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

implement iam-runtime GetAccessToken #39

Merged
merged 6 commits into from
May 3, 2024
Merged

Conversation

mikemrm
Copy link
Contributor

@mikemrm mikemrm commented Apr 17, 2024

This implements the GetAccessToken method which returns an access token upon request.

Returned tokens can be configured to be from a file or client credentials.
Additionally the sourced token can be exchanged for another token.

This is particularly useful within a kubernetes cluster.
You can exchange the service account token for one from another issuer.

@mikemrm mikemrm force-pushed the implement-exchange-token branch from 44ec769 to 3c057e2 Compare April 18, 2024 12:53
@mikemrm mikemrm force-pushed the implement-exchange-token branch from 3c057e2 to 6684a7d Compare April 25, 2024 17:20
@mikemrm mikemrm changed the title implement iam-runtime ExchangeToken implement iam-runtime GetAccessToken Apr 25, 2024
@mikemrm mikemrm force-pushed the implement-exchange-token branch 2 times, most recently from 2c38384 to f681ba6 Compare April 26, 2024 18:26
@mikemrm mikemrm marked this pull request as ready for review April 26, 2024 18:27
@mikemrm mikemrm requested review from a team as code owners April 26, 2024 18:27
@mikemrm mikemrm force-pushed the implement-exchange-token branch 2 times, most recently from 37b4cd3 to db28be4 Compare May 1, 2024 20:52
@mikemrm mikemrm marked this pull request as draft May 1, 2024 20:54
@mikemrm mikemrm force-pushed the implement-exchange-token branch from db28be4 to 85889cf Compare May 2, 2024 17:01
@mikemrm mikemrm marked this pull request as ready for review May 2, 2024 17:03
@mikemrm mikemrm force-pushed the implement-exchange-token branch 2 times, most recently from 1f18247 to 73ce84e Compare May 2, 2024 17:44
This implements the GetAccessToken method which returns an access token upon request.

Returned tokens can be configured to be from a file or client credentials.
Additionally the sourced token can be exchanged for another token.

This is particularly useful within a kubernetes cluster.
You can exchange the service account token for one from another issuer.

Signed-off-by: Mike Mason <[email protected]>
@mikemrm mikemrm force-pushed the implement-exchange-token branch from 73ce84e to c5ef94c Compare May 3, 2024 12:43
Copy link
Contributor

@jnschaeffer jnschaeffer left a comment

Choose a reason for hiding this comment

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

Looks good! Some thoughts.

config.example.yaml Show resolved Hide resolved
internal/accesstoken/tokenexchange.go Outdated Show resolved Hide resolved
internal/accesstoken/tokenexchange.go Outdated Show resolved Hide resolved
Comment on lines +89 to +91
oauth2.SetAuthURLParam("grant_type", s.cfg.GrantType),
oauth2.SetAuthURLParam("subject_token", s.upstreamToken.AccessToken),
oauth2.SetAuthURLParam("subject_token_type", s.cfg.TokenType),
Copy link
Contributor

Choose a reason for hiding this comment

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

Usually I like to make OAuth parameters constants elsewhere, though in this case since we're not reusing them anywhere this might be fine.

internal/filetokensource/doc.go Outdated Show resolved Hide resolved
internal/filetokensource/token.go Show resolved Hide resolved
internal/jwt/jwks.go Outdated Show resolved Hide resolved
mikemrm and others added 5 commits May 3, 2024 08:33
Co-authored-by: John Schaeffer <[email protected]>
Signed-off-by: Mike Mason <[email protected]>
Co-authored-by: John Schaeffer <[email protected]>
Signed-off-by: Mike Mason <[email protected]>
Signed-off-by: Mike Mason <[email protected]>
@mikemrm mikemrm force-pushed the implement-exchange-token branch from f769099 to 593cd3a Compare May 3, 2024 13:34
@mikemrm mikemrm requested a review from jnschaeffer May 3, 2024 13:35
@mikemrm mikemrm merged commit 3f4d1ca into main May 3, 2024
3 checks passed
@mikemrm mikemrm deleted the implement-exchange-token branch May 3, 2024 13:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants