Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Composite claims in OIDC connector #3

Merged
merged 8 commits into from
Jul 27, 2023
Merged

Composite claims in OIDC connector #3

merged 8 commits into from
Jul 27, 2023

Conversation

Oded-B
Copy link
Owner

@Oded-B Oded-B commented Jul 18, 2023

Overview

Adds the ability to compose new group claims elements in the OIDC connector, based on other claims.
So this OIDC connector config:

     claimConcatenations:
        - claimList:
           - "organization_slug"
           - "pipeline_slug"
           - "build_branch"
          delimiter: "::"
          prefix: "bk"

Would result in this element in the group claim which looks like this:: bk::acme-inc::super-duper-app::main

What this PR does / why we need it

After dex/pull/2806 we are able to authenticate with JWT generated by CI systems.
The claim provided by those system are usually static and if the upstream OIDC service doesn't support sophisticated query language in its IAM/RBAC mechanism the operator might be enable to find a configuration that provided the needed granularity.

For example, lets say you want a specific Buildkiite pipeline to run a sync action on an ArgoCD instance.
These are claim provided by Buildkite CI/CD system:

{
  "iss": "https://agent.buildkite.com",
  "sub": "organization:acme-inc:pipeline:super-duper-app:ref:refs/heads/main:commit:9f3182061f1e2cca4702c368cbc039b7dc9d4485:step:build",
  "aud": "https://buildkite.com/acme-inc",
  "iat": 1669014898,
  "nbf": 1669014898,
  "exp": 1669015198,
  "organization_slug": "acme-inc",
  "pipeline_slug": "super-duper-app",
  "build_number": 1,
  "build_branch": "main",
  "build_commit": "9f3182061f1e2cca4702c368cbc039b7dc9d4485",
  "step_key": "build",
  "job_id": "0184990a-477b-4fa8-9968-496074483cee",
  "agent_id": "0184990a-4782-42b5-afc1-16715b10b8ff"
}

AFAIKT ArgoCD doesn't have fancy query language in its RBAC config (regexs are supported to action field only)
So If you want to allow pipelines runs from a specific repo and branch combination, you would need to combine organization_slug, pipeline_slug and build_branch claims ( notice the sub claim includes the git commit, making it unusable as reference for RBAC ).

With this PR you'll be able to concatenate/compose multiple claims to a new element in the group claim:

        - name: Buildkite Agents OIDC
          type: oidc
          id: bk-oidc
          config:
            issuer: https://agent.buildkite.com
            scopes:
              - groups
              - openid
            userNameKey: sub
            claimConcatenations:
              - claimList:
                  - "organization_slug"
                  - "pipeline_slug"
                  - "build_branch"
                delimiter: "::"
                prefix: "bk"

This would be the resulting group : bk::acme-inc::super-duper-app::main
And you can refrence it in ArgoCD RBAC like so:

      g, bk::acme-inc::super-duper-app::main, role:cicd-sync

Special notes for your reviewer

This is intended as a temporary solution until a more flexible solution is provided via https://github.com/dexidp/dex/issues/1635.
Because the problem is uniq to service-tied JWTs and only relevant for OIDC I believe a connecter-specific solution is acceptable.

Does this PR introduce a user-facing change?

Enhancements:
* Support composing new group claims in OIDC connector.

@Oded-B Oded-B changed the title Composite claims Composite claims in OIDC connector Jul 27, 2023
@Oded-B Oded-B merged commit 0af364c into master Jul 27, 2023
Oded-B added a commit that referenced this pull request Jul 27, 2023
* Add the ability to composite new claims in the OIDC connector,  based on upstream claims

Signed-off-by: Oded Ben-Ozer <obenozer@wayfair.com>
Oded-B added a commit that referenced this pull request Aug 6, 2023
* Add the ability to composite new claims in the OIDC connector,  based on upstream claims

Signed-off-by: Oded Ben-Ozer <obenozer@wayfair.com>
Oded-B added a commit that referenced this pull request Aug 6, 2023
* Add the ability to composite new claims in the OIDC connector,  based on upstream claims

Signed-off-by: Oded Ben-Ozer <obenozer@wayfair.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant