For Authlete 2.x documentation, see 2.x version.
Preface
Authlete has a feature that can issue JWT-formatted access tokens. This article describes how to enable the feature, and how to specify additional claims to an access token.This feature is available in Authlete 2.1 and later.
Enabling The Feature
Register a JWK set document to “JWK Set Content” section in Service Settings. See the following article for instructions. After the registration, choose an appropriate “Access Token Signature Algorithm” in the same “Token” tab. For example, you would choose “ES256” if you have registered an ES256 signing key (shown in the article above).
Access Token Signature Algorithm
After the change, access tokens to be issued by Authlete are JWT-formatted.
Embedding additional properties into access tokens
You can embed arbitrary key-value pairs into access tokens in either of the following ways:- Adding string values using “Extra Properties”
- Adding arbitrary claims using jwtAtClaims parameter
The jwtAtClaims parameter is available in Authlete 2.3 or later.
1. Add String Values Using “Extra Properties”
The “Extra Properties ” feature allows an authorization server to associate arbitrary properties with either an access token or an authorization code. By using this feature for the JWT-formatted access tokens, visible (= not-hidden) extra properties are included in the access tokens as custom claims so that resource servers can extract them.Example
The following is an execution example of /auth/token API of the Authlete service configured to issue JWT-formatted access tokens. This example also shows output when using extra properties. You will see a JWS signed JWT as a value of “access_token” in “responseContent” (content of token response). The same value is also provided as “jwtAccessToken”. (folded for readability)- Request
- Response
- Header
- Payload
2. Add Arbitrary Claims Using jwtAtClaims Parameter
The jwtAtClaims request parameter allows you to add JSON objects as claims to a JWT access token. This parameter is available when making a request to the following Authlete APIs.
- POST /auth/authorization/issue
- POST /auth/token
- POST /auth/token/issue
- POST /auth/token/create
- POST /backchannel/authentication/complete
- POST /device/complete
jwtAtClaims is a JSON object. The properties in the JSON object specified in jwtAtClaims will be added to the JWT access token payload.
Example
Below is an example using jwtAtClaims as one of the parameters of the request to the POST /auth/authorization/issue API.Relationship Between JWT-Based Access Tokens and Identifier-Type Access Tokens
When the Authlete token issuance endpoint successfully issues an access token, in addition to theresponseContent that is returned to the authorization server, the following properties are also included in the response:
accessTokenjwtAccessToken(if configured to issue a JWT-based token, this is identical to theaccess_tokenin theresponseContent)
responseContent and return both tokens, or it could decide per client whether to return accessToken or jwtAccessToken.
Additionally, the jti claim contained in a JWT-based access token matches the value of Authlete’s identifier access token.
Revocation Check for JWT-Based Access Tokens
A major advantage of JWT-based access tokens is that they do not require contacting the authorization server for revocation checking. However, in certain special scenarios, you may want to perform revocation and revocation checks even for JWT-based access tokens. For instance, you might prioritize performance by validating JWT-based tokens locally in general, but perform an additional revocation check with the authorization server for critical operations. To implement revocation for JWT-based tokens issued by Authlete, it’s necessary to understand how Authlete handles them.How to Revoke a JWT-Based Access Token
Authlete’s revocation endpoint (/auth/revocation) does not directly support JWT-type access tokens, so submitting a JWT token itself to the endpoint will not revoke it. If you want to revoke a JWT-based access token (i.e., mark it as revoked in Authlete’s internal database), you must send the identifier token contained in the JWT’s jti claim to the revocation endpoint.
/auth/introspection) accepts JWT access tokens and verifies the database record based on the jti.
Therefore, if a JWT access token has been revoked using its jti claim, /auth/introspection will correctly reflect its revoked status.
On the other hand, /auth/introspection/standard only validates the JWT’s signature and expiration time and does not check the database record.
As a result, it does not perform revocation verification based on the jti claim.