-
Notifications
You must be signed in to change notification settings - Fork 6k
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 nonce to OIDC Authentication Request #7337
Conversation
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.
@mkheck Thanks for the PR! I left a couple of comments for you. Also, can you please rebase off master and squash commits to one and than force push. Please ensure you do fast-forward merges as we use this git process. Thanks!
...ava/org/springframework/security/oauth2/client/oidc/authentication/OidcIdTokenValidator.java
Outdated
Show resolved
Hide resolved
...work/security/oauth2/client/web/reactive/function/client/OAuth2AuthorizedClientResolver.java
Outdated
Show resolved
Hide resolved
...rity/oauth2/client/web/reactive/result/method/annotation/OAuth2AuthorizedClientResolver.java
Outdated
Show resolved
Hide resolved
...ore/src/main/java/org/springframework/security/oauth2/core/endpoint/NonceParameterNames.java
Outdated
Show resolved
Hide resolved
@mkheck I've been thinking about whether the
which is not ideal since we would have to create a new The other solution is to implement the validation check in Makes sense? |
…est, also added comparison+verification in IdToken
…ssue to be discussed w/team
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.
.../security/oauth2/client/oidc/authentication/OidcAuthorizationCodeAuthenticationProvider.java
Outdated
Show resolved
Hide resolved
.../security/oauth2/client/oidc/authentication/OidcAuthorizationCodeAuthenticationProvider.java
Outdated
Show resolved
Hide resolved
.../security/oauth2/client/oidc/authentication/OidcAuthorizationCodeAuthenticationProvider.java
Outdated
Show resolved
Hide resolved
.../security/oauth2/client/oidc/authentication/OidcAuthorizationCodeAuthenticationProvider.java
Outdated
Show resolved
Hide resolved
...ava/org/springframework/security/oauth2/client/oidc/authentication/OidcIdTokenValidator.java
Outdated
Show resolved
Hide resolved
...rg/springframework/security/oauth2/client/web/DefaultOAuth2AuthorizationRequestResolver.java
Outdated
Show resolved
Hide resolved
String nonceHash = createHash(nonce); | ||
additionalParameters.put(IdTokenClaimNames.NONCE, nonceHash); | ||
} catch (NoSuchAlgorithmException e) { | ||
// MAH: TODO...but what? |
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.
If the nonce
hash could not be created because of JCE crypto lib missing than we should not add the nonce
to attributes
, effectively creating an Authentication Request without a nonce
as is the current impl.
...rg/springframework/security/oauth2/client/web/DefaultOAuth2AuthorizationRequestResolver.java
Outdated
Show resolved
Hide resolved
...ework/security/oauth2/client/web/server/DefaultServerOAuth2AuthorizationRequestResolver.java
Show resolved
Hide resolved
...main/java/org/springframework/security/oauth2/core/endpoint/OAuth2AuthorizationResponse.java
Outdated
Show resolved
Hide resolved
Implements nonce functionality for OpenID Connect authentication request in OAuth2 Authorization Code flow. This includes the following capabilities: * Generate nonce * Generate hash of nonce * Add nonce to attributes and hash to additional parameters of authentication request * Propagate hash to authentication response * Verify hash upon receipt of response by hashing original nonce * Complete all relevant tests Fixes/implements spring-projectsgh-4442
Hi @jgrandja, Good catches one and all. I've reworked per your recommendations and all build tests pass. LDAP integration tests are failing, but I suppose those are resolved by Travis? I've also formatted the commit message per the guidelines you provided. 😃 Please let me know of any additional changes required or desired. Thanks! |
Missed 4 unit tests in Still getting local failures with various LDAP tests under |
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 updates @mkheck. Please see comments inline.
...rg/springframework/security/oauth2/client/web/DefaultOAuth2AuthorizationRequestResolver.java
Outdated
Show resolved
Hide resolved
...rg/springframework/security/oauth2/client/web/DefaultOAuth2AuthorizationRequestResolver.java
Outdated
Show resolved
Hide resolved
.../security/oauth2/client/oidc/authentication/OidcAuthorizationCodeAuthenticationProvider.java
Outdated
Show resolved
Hide resolved
...ework/security/oauth2/client/web/server/DefaultServerOAuth2AuthorizationRequestResolver.java
Show resolved
Hide resolved
.../security/oauth2/client/oidc/authentication/OidcAuthorizationCodeAuthenticationProvider.java
Show resolved
Hide resolved
...rg/springframework/security/oauth2/client/oidc/authentication/OidcIdTokenValidatorTests.java
Show resolved
Hide resolved
...src/main/java/org/springframework/security/oauth2/core/oidc/endpoint/OidcParameterNames.java
Show resolved
Hide resolved
Made changes requested by Joe Grandja to PR, including addition of test when nonce isn't present in request. Fixes spring-projectsgh-4442 and addresses changes requested to PR
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.
Please let me know Joe, thanks!
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 updates @mkheck. Please see my comments.
Also, can you add a test in OidcAuthorizationCodeReactiveAuthenticationManagerTests
This is a PR for gh-4442: Consider adding nonce to OAuth2 Authentication Request (#4442).
I've coded the implementation & tests for creating+passing+verifying the nonce in the ID token, and all tests pass (with the exception of the one that wasn't passing in the codebase before).
I would like to open a follow-on request to push some optimizing changes out a bit further.
I'm getting everything I need within the
OidcIdTokenValidator
by retrieving the nonce via claims, but it would be cleaner to change from dealing withJwt
to dealing withOIdcIdToken
s instead. But that would necessitate reaching into & reworkingDefaultOidcIdTokenValidatorFactory
(& of course tests associated, etc.) and everything that touches. And it touches quite a lot.In short, this all works, so I believe the issue to be feature complete. But I would like to extend further changes to present a more specific solution throughout.