You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Keycloak does not include a nonce in the ID token when refreshing tokens. Because of this, OAuth2-Proxy throws an error for nonce mismatch when insecureSkipNonce is set to false
Steps To Reproduce
Set up OAuth2-Proxy with Keycloak as the identity provider.
Configure the proxy with insecureSkipNonce: false.
Attempt to refresh the token using the refresh token flow.
Observe the nonce mismatch error.
Possible Solutions
No response
Configuration details or additional information
For now, I've added a mapper in Keycloak called Nonce backwards compatible. This temporarily adds a nonce to the ID token after refreshing, which allows OAuth2-Proxy to refresh tokens successfully.
The text was updated successfully, but these errors were encountered:
This bug is not specific to Keycloak but it is a general issue. According to the OIDC specification, the ID token in a refresh response SHOULD NOT contain a nonce, see https://openid.net/specs/openid-connect-core-1_0.html#RefreshTokenResponse.
We observe the same problem with Forgerock as the IdP.
So the issue specifically here is that we are using the same nonce checking on the initial token, and refreshed tokens, and I'm guessing some providers do provide a nonce, and some do not?
If you set insecureSkipNonce this fixes the issue, but also means that the nonce is not being checked for the initial ID token either?
I guess we probably want to skip the check on refresh tokens, per the spec link you added.
insecureSkipNonce = true: Do not validate the nonce, neither in the initial ID token, nor in refreshed ones.
insecureSkipNonce = false: Validate the nonce in the initial ID token. Validate the nonce in a refreshed ID token only if the nonce claim is present in the refreshed ID token (if present, the nonce of refreshed ID tokens MUST be the same as the one in the initial ID token).
OAuth2-Proxy Version
v7.7.1
Provider
keycloak-oidc
Expected Behaviour
When using the refresh token flow, OAuth2-Proxy should be able to refresh the access token without encountering a nonce mismatch.
https://www.keycloak.org/docs/latest/upgrading/#nonce-claim-is-only-added-to-the-id-token
Current Behaviour
Keycloak does not include a nonce in the ID token when refreshing tokens. Because of this, OAuth2-Proxy throws an error for nonce mismatch when
insecureSkipNonce
is set tofalse
Steps To Reproduce
Possible Solutions
No response
Configuration details or additional information
For now, I've added a mapper in Keycloak called Nonce backwards compatible. This temporarily adds a nonce to the ID token after refreshing, which allows OAuth2-Proxy to refresh tokens successfully.
The text was updated successfully, but these errors were encountered: