Describe the bug
In oidc/core/grants/code.py, there is the OpenIDToken.get_authorization_code_claims method:
def get_authorization_code_claims(self, authorization_code: AuthorizationCodeMixin):
claims = {
"nonce": authorization_code.get_nonce(),
"auth_time": authorization_code.get_auth_time(),
}
[ ... ]
return claims
it returns the nonce as claims, regardless if it's None or a string.
According to https://openid.net/specs/openid-connect-core-1_0.html#JSONSerialization, parameters with no values should be omitted from the response.
For me, it leads to an error from the oauth4webapi client library, see panva/oauth4webapi#184 (comment). To be fair, it's not a problem for all other apps and libraries I have used.
Expected behavior
The nonce should only be added if it's not None. At least this leads to the oauth4webapi (and Immich using it) being able to successfully do OIDC against my patched authlib OIDC server.
def get_authorization_code_claims(self, authorization_code: AuthorizationCodeMixin):
claims = {
"auth_time": authorization_code.get_auth_time(),
}
if nonce := authorization_code.get_nonce():
claims["nonce"] = nonce
if acr := authorization_code.get_acr():
claims["acr"] = acr
if amr := authorization_code.get_amr():
claims["amr"] = amr
return claims
If you agree, I can do a PR.
Environment:
Describe the bug
In oidc/core/grants/code.py, there is the OpenIDToken.get_authorization_code_claims method:
it returns the nonce as claims, regardless if it's None or a string.
According to https://openid.net/specs/openid-connect-core-1_0.html#JSONSerialization, parameters with no values should be omitted from the response.
For me, it leads to an error from the oauth4webapi client library, see panva/oauth4webapi#184 (comment). To be fair, it's not a problem for all other apps and libraries I have used.
Expected behavior
The nonce should only be added if it's not None. At least this leads to the oauth4webapi (and Immich using it) being able to successfully do OIDC against my patched authlib OIDC server.
If you agree, I can do a PR.
Environment: