Skip to content

Pipeline identity token var_source - #9035

Merged
taylorsilva merged 21 commits into
concourse:masterfrom
dbaumgarten:feature/pipeline-identities
Jun 24, 2025
Merged

taylorsilva merged 21 commits into
concourse:masterfrom
dbaumgarten:feature/pipeline-identities

Conversation

@dbaumgarten

@dbaumgarten dbaumgarten commented Dec 3, 2024 •

Copy link
Copy Markdown
Contributor

Changes proposed by this PR

This PR is the implementation of RFC139.

The idtoken var_source generates a signed jwt, which contains infomation about the pipeline (team, pipeline-name etc.). It can be send to external services for authentication.

This PR makes it possible to have a pipeline like this:

var_sources:
- name: idtoken
  type: idtoken
  config:
    audience: ["sts.amazonaws.com"]
    expires_in: 1h

jobs:
- name: print-creds
  plan:
  - task: print
    config:
      platform: linux

      image_resource:
        type: registry-image
        source: {repository: ubuntu}

      run:
        path: bash
        args:
        - -c
        - |
          echo token: ((idtoken:token))
          // Send this token as part of an API-Request to an external service

Phase 1:

  • Add var_source for identity tokens
  • Store and retrieve signing keys in DB
  • Publish signing keys as JWKs
  • Add job+step info to token (if possible)
  • Support RSA and ECDSA signatures (optional)
  • Tests

Phase 2:

  • Automatically rotate the signing key periodically

Phase 3:

  • Provide a token introspection endpoint (to be discussed if this really provides any benefit)

@dbaumgarten
dbaumgarten force-pushed the feature/pipeline-identities branch from b000a00 to 0458916 Compare December 3, 2024 08:08
@dbaumgarten
dbaumgarten force-pushed the feature/pipeline-identities branch 3 times, most recently from becd951 to fd0872d Compare April 26, 2025 08:42
@dbaumgarten

Copy link
Copy Markdown
Contributor Author

Hey @taylorsilva ,

as of now Phase 1 of the RFC is nearly complete. Tokens can be obtained from the var-source, keys are stored in the DB and published via a public API-Endpoint as JWKs. I tested it with vault's JWT-Auth feature and it is working just fine.

Still missing is the job/step info in the token (honestly, I have no idea how to do this...) and of course tests.

If you have some time to spare, I would appreciate some feedback, so I can see if I am going in the right direction.
(It is however not super urgent, as I am going on vacation for about a week, so take your time :) )

@taylorsilva

Copy link
Copy Markdown
Member

@dbaumgarten I'll try and take a look next week. Got a bit in my plate right now.

@dbaumgarten
dbaumgarten force-pushed the feature/pipeline-identities branch from fd0872d to e5c03e4 Compare May 10, 2025 10:48
@taylorsilva taylorsilva moved this from Todo to In Progress in Pull Requests May 15, 2025

@taylorsilva taylorsilva left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've given the smaller pieces of this a quick glance. It's looking good so far.

I haven't had time to dig into the job/step name stuff yet. Definitely isn't straight forward how we'll get that in there. Not sure if it may bee a good opportunity to use the Options pattern here 🤔

I see you're adding testflight tests now, really appreciate that!

Don't forget to add tests to the API layer.

Thanks for the work so far, it's looking great! 👏

Comment thread atc/atccmd/command.go Resolved
@dbaumgarten
dbaumgarten force-pushed the feature/pipeline-identities branch from 277c5a7 to 911665e Compare May 16, 2025 06:37
@dbaumgarten

dbaumgarten commented May 16, 2025 •

Copy link
Copy Markdown
Contributor Author

I tried adding the job-info. But it turned out to be a gigantic mess and in the end didn't even work out properly...

I will add some tests for the API. Added some tests for the API to fetch signing keys.

@dbaumgarten
dbaumgarten requested a review from taylorsilva May 16, 2025 15:39
@dbaumgarten
dbaumgarten marked this pull request as ready for review May 22, 2025 16:17
@dbaumgarten
dbaumgarten requested a review from a team May 22, 2025 16:17
@dbaumgarten
dbaumgarten force-pushed the feature/pipeline-identities branch from 1648310 to 636fce6 Compare May 22, 2025 16:23
@dbaumgarten

Copy link
Copy Markdown
Contributor Author

Hey @taylorsilva ,

i finally figured out how to get instance-vars and job-name into the idtoken (however I have still no idea how to get step-info in there). See the latest commit.

It isn't beautiful and I had to change stuff in quite a few places.
However, it does seem to work nicely.

The basic idea is to add a new parameter to creds.NewVariables (which contains context-info for the secrets-lookup) and therefore force all callers of creds.NewVariables to provide these context-infos.
A new interface "SecretsWithContext" has been added, which extends the existing Secrets-Interface with new methods. Secret-Providers can implement this interface if they want to use context-information for the secrets lookup.
All intermediate secrets-providers (caching and retry) also need to implement the new Interface and pass on the context they receive to any wrapped secrets-providers.

Resulting tokens now look like this:

{
  "aud": "sts.amazonaws.com",
  "exp": 1747933980,
  "iat": 1747930380,
  "instance_vars": {
    "branch": "develop"
  },
  "iss": "http://localhost:8080",
  "job": "print-creds",
  "jti": "2624488249486034719",
  "pipeline": "test2",
  "sub": "main/test2/branch:develop/print-creds",
  "team": "main"
}

