Encrypting OpenID Connect ID Tokens
AM supports encrypting OpenID Connect ID tokens to protect them against tampering attacks, which is outlined in the JSON Web Encryption specification (RFC 7516).
Perform the following steps to enable and configure ID token encryption:
Go to Realms > Realm Name > Applications > OAuth 2.0 > Client Name.
On the Signing and Encryption tab, select Enable ID Token Encryption.
In the Id Token Encryption Algorithm field, enter the algorithm AM will use to encrypt ID tokens.
A128KW
- AES Key Wrapping with 128-bit key derived from the client secret.A192KW
- AES Key Wrapping with 192-bit key derived from the client secret.A256KW
- AES Key Wrapping with 256-bit key derived from the client secret.RSA-OAEP
- RSA with Optimal Asymmetric Encryption Padding (OAEP) with SHA-1 and MGF-1.RSA-OAEP-256
- RSA with OAEP with SHA-256 and MGF-1.RSA1_5
- RSA with PKCS#1 v1.5 padding (not recommended).dir
- Direct encryption with AES using the hashed client secret.ECDH-ES
- Elliptic Curve Diffie-HellmanECDH-ES+A128KW
- Elliptic Curve Diffie-Hellman + AES Key Wrapping with 128-bit key.ECDH-ES+A192KW
- Elliptic Curve Diffie-Hellman + AES Key Wrapping with 192-bit key.ECDH-ES+A256KW
- Elliptic Curve Diffie-Hellman + AES Key Wrapping with 256-bit key.X25519
- Elliptic Curve Diffie-Hellman with Curve25519.X448
- Elliptic Curve Diffie-Hellman with Curve448.
Only the
P-256
,P-384
, andP-521
curves are supported.In the ID Token Encryption Method field, enter the method AM will use to encrypt ID tokens.
A128CBC-HS256
- AES 128-bit in CBC mode using HMAC-SHA-256-128 hash (HS256 truncated to 128 bits)A192CBC-HS384
- AES 192-bit in CBC mode using HMAC-SHA-384-192 hash (HS384 truncated to 192 bits)A256CBC-HS512
- AES 256-bit in CBC mode using HMAC-SHA-512-256 hash (HS512 truncated to 256 bits)A128GCM
- AES 128-bit in GCM modeA192GCM
- AES 192-bit in GCM modeA256GCM
- AES 256-bit in GCM mode
(Optional) If you selected an RSA encryption algorithm, perform one of the following actions:
Enter the public key in the Client ID Token Public Encryption Key field.
Enter a JWK set in the Json Web Key field.
Enter a URI containing the public key in the Json Web Key URI field.
(Optional) If you selected an ECDH-ES encryption algorithm, perform one of the following actions:
Enter a JWK set in the Json Web Key field.
Enter a URI containing the public key in the Json Web Key URI field.
(Optional) If you selected an algorithm different from RSA or ECDH-ES, go to the Core tab and store the private key/secret in the Client Secret field.
Caution
Several features of OAuth 2.0 use the string stored in the Client Secret field to sign/encrypt tokens or parameters when you configure specific algorithms. For example, signing ID tokens with HMAC algorithms, encrypting ID tokens with AES or direct algorithms, or encrypting OpenID Connect parameters with AES or direct algorithms.
In this case, these features must share the key/secret stored in the Client Secret field, and you must ensure that they are configured with the same algorithm.