In the OpenID Connect spec the azp (authorized party) claim seems to have a contradiction.
In the ID token definition section 2 it says:
azp
OPTIONAL. Authorized party - the party to which the ID Token was issued. If present, it MUST contain the OAuth 2.0 Client ID of this party. This Claim is only needed when the ID Token has a single audience value and that audience is different than the authorized party. It MAY be included even when the authorized party is the same as the sole audience...
But in token validation section 3.1.3.7, one of the steps seems to say the opposite:
- If the ID Token contains multiple audiences, the Client SHOULD verify that an azp Claim is present.
Could anyone shed some light on this apparent discrepancy? Only the second instance uses declaratory language, so I'm leaning towards favoring that in my implementation.
You're correct, the whole
azp
situation in OIDC is confusing. For what's it's worth, they have an open issue associated with it; see OIDC - Issue 973 (azp claim underspecified and overreaching).Personally, from the client application developer perspective, the best course of action seems to be honoring the ID Token validation rules which always imply that the value within
azp
will also be present as anaud
. However, according to what's available online Google seemed to use it a bit differently so you could have a value inazp
not listed withinaud
, so there may be situations where you play by Google rules and not (just) OIDC.If you're implementing an OP a probably good option is also to entirely stay away from including
azp
in your issued tokens if possible or only include it when using multiple audiences with one of them being the value also in theazp
.