-
Notifications
You must be signed in to change notification settings - Fork 6k
Consider adding switch to enable or disable OIDC nonce #7696
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
Comments
@hejianchao Regarding your comment:
If this is the case than the provider is NOT OpenID Connect compliant. As per spec, in the ID Token section:
The Authorization Server MUST include the nonce Claim in the ID Token if it was sent in the Authentication Request. If you need to override the Authentication Request to not include the |
@jgrandja It works but not so convenient, For optional parameters like nonce, switches are a more convenient way. Anyway, thanks for your information. |
Which provider are you having this issue with? Could you provide more details around the error message? Is the error message being triggered by the provider or client? |
The method that throws the exception is:
|
@hejianchao Which provider are you using? |
I also ran into this issue using a proprietary in house IdP from a large organization. This IdP provides a limited openid feature set and does not support nonce parameters. It does however integrate with well known clients like Keycloak and others. Although one can navigate around this problem as was suggested above. This is not a very clean solution. It would be nice to have a switch to disable requesting nonces. |
@hejianchao @soarten I took a look at pac4j and I see that it provides a switch Instead of the switch approach, we're looking at introducing a Let me know your thoughts. |
@jgrandja Great, through |
Using switches for all sorts of options is far from ideal indeed, this would be a better solution! |
@jgrandja I think there's a problem with |
@jadzie Can you put together a minimal sample or a test that reproduces the issue. This will make it more clear to me if there is an issue or not. |
@jgrandja ok, will try to do it for tomorrow |
@jgrandja https://github.com/jadzie/login-oidc-customizer-test I hope the readme is descriptive enough :) |
@jgrandja glad I could help :) |
Sign In with LinkedIn V2 does not support the OIDC nonce either. I ended up configuring an authorization request customizer as suggested by @jgrandja here. |
OpenID doc says: So it's not a required field for the sender. I wish there was a provider option for disabling nonce. Is it okay If I open a PR for this issue? |
@thammerl I am building a python flask app, and running into the issue you mentioned here, where my app is faced with a "missing_claim: Missing "nonce" claim" error. Any suggestions on how to resolve? This is the piece of the code, which is on the callback, where this happens: Auth route@app.route('/auth') I recognise that this is an out-of-scope question because diff lan and libs, but I'm a newbie and thought it wouldn't hurt to ask |
@ashwinlimaye You shouldn't send |
Thanks. Actually after some more digging I discovered that LinkedIn have
changed a lot of things about how their oauth works. Also found some sample
code by the LinkedIn team on GitHub, and now things are working fine. Short
version is that there is a large gap between official documentation, sample
code that works, and older sample code on various parts of the internet. :-)
…On Tue, 23 Jan 2024, 13:00 Menderes, ***@***.***> wrote:
@ashwinlimaye <https://github.com/ashwinlimaye> You shouldn't send nonce
field to LinkedIn. Check out your oauth library to have some
configuration to change or try to create a hook before sending a request.
—
Reply to this email directly, view it on GitHub
<#7696 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/A5HDRE56DY4GPWIZZAUXFZDYP6X7BAVCNFSM4JVB37I2U5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TCOJQGYYDCMBXGM3Q>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
got a link? |
Ah, can't seem to find it. But here are some code snippets that work within my app (today), so should be a good pointer for you:
|
I am unfortunately running into this issue with the Intuit (Quickbooks) OpenID Connect implementation. They fail to send the nonce parameter if it's included in the authentication request. Sigh. I'll implement the resolver. I just thought I'd add this comment in case someone else is running into this. Thank you for the workaround tip! |
Okay, I got it working with the help of Baeldung's article here: https://www.baeldung.com/spring-security-custom-oauth-requests Here's my customizeAuthorizationRequest method: private OAuth2AuthorizationRequest customizeAuthorizationRequest(OAuth2AuthorizationRequest req) {
return OAuth2AuthorizationRequest.from(req)
.attributes(attrs -> attrs.remove(OidcParameterNames.NONCE))
.build();
} |
Alternatively: @Configuration
public class SecurityConfiguration {
@Bean
public SecurityFilterChain filterChain(HttpSecurity http, ClientRegistrationRepository clientRegistrationRepository) throws Exception {
http.oauth2Login(login ->
login.authorizationEndpoint(authzEndpoint -> {
final DefaultOAuth2AuthorizationRequestResolver resolver = new DefaultOAuth2AuthorizationRequestResolver(
clientRegistrationRepository, OAuth2AuthorizationRequestRedirectFilter.DEFAULT_AUTHORIZATION_REQUEST_BASE_URI);
resolver.setAuthorizationRequestCustomizer(req -> req.attributes(attrs -> attrs.remove(OidcParameterNames.NONCE)));
authzEndpoint.authorizationRequestResolver(resolver);
}));
return http.build();
}
} |
I am struggling with this as well. The challenge I am having is that I want to disable nonce for some providers (e.g. linkedin), while not for the others (e.g. google). I see no way of doing this cleanly, and am required to duplicate code to extract the clientRegistrationId from the requestUri. Does anyone know of a clean way to use the customizer for a specific registrationId? |
@hejianchao No there isn't a setting/property available to turn it off. Are you having issues with it? Why do you want it disabled?
Originally posted by @jgrandja in #4442 (comment)
This issue was created for two reasons:
invalid nonce
Also, as far as I know, the pac4j framework supports nonce settings (link).
The text was updated successfully, but these errors were encountered: