`scope` claim in JWT
looks like scope claim is modeled differently in Zitadel compared to Okta/KeyCloak. any reason and also is it complaint to Oauth2 spec? here are some example for dfferent Auth servers
ZITADEL Implementation
Scope Format:
JWT Structure:
Keycloak Implementation
Scope Format:
JWT Structure:
Okta Implementation
Scope Format:
JWT Structure:
3 Replies
Hi @kappapilla, I'm an AI assistant for ZITADEL. While a team member reviews this question, I'll see if I can find relevant sources for your question.
Answer
The
scope claim behavior in ZITADEL JWT access tokens has been a known issue. According to RFC 8693, the scope claim should be returned in JWT access tokens (1) . However, there's a documented difference between how ZITADEL handles opaque versus JWT access tokens (2) .
For opaque access tokens, the scope claim is included when you introspect the token . For JWT access tokens, the scope claim has historically not been included in the token itself .
This appears to be a gap rather than intentional design. Access tokens configured as JWT (not opaque) should include the scope claim (1) . The Token Exchange grant in ZITADEL does return a scope field in the response, which contains the final scope of the obtained token (3) .
Regarding OAuth2/OIDC compliance: ZITADEL's URN-based scope format (like urn:zitadel:iam:org:project:id:344374183645413380:aud) is used for audience control and role assertions, which is an extension beyond standard OAuth2 scopes but doesn't violate the spec (4) . Standard scopes like openid, profile, and email work as expected .
If you need the scope claim in your JWT access tokens, you could:
1. Use opaque tokens and call the introspection endpoint (2)
2. Request both access and ID tokens with the openid scope (3)
3. Consider using Actions to add the scope claim to JWT tokens
Would you like help with implementing any of these approac
hes?
To learn more, see the sources I considered:
[1] According to RFC 8693 "scope" is supposed to be returned in JWT Access token
[2] Discord message from @zgrdaniel on 2024-06-11
[3] Impersonation and delegation using Token Exchange
[4] OpenID Connect Endpoints in ZITADEL
Feel free to tag @Ask Inkeep with additional questions.this is for service user and wondering if simple strings x.write available for service user scope claim.. @Ask Inkeep
Got it. Tagging @Rajat for additional help.