This article explains the constraints of the sub (subject) claim within Identity (ID) and Access Tokens. It outlines standard system behavior and provides a practical workaround for requirements that necessitate a custom username.
- Sub claim
- ID token
- Access token
- Custom Authorization Server
- Group-based Application Assignment
The sub claim in an ID Token is a reserved system claim that defaults to the Okta User Identification (ID) and cannot be modified. While the sub claim in an Access Token can be modified using a Custom Authorization Server (CAS), creating a new custom claim in both tokens is the recommended approach to ensure consistency.
Follow these steps to create a custom claim:
- Go to Security > API > Authorization Servers.
- Select the appropriate Custom Authorization Server.
- Navigate to the Claims tab and click Add Claim.
- Create a claim (for example,
test_username) for the ID Token:- Include in token type:
ID Token. - Value type:
Expression. - Value:
user.login.
- Include in token type:
- Create the same claim for the Access Token:
- Include in token type:
Access Token. - Value:
user.login.
- Include in token type:
- Update the external application configuration to utilize this new claim instead of
suboruid.