@taylorsilva

Copy link
Copy Markdown
Member

Awesome! Thanks for all the work. I'm going to start wrapping my head around all the code changes here and reviewing. There is a lot so might take me a bit of time.

@dbaumgarten

Copy link
Copy Markdown
Contributor Author

Yeah, this somehow turned out much larger than expected...
Take your time

@taylorsilva taylorsilva left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for waiting. Overall this is looking really good! I haven't had time to test it locally but I'm happy to see you added some tests to testflight!

I just unpaused the pipeline for this PR, so we'll see how all those tests go. I'll play around with this soon, just wanted to share the feedback I have so far.

I think the changes you made to get the job name in are good. It does seem like too much work to get the step name in. Like our RFC said, best effort to get it in. I think most folks will be happy having the job name in there. It's probably enough granularity for users to work with.

The majority of my feedback is what I'd consider "nit-pick" level stuff, though they should be easy to resolve.

The one thing I do request be changed is how the SigningKeyLifecycler gets wired up and invoked.

Once that's resolved though and I play around with it a bit, I'm not seeing any other blockers with getting this in. Thanks so much for all the work you've done so far!

Comment thread atc/auditor/auditor.go Resolved
Comment thread atc/api/idtoken_test.go Resolved
Comment thread atc/creds/cached_secrets_test.go Resolved
Comment thread atc/atccmd/command.go Resolved
Comment thread atc/creds/idtoken/manager.go Resolved
Comment thread atc/creds/idtoken/lifecycle.go Resolved
Comment thread atc/creds/retryable_secrets_test.go Resolved
Comment thread atc/db/signing_key_factory.go Resolved
Comment thread atc/creds/idtoken/token_generator.go Resolved
Comment thread atc/creds/secrets_factory.go Resolved
@dbaumgarten

Copy link
Copy Markdown
Contributor Author

That's a lot of (quite reasonable) feedback. I will resolve it step by step, but it might take a few days.

@dbaumgarten
dbaumgarten force-pushed the feature/pipeline-identities branch 2 times, most recently from b96ee62 to e3daab3 Compare May 30, 2025 10:01
@dbaumgarten
dbaumgarten requested a review from taylorsilva May 30, 2025 10:34
@dbaumgarten

Copy link
Copy Markdown
Contributor Author

Hi @taylorsilva ,
I have adressed your findings. Things look quite a bit cleaner now.

@dbaumgarten

Copy link
Copy Markdown
Contributor Author

I would really like to know what checks are failing there and why.
However it seems like I am unable to view the pipelines. Clicking on the failed checks brings me to a concourse, but login in with github then just shows me an empyt and endlessly loading page:
grafik

@dbaumgarten

Copy link
Copy Markdown
Contributor Author

@taylorsilva did you already find some time to play around with this feature?

dbaumgarten and others added 17 commits June 23, 2025 14:34
Signed-off-by: dbaumgarten <[email protected]>

Co-authored-by: Taylor Silva <[email protected]>
Signed-off-by: dbaumgarten <[email protected]>

Co-authored-by: Taylor Silva <[email protected]>
Signed-off-by: dbaumgarten <[email protected]>

Co-authored-by: Taylor Silva <[email protected]>
Signed-off-by: dbaumgarten <[email protected]>

Co-authored-by: Taylor Silva <[email protected]>
Signed-off-by: dbaumgarten <[email protected]>

Co-authored-by: Taylor Silva <[email protected]>
Signed-off-by: dbaumgarten <[email protected]>
@taylorsilva
taylorsilva force-pushed the feature/pipeline-identities branch from 7d95137 to d6d6c94 Compare June 23, 2025 18:35
@taylorsilva

Copy link
Copy Markdown
Member

FYI: I had to rebase the branch, the goimport command had a small change and some unrelated files needed to be updated, which was done on master.

I am actively reviewing this now, thanks for waiting 🙏

@taylorsilva taylorsilva left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost there, just want your thoughts on the new instance scope.

Comment thread atc/creds/idtoken/token_generator.go Resolved
@taylorsilva
taylorsilva merged commit 58b7d06 into concourse:master Jun 24, 2025
@github-project-automation github-project-automation Bot moved this from In Progress to Done in Pull Requests Jun 24, 2025
@taylorsilva

Copy link
Copy Markdown
Member

@dbaumgarten

Copy link
Copy Markdown
Contributor Author

You're welcome :)
Glad I could contribute something useful.

I will take a look at the documentation in the next few days.

Do you already have a rough idea when a version containing this feature will be released?

@taylorsilva

Copy link
Copy Markdown
Member

Do you already have a rough idea when a version containing this feature will be released?

I am planning to make a 7.14 release that would contain this feature. 7.14 will also contain the first official ARM release of Concourse, which is the main reason for the release. I need to finish the release engineering work and then I'll make a release. Some time in July is my current goal.

@dbaumgarten

Copy link
Copy Markdown
Contributor Author

@taylorsilva Do you think I should also add a page to the Credential Management Section of the docs, explaining the feature in more detail (maybe including examples)?

Or is the section under var-sources good enough?

@taylorsilva

Copy link
Copy Markdown
Member

Do you think I should also add a page to the Credential Management Section of the docs, explaining the feature in more detail (maybe including examples)?

I think that's a good idea. It feels a bit odd putting it on that page, but I don't think there's a better place for it right now. Do it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants