-
Notifications
You must be signed in to change notification settings - Fork 149
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
Support multiple response_type values #38
Conversation
cef8bfd
to
780349d
Compare
780349d
to
d008135
Compare
this.state = UUID.randomUUID().toString(); | ||
this.scope = null; | ||
withResponseType(ResponseType.CODE); | ||
withState(UUID.randomUUID().toString()); |
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.
Use SecureRandom
} | ||
|
||
/** | ||
* Use a custom nonce in the requests |
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.
Specify a custom nonce value to avoid replay attacks. It will be sent in the auth request that will be returned back as a claim in the id_token
*/ | ||
public Builder withResponseType(@ResponseType int type) { | ||
StringBuilder sb = new StringBuilder(); | ||
if ((type & ResponseType.CODE) != 0) { |
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.
I think it should be (type & ResponseType.CODE) == ResponseType.CODE
try { | ||
final JWT idToken = new JWT(token); | ||
final Claim nonceClaim = idToken.getClaim(KEY_NONCE); | ||
return !(nonceClaim == null || !nonce.equals(nonceClaim.asString())); |
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.
Can we avoid the double negation?
queryParameters.put(KEY_RESPONSE_TYPE, RESPONSE_TYPE_TOKEN); | ||
|
||
if (!getResponseType().contains(RESPONSE_TYPE_ID_TOKEN)) { | ||
queryParameters.remove(KEY_NONCE); |
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.
We should only do this if we generated the nonce, if the user provided one we should still send it
1997f3a
to
ad79347
Compare
ad79347
to
c1bec1a
Compare
WebAuthProvider
can now handle multiple response_type values as per https://openid.net/specs/oauth-v2-multiple-response-types-1_0.html#Combinations.Posible values are:
ResponseType.CODE
ResponseType.ID_TOKEN
ResponseType.TOKEN
i.e.: