Skip to content

Commit 972fa1f

Browse files
authored
fix!(oauth): use either token or id_token for nonce (#1532)
While I think this should only fix problems, and any working solution will be working around this problem, there's still some risk that setting nonce will break an implementation. Please carefully test this commit and make sure logging in still works for all strategies.
1 parent e596c11 commit 972fa1f

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/schemes/oauth2.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,12 @@ export class Oauth2Scheme<
259259
// Set Nonce Value if response_type contains id_token to mitigate Replay Attacks
260260
// More Info: https://openid.net/specs/openid-connect-core-1_0.html#NonceNotes
261261
// More Info: https://tools.ietf.org/html/draft-ietf-oauth-v2-threatmodel-06#section-4.6.2
262-
if (opts.response_type.includes('token')) {
262+
// Keycloak uses nonce for token as well, so support that too
263+
// https://github.com/nuxt-community/auth-module/pull/709
264+
if (
265+
opts.response_type.includes('token') ||
266+
opts.response_type.includes('id_token')
267+
) {
263268
opts.nonce = _opts.nonce || randomString(10)
264269
}
265270

0 commit comments

Comments
 (0)