Skip to content
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

JWT nonce claim is required, even though the spec says it's optional and some OpenID Connect providers do not provide it #163

Open
consolibyte opened this issue May 23, 2019 · 2 comments

Comments

@consolibyte
Copy link

The implementation here assumes that nonce is always present in the claim:
https://github.com/jumbojett/OpenID-Connect-PHP/blob/master/src/OpenIDConnectClient.php#L922

return (($claims->iss == $this->getIssuer() || $claims->iss == $this->getWellKnownIssuer() || $claims->iss == $this->getWellKnownIssuer(true))
            && (($claims->aud == $this->clientID) || in_array($this->clientID, $claims->aud))
            && ($claims->nonce == $this->getNonce())
            && ( !isset($claims->exp) || $claims->exp >= time() - $this->leeway)
            && ( !isset($claims->nbf) || $claims->nbf <= time() + $this->leeway)
            && ( !isset($claims->at_hash) || $claims->at_hash == $expecte_at_hash )
        );

However, some providers do not return a nonce here. For example, Intuit's implementation does not: https://developer.intuit.com/app/developer/qbo/docs/develop/authentication-and-authorization/openid-connect

According to the spec, it seems optional (note the "if a nonce value was sent..."):

If a nonce value was sent in the Authentication Request, a nonce Claim MUST be present and its value checked to verify that it is the same value as the one that was sent in the Authentication Request. The Client SHOULD check the nonce value for replay attacks. The precise method for detecting replay attacks is Client specific. 

From: https://openid.net/specs/openid-connect-core-1_0.html#IDTokenValidation

@nliwo
Copy link

nliwo commented Jan 9, 2020

I'm facing the same problem.

@JuliusPC
Copy link
Contributor

JuliusPC commented May 2, 2021

These providers are simply not OIDC compliant, as already cited above:

If a nonce value was sent in the Authentication Request, a nonce Claim MUST be present and its value checked to verify that it is the same value as the one that was sent in the Authentication Request.

This library always sends the nonce, so it is required to expect it in the response.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants