-
Notifications
You must be signed in to change notification settings - Fork 33
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
Add tokens exchange functionality #66
Closed
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR, great work. I have commented with an alternative approach to solve the missing id token issue, wdyt about that?
Great addition @fritjofbohm, thank you! Merged with 47bc477 👍🏻 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi all,
this PR adds a basic token exchange functionality (see https://www.rfc-editor.org/rfc/rfc8693) to this package.
With this functionality, this module can request a new token on behalf of an authenticated user, but with a different audience or different scope.
In my use case, there's an internal API that also uses SSO to identify the user. The token issued by the SSO for my Symfony app doesn't work for the API (different audience/scope). This is where the token exchange comes in: The app can ask the SSO provider to issue a new token that can authenticate the user against the API.
This whole procedure is not overly complicated, but there are some things in this module's core that need to be modified for it. The changes should not break any public signatures, so this could be a new minor version. I'm very open to any suggestions - please let me know what you think.
Requesting an exchange token is basically the same as requesting an
authorization_code
orrefresh_token
, only that there are some additionalparams
in the token endpoint call. The response is a little different though, so there are some reefs I needed to navigate around.OidcClient->requestTokens()
has a few additional parameters.OidcTokens
tostdClass
. This is because the exchange tokens response does not contain an ID token, and calling the originalOidcTokens
constructor without ID token would fail.OidcTokens
now happens inauthenticate()
andrefreshTokens()
.OidcClient->exchangeTokens()
(and also in the client interface). This method will initiate the tokens exchange.exchangeTokens()
uses the new classOidcExchangeTokens
instead ofOidcTokens
.The tokens exchange functionality could for example be used like this: