For Authlete 2.x documentation, see 2.x version.
Preface
This article explains how to register a JWK set for an Authlete service. First, refer to the steps below in order to prepare a JWK set.This article assumes that you have prepared a JWK set in some way. The following example illustrates usage of mkjwk.org service to generate an ES256 key pair, and parameters specified for it.
- Key Type: EC (Elliptic Curve)
- Curve: P-256
- Key Use: Signing
- Algorithm: ES256
- Key ID: 1
Generating a JWK Set using mkjwk
Registering the JWK set via the Authlete Console
To register the JWK set you prepared, go to your service settings, insideKey Management > JWK Set. There, you will be able to copy the generated “Public and Private Keypair Set” into the JWK Set Content field of the settings. Make sure to save your changes by hitting the Save Changes button at the bottom of the page.
JWK Set Content
Now the JWK set has been registered in the service.
In addition, by adding the authorization server’s endpoint as the JWK set endpoint URI, the jwks_uri value is reflected in the authorization server’s metadata document.
Registering the JWK set via Authlete API
You can also use Authlete’s service management APIs to register the JWK set instead of using the Web console. The following example illustrates how to make a request to the PUT /service/update API to specify the JWK set as a value of “jwks” key. Updating service settings requires an organization access token.1. Get configuration data about the target service
Use the GET /service/get API to retrieve the configuration data of the service.2. Add a new JWK set to the data
Add the following key/value as a JWK set to the JSON formatted configuration data retrieved above and save as updated-service.json."kid":"2019-07-25_02" to be used for signing ID tokens, you should add the following key/value:
idTokenSignatureKeyId)
3. Update the service with the new configuration data
Use PUT /service/update API to put the new configuration data that includes the JWK set.Key Rotation
To perform key rotation without downtime, it is common to update keys using the following procedure.- Add a new signing key to
jwks_uri(resulting in a state where multiple keys are included) - Wait until the
jwks_uricache on clients and RPs is invalidated and multiple keys are recognized - Switch the signing key to the new key
- Remove the old signing key
jwks), and step 3 corresponds to updating settings such as the service’s ID token signature key ID (idTokenSignatureKeyId).