question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Feature Request] During auth code redemption, send `code_verifier` to /token endpoint as part of auth code + pkce

See original GitHub issue

Background For details, see the spec for auth code + pkce for public clients.

Auth code + pkce was originally implemented for public clients as they are susceptible to having the auth code intercepted. However, more and more confidential clients are wanting to implement pkce: image

ASP NET Core surfaces the code_verifier in the AuthenticationProperties collection on the event context.

Part of this work is adding a client secret for the web app, in the templates, now as the secret will be used to verify the client.

Next Steps MSAL .NET needs to support auth code + pkce for confidential clients first, so that we can use it during auth code redemption. See issue here.

ASP NET starts the first leg of the auth code flow, and includes code_challenge and code_challenge_method to the /authorize endpoint.

Then, the second part, MS Identity Web, using MSAL, will need to send the code + code_verifier (which we will get in the AuthenticationProperties) so that the server can verify the original code_challenge.

We need to complete the work in MSAL .NET first. We can use the MSAL Java implementation for this.

Here is where the developer provides the code_challenge and code_challenge_method: https://github.com/AzureAD/microsoft-authentication-library-for-java/blob/dev/src/main/java/com/microsoft/aad/msal4j/AuthorizationRequestUrlParameters.java#L84

And where the developer passes in the code_verifier. https://github.com/AzureAD/microsoft-authentication-library-for-java/blob/dev/src/main/java/com/microsoft/aad/msal4j/AuthorizationCodeParameters.java#L47

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:21 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
Ponantcommented, May 11, 2021

@jmprieur , I checked out further, and the only way to make it work from the base template (updated nuget) is to do on the portal a spa registration, so @tedvanderveen is right. So I do not understand how you get it to work with the web option in azure? The portal even hapily displays “Your Redirect URI is eligible for the Authorization Code Flow with PKCE.” Here is the output manifest

"replyUrlsWithType": [
		{
			"url": "https://localhost:44339/signin-oidc",
			"type": "Spa"
		}

Edit: Furthermore, the options.ResponseType = OpenIdConnectResponseType.Code; options.Scope.Add(options.ClientId); need to be added in startup. SO I believe we disagree.

1reaction
tedvanderveencommented, May 11, 2021

@Ponant yes it just works!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Authorization Code Flow with Proof Key for ...
Learn how the Authorization Code flow with Proof Key for Code Exchange (PKCE) works and why you should use it for native and...
Read more >
Implement the OAuth 2.0 Authorization Code with PKCE Flow
The app makes the request to exchange the code for tokens, only it sends the Code Verifier instead of a fixed secret. Now...
Read more >
Implement authorization by grant type | Okta Developer
PKCE ensures that only the client that requests the access token can redeem it. Save the generated Client ID value to implement your...
Read more >
Call Your API Using the Authorization Code Flow with PKCE
Create code verifier: Generate a code_verifier that will be sent to Auth0 to request ... Refresh tokens: Use a Refresh Token to request...
Read more >
RFC 7636 - Proof Key for Code Exchange by OAuth Public ...
RFC 7636 OAUTH PKCE September 2015 Table of Contents 1. Introduction . ... Client Sends the Authorization Code and the Code Verifier to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found