Open tedvanderveen opened 3 years ago
@tedvanderveen
If you are interested in writing a SPA, we suggest you use MSAL.js, not Microsoft.Identity.Web.
@jmprieur the notion of a "confidential app" and the usage of client_secret in relation to OAuth flows is being deprecated in favor of usage of PKCE. As per the latest version of the latest OAuth 2.0 Security Best Current Practice: https://datatracker.ietf.org/doc/draft-ietf-oauth-security-topics In section 2.1.1. it states:
Public clients MUST use PKCE [RFC7636] to this end. For confidential clients, the use of PKCE [RFC7636] is **RECOMMENDED**.
Additionally, AAD B2C also supports it.
Why would this library allow sign-in and acquire access/refresh tokens on sign-in using PKCE, but suddenly require a client_secret if one wants to actually use that refresh token to obtain a fresh access token?
For who is actually interested in learning why PKCE is also important for confidential apps, please read up on why the industry is moving in this direction.
@jmprieur just to sum things up:
Is this a correct reflection of current design?
@tedvanderveen , did you try commenting the code?
MergedOptionsValidation.ValidateEitherClientCertificateOrClientSecret(
mergedOptions.ClientSecret,
mergedOptions.ClientCertificates);
in
private IConfidentialClientApplication BuildConfidentialClientApplication(MergedOptions mergedOptions)
?
Well, no it throws here
IConfidentialClientApplication app = builder.Build();
For who is actually interested in learning why PKCE is also important for confidential apps, please read up on why the industry is moving in this direction.
Message received, thanks @tedvanderveen. The current implementation uses a nonce and tokens cannot be replayed, but we can go the extra mile. Having said that last time I checked the middleware (which validates the ID token in a web app) wasn't happy without the ID token.
@jmprieur just to sum things up:
- By design this lib DOES SUPPORT a "public" app to signin users to B2C with PKCE and obtain a refresh_token
- By desgin this lib DOES NOT SUPPORT a "public" app to do anything useful with that same refresh_token (although B2C itself DOES support this)
Is this a correct reflection of current design?
What is a public app? Ms.id.web is only about confidential client apps?
@jmprieur , there is also this video in case you did not have a look at: https://www.youtube.com/watch?v=1ot45WwQWJE for example. It uses a real world example of a server app and the guy is just logging in with google.
In short, to me at least, the idea is that PKCE on a confidential app even without an API call should be made possible in the libraries, with the last step of the code_verifier being applied. I see PKCE on a server web app delivering html as better than client sercrets, a bit similar in philosophy to antiforgery tokens in the older days because the code_verifier is a random string that is generated each time, which is better than a one time secret stored in the server.
I understand that there are diverse opinions on this, and I have seen on SO a few answers saying that PKCE on a server app without api calls adds little security, but there are opinions on the opposite, two, and I believe that this is why the specs recommend PKCE for confidential clients regardless of the presence of APIS.
Personnaly I would like to see this implemented.
@jmprieur just to sum things up:
- By design this lib DOES SUPPORT a "public" app to signin users to B2C with PKCE and obtain a refresh_token
- By desgin this lib DOES NOT SUPPORT a "public" app to do anything useful with that same refresh_token (although B2C itself DOES support this)
Is this a correct reflection of current design?
What is a public app? Ms.id.web is only about confidential client apps?
A public App is an app that cannot securely handle confidential secrets i.e. a client_secret
for example. And -also for that reason- leverages PKCE flows to solve issues that traditionally that client_secret
takes care of.
If this lib also fully embraces PKCE flow, then it can also be used by -for example- Blazor WebAssembly public apps.
Is your feature request related to a problem? Please describe. Azure B2C allows for using a refresh token for obtaining a new access token without supplying a client_secret. See following successfull request/reponse:
But the class
TokenAcquisition
requires a client secret or client certificate to be provided. Of not, the following error is thrown:IDW10104: Both client secret and client certificate cannot be null or whitespace, and only ONE must be included in the configuration of the web app when calling a web API. For instance, in the appsettings.json file.
.See this hard dependency on "confidential" app configuration here: https://github.com/AzureAD/microsoft-identity-web/blob/14429b8cb93352d78b6e1618d3a0bb50f203602d/src/Microsoft.Identity.Web/TokenAcquisition.cs#L651
Describe the solution you'd like Enable the supported B2C API for acquiring access tokens, as B2C does not require client secrets or certs. This is especially usefull in scenario's where B2C support for PKCE is leveraged and the original refresh token is also obtained without a client_secret
Describe alternatives you've considered Write our own implementation of
ITokenAcquisition
that does not mandate client_secret or cert.