fix: remove duplicate trailing slash from client_assertion audience#236
Open
samjetski wants to merge 1 commit into
Open
fix: remove duplicate trailing slash from client_assertion audience#236samjetski wants to merge 1 commit into
samjetski wants to merge 1 commit into
Conversation
Contributor
|
Hi @samjetski 👋 Thanks a lot of flagging this. Appreciate you taking the effort to help fix it as well. We will take a look at this PR, in the meanwhile, can you please sign the commit? We will also make sure that this ask (mandatory signed commit) is clear in our contributing guidelines and PR template checklist. |
This file contains hidden or 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
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.
Description
The
OnAuthorizationCodeReceivedhandler builds theaudclaim for the Private Key JWT client assertion sent to/oauth/token. Since v1.7.0 it has been double-appending the trailing slash:Utils.ToAuthority(added in #206) already normalises its input to a value ending in/, so the resulting audience becomeshttps://{tenant}//(two slashes). Auth0's/oauth/tokenendpoint validates thataudexactly matches the tenant token endpoint with a single trailing slash, so it rejects the assertion with401 invalid_client.The visible symptom for affected apps (any app configured with
ClientAssertionSecurityKey) is a callback loop: the OIDC middleware can't complete the code-for-token exchange, retries/authorize, Auth0's SSO cookie immediately returns a new code, and the cycle repeats. Server logs show:The companion
TokenClientpath (used for refresh-token exchange inTokenClient.cs:68) already used the single-slash form$"https://{domain}/"and was unaffected — so the fix brings the OIDC callback path back in line with it.The change is a one-line removal of the duplicate
+ "/".References
Testing
The existing integration test
Should_Send_ClientAssertion_To_Token_Endpointonly asserted that aclient_assertionform parameter was present, which is how this slipped through. It has been strengthened to:HttpRequestMessage.GetClientAssertion()test helper.Audiencescontains exactlyhttps://{domain}/(single trailing slash), plus thatIssuerandSubjectequal the configuredClientId.Verified by temporarily reverting the fix — the new assertion fails with the buggy double-slash audience; restoring the fix passes.
Full integration suite: 205/205 passing locally on
net10.0.Checklist
main