ID Tokens
The ID Token is conceptually the same as an identity card, with information about a user packaged as a JWT token. ID Tokens can be returned as a result when an application makes an OpenId Connect (OIDC) authentication request to the Identity Provider. The statements (called claims) of an ID Token are packaged in a simple JSON object (this is the Body of the JWT token).
{
"iss": "https://instance.irmciam.se",
"sub": "f404a4ff-6037-4097-afa7-24b397239009",
"tid": "d10a1624-6de7-4b50-b662-0f1cc6733edf",
"aud": "APPLICATION CLIENT ID",
"nonce": "VALUE",
"exp": 1311281970,
"iat": 1311280970,
"auth_time": 1311280969,
"amr": "pwd"
}
An ID Token has these features:
- Asserts the identity of the user, called subject in OIDC and represented with a
sub
claim. - Asserts the identity of the tenant, represented with a
tid
claim. This is not standardized or required in the protocol, but a claim that Authway always issues. - Specifies the issuing authority, represented with a
iss
claim. - Is generated for a specific application, called client in OIDC and represented with a
aud
claim. - Has an issue (
iat
claim) and expiration time (exp
claim). - May contain other protocol claims like
- A
nonce
that associates a client session with the token, which is used to mitigate replay attacks. - One or more authentication method reference (
amr
claim) that represents how the user was authenticated. There are standardized values that Authway uses if it exists.
- A
- May contain other claims about the user, like
name
andemail
, depending on what scopes was requested.
The ID token header, claims JSON and signature are encoded into a base 64 URL-safe string, so it can easily be passed around.
Considerations to make for ID Tokens
What claims end up in the ID Token is controlled by passing Scopes to the Authorization endpoint. The openid
scope is required when requesting an ID Token, but other can be requested to retrieve more information about the user. In Authway the openid
scope contains the sub
and tid
claims.
When requesting many scopes the returned ID Token will contain many claims, which can result in a large ID Token. The size of the token can effect how good it is to keep in a cookie or other state for the client application. It is good to keep the token as small as possible. It is possible to request more information about the user from the UserInfo endpoint instead. The downside of that alternative is that it results in more network requests which can affect the latency of the application during sign-in.