Claims in the Identity Token
In this guide, we will walk through these scenarios:
- Requesting a basic Identity Token
- Adding claims to the Identity Token
- Requesting different claims in the Identity Token versus the UserInfo endpoint
Prerequisites
To be successful, you will first need to understand how authentication works. Take a look at the Authentication (Command Line) Quickstart for a walkthrough of how to authenticate.
Requesting a basic identity token
These steps below are what it takes to request the most basic Identity Token possible. It will have the minimum required claims.
Send the user to the authorization URL
The authorization URL will be of the form:
Where:
- Using a
scope
value ofopenid
requests that an Identity Token be issued. - Other authorization URL parameters have been omitted for clarity.
Authentication response
Assume that the Authorization Code has been exchanged for an Access Token and an Identity Token.
The authentication server will respond with a JSON payload of the form:
The tokens are in JSON Web Token format.
Decoded identity token
After decoding the Identity Token it will look like this:
Where:
sub
is the Subject Identifier that identifies this user.at_hash
is a hash value.aud
is the audience for this Identity Token (this is the Client ID).exp
is the expiration time for this Identity Token.iat
is the time at which the Identity Token was issued.iss
is the identifier of the issuer of the Identity Token.
This is the most basic possible Identity Token.
This basic Identity Token includes a Subject Identifier, which identifies the user.
Pass this value as the User ID parameter in calls to the Consumer API (see the API Reference for details).
Adding claims to the identity token
If you want to add more claims to an Identity Token, these are the necessary steps.
If you need to cross-reference a user to other system identifiers, this is most likely what you will use. See the Authentication Framework - Mapping Data to Other Systems topic for more details.
Let’s assume that you want the Unique Customer Identifier (which is either a CIF for a bank or Member Number for a credit union). This is an example of a Restricted Claim, which the financial institution must enable for your app.
The Unique Customer Identifier claim is identified with the special claim value of https://api.banno.com/consumer/claim/customer_identifier
.
Let’s assume here that the financial institution has already enabled that Restricted Claim for our app.
Send the user to the authorization URL
The URL will be of the form:
The claims
parameter is constructed as a JSON object which then must be encoded.
Authentication response
Assume that the Authorization Code has been exchanged for an Access Token and an Identity Token.
The authentication server will respond with a JSON payload of the form:
The tokens are in JSON Web Token format.
Decoded identity token
After decoding the Identity Token it will look like this:
This has one more claim than the basic Identity Token.
- In this case, the example was from a bank, so the
https://api.banno.com/consumer/claim/customer_identifier
claim value is a CIF. - If this same example was from a credit union then the
https://api.banno.com/consumer/claim/customer_identifier
claim value would be a member number.
If you added more claims such as name
, address
, phone_number
, or email
to the claims parameter in the authorization URL as {"id_token":{"name":null,"address":null,"phone":null,"email":null,"https://api.banno.com/consumer/claim/customer_identifier":null}
, then the (decoded) Identity Token would look like this:
Requesting different claims in the identity token versus the UserInfo endpoint
Claims can be returned in these ways (as described in the RFC):
- In the Identity Token
- From the UserInfo Endpoint
- In both the Identity Token and from the UserInfo Endpoint
This provides options for handling personally identifiable information (PII).
Imagine a situation where it is undesirable for Identity Tokens to contain PII data because those tokens are being stored by your service, yet it is still desirable to retrieve PII data on-demand via the UserInfo Endpoint.
The example below is similar to the Adding Claims to the Identity Token example, but it has been modified such that claims are returned by the UserInfo Endpoint, not in the Identity Token.
Send the user to the authorization URL
The URL will be of the form:
Where:
- The
claims
parameter is constructed as a JSON object which then must be encoded. - In this case, we use
userinfo
instead ofid_token
within the JSON object.
Authentication response
Assume that the Authorization Code has been exchanged for an Access Token and an Identity Token.
The authentication server will respond with a JSON payload of the form:
The tokens are in JSON Web Token format.
Decoded identity token
After decoding the Identity Token it will look like this:
Notice that this Identity Token is the same as the Requesting a Basic Identity Token example.
Also notice that the Identity Token itself does not contain any PII.
UserInfo endpoint request using curl
If you still want to know information about the user, you can still get the information from the UserInfo endpoint.
Next steps
Take a look at specific documentation in the API Reference.
Review concepts in the Authentication Framework - Tokens documentation.
Learn about scopes and claims in the Authentication Framework - OpenID Connect and OAuth 2.0 documentation.