Encrypted ID tokens
Receive your application's ID tokens, and its JARM responses, encrypted to your own key: a JSON Web Encryption (JWE) wrapper around the signed token, the registration fields, the algorithms, which key is used, rotation, and how to decrypt and validate.
An ID token is a signed JWT. Anyone who holds it can read its claims. An application can opt in to receive its ID tokens encrypted as well: SenseCrypt signs the token exactly as before, then encrypts the whole signed token to a public key your application registered. Only the holder of the matching private key can read the claims.
Encryption helps most where the ID token passes through places you do not control:
- The browser. The implicit and hybrid flows and
response_mode=form_postdeliver the ID token in a URL fragment or an auto-posted form. - Logs and storage. ID tokens end up in logs, TLS-terminating proxies, session stores and
id_token_hintvalues. - Sensitive claims. A tenant attribute released as a claim (a national ID, for example) is otherwise protected by a signature only, which proves who issued it but hides nothing.
This follows OpenID Connect Core section 10.2 and OpenID Connect Dynamic Client Registration section 2. It is optional and off by default.
Turn it on
Set two fields on the application:
| Field | Values | Default |
|---|---|---|
id_token_encrypted_response_alg | RSA-OAEP-256 or ECDH-ES+A256KW | none (encryption off) |
id_token_encrypted_response_enc | A128CBC-HS256, A256CBC-HS512 or A256GCM | A128CBC-HS256 when the alg is set |
In the console: Applications → your app → Tokens & Security → ID tokens → ID token encryption. Over the Management API:
curl -X PATCH "https://<your-tenant>.sensecrypt.com/v1/admin/oidc-apps/$CLIENT_ID" \
-H "Authorization: Bearer $MGMT_TOKEN" \
-H "Content-Type: application/json" \
-d '{"id_token_encrypted_response_alg": "ECDH-ES+A256KW", "id_token_encrypted_response_enc": "A256GCM"}'Send only the alg, and the enc defaults to A128CBC-HS256, which the response then shows. Send "id_token_encrypted_response_alg": null to turn encryption off; the enc is cleared with it.
Before you turn it on:
- The application needs keys. SenseCrypt encrypts to a key from the application's own
jwksorjwks_uri, so encryption is available to applications that authenticate withprivate_key_jwtor mutual TLS (the methods that register keys). The key must be there when you save: registration refuses the setting otherwise (id_token_encryption.no_usable_key). For ajwks_uri, SenseCrypt fetches the URL when you save. - Not on the FAPI 2.0/CIBA profile. Section 5.4.1 of the FAPI 2.0 Security Profile names only signing algorithms, and section 5.5 keeps ID tokens in the back channel, where they need no encryption. A FAPI application receives signed ID tokens only (
fapi.forbids_id_token_encryption), and a FAPI issuer's discovery document offers no encryption.
Discovery lists what a Standard issuer offers:
{
"id_token_encryption_alg_values_supported": ["ECDH-ES+A256KW", "RSA-OAEP-256"],
"id_token_encryption_enc_values_supported": ["A128CBC-HS256", "A256CBC-HS512", "A256GCM"]
}RSA1_5 is never offered or accepted (JSON Web Token Best Current Practices, RFC 8725), and neither is dir or a key wrap with a shared secret.
Your encryption key
SenseCrypt encrypts to the first key in your key set that:
- is meant for encryption:
"use": "enc", or nouseat all (and, if it haskey_ops, one that allows encrypting to it); - names no other algorithm: no
alg, or the alg you registered; - fits the alg: an RSA key of at least 2048 bits for
RSA-OAEP-256, an EC key on P-256, P-384 or P-521 forECDH-ES+A256KW; - has not been revoked on the application.
Its kid goes in the JWE header, so give every key a kid. A key set with a signing key and an encryption key side by side:
{
"keys": [
{ "kty": "EC", "crv": "P-256", "x": "…", "y": "…", "kid": "rp-sig-1", "use": "sig", "alg": "ES256" },
{ "kty": "EC", "crv": "P-256", "x": "…", "y": "…", "kid": "rp-enc-1", "use": "enc", "alg": "ECDH-ES+A256KW" }
]
}A key marked "use": "enc", or one that names a JWE algorithm, is never used to verify your signatures: a client assertion or a signed request whose header names it is refused. Use a separate key for each job (FAPI 2.0 section 6.8 recommends the same).
What you receive
Every response that carries an ID token carries the encrypted one: the authorization code exchange, the refresh grant, the implicit and hybrid flows in every response mode (fragment and form_post), a silent prompt=none authorization, and CIBA in poll, ping and push mode.
The token is a compact JWE with five parts. Its protected header names the algorithms and your key, and cty: "JWT" says the plaintext is itself a JWT:
{ "alg": "ECDH-ES+A256KW", "enc": "A256GCM", "cty": "JWT", "kid": "rp-enc-1", "epk": { "kty": "EC", "crv": "P-256", "x": "…", "y": "…" } }The plaintext is exactly the signed ID token you would have received without encryption: same claims, same signature, same kid from the tenant's JWKS.
Only the ID token is encrypted. Access tokens and UserInfo responses stay signed only. A JARM authorization response is encrypted only if you also register JARM response encryption; an ID token inside a JARM response is the encrypted one either way.
Decrypt, then validate
- Decrypt the JWE with your private key. Accept only the alg and enc you registered.
- Validate the plaintext as an ordinary ID token: the signature against the tenant's JWKS, then
iss,aud,expandnonce. See Validate a SenseCrypt token.
With the jose library in Node.js:
import { compactDecrypt, createRemoteJWKSet, jwtVerify } from 'jose';
const jwks = createRemoteJWKSet(new URL(`${issuer}/.well-known/jwks.json`));
// 1. Decrypt with your private encryption key.
const { plaintext, protectedHeader } = await compactDecrypt(idToken, encryptionPrivateKey, {
keyManagementAlgorithms: ['ECDH-ES+A256KW'],
contentEncryptionAlgorithms: ['A256GCM'],
});
if (protectedHeader.cty !== 'JWT') throw new Error('unexpected content type');
// 2. Validate the signed ID token inside.
const { payload } = await jwtVerify(new TextDecoder().decode(plaintext), jwks, {
issuer,
audience: clientId,
algorithms: ['ES256'],
});When you send an id_token_hint back (to RP-initiated logout, /authorize or CIBA), send the inner signed token you decrypted, not the JWE. SenseCrypt does not publish an encryption key of its own, so it accepts signed hints only.
Rotate your encryption key
Add the new key before you remove the old one, and keep the old private key until the ID tokens encrypted to it have expired.
- Inline
jwks. Add the new encryption key (Applications → your app → Credentials → Add key), then stop or revoke the old one. SenseCrypt refuses to stop or revoke the last key it can encrypt to while encryption is on (409 last_encryption_key), and it refuses a rotation whose new key cannot be encrypted to, because a rotation stops every current key. See Rotating client credentials. jwks_uri. Publish the new key at your URL, then remove the old one. SenseCrypt reads the set through a cache of up to five minutes; Refresh keys now on the application makes the change take effect at once.
When no key can be used
If the application's keys hold no usable key when a token is issued (for example, the key was removed from the jwks_uri), or the jwks_uri cannot be fetched, the request fails with server_error. SenseCrypt never falls back to a plain ID token.
- At the token endpoint the answer is
500with{"error": "server_error", "error_description": "…"}. - In the browser flows,
error=server_erroris delivered to your redirect URI in the request's response mode. - CIBA push sends nothing and retries the delivery, as it does for an unreachable endpoint.
The check runs before anything is used up. The authorization code, the refresh token and the CIBA auth_req_id stay valid, so the same request succeeds once you fix your keys.
Encrypted JARM responses
A JARM response is a signed JWT that carries the authorization response (the code and state, the front-channel tokens, or the error). It can be encrypted to your key too, separately from the ID token. This follows JARM §2.2 and §3, and works exactly like ID token encryption: the same algorithms, the same rules for which key is used, and the same decryption.
Set two fields on the application, over the Management API (the console has no control for them yet):
| Field | Values | Default |
|---|---|---|
authorization_encrypted_response_alg | RSA-OAEP-256 or ECDH-ES+A256KW | none (encryption off) |
authorization_encrypted_response_enc | A128CBC-HS256, A256CBC-HS512 or A256GCM | A128CBC-HS256 when the alg is set |
curl -X PATCH "https://{tenant-host}/v1/admin/oidc-apps/{client_id}" -H "Authorization: Bearer $MGMT_TOKEN" -H "Content-Type: application/json" -d '{"authorization_encrypted_response_alg": "RSA-OAEP-256"}'The two pairs are independent: you can encrypt the JARM response, the ID token, or both, with different algorithms and keys. The registration rules are the same, under their own codes (authorization_encryption.enc_requires_alg, .requires_keys, .no_usable_key, and fapi.forbids_authorization_encryption on the FAPI 2.0/CIBA profile). Discovery lists the algorithms in authorization_encryption_alg_values_supported and authorization_encryption_enc_values_supported.
What you receive. When the request asks for a JARM response mode (query.jwt, fragment.jwt, form_post.jwt, or jwt), the single response parameter is a five-part JWE instead of the three-part signed JWT, in the same place the mode puts it. Its header carries alg, enc, cty: "JWT" and your key's kid. Every JARM response is encrypted, an error response included. Decrypt it with your private key, then validate the signed JWT inside as a JARM response: the signature against the tenant's JWKS, then iss, aud and exp. A request with a plain mode (query, fragment, form_post) gets a plain response, because there is no JWT to encrypt.
When no key can be used. If your keys hold no usable key, or your jwks_uri cannot be fetched, SenseCrypt cannot send any JARM response to your redirect URI, not even an error, because that would be a response you asked never to receive unencrypted. The user sees an error page with server_error instead, and your application receives nothing. The check runs before anything is used up: the sign-in, the pushed request_uri and the user's browser session are left as they were, so the same sign-in finishes once you fix your keys.
Signed requests and responses
JAR request objects at the PAR endpoint (RFC 9101) and JARM signed authorization responses — the signing rules, the claims that are required, where each is accepted, and how to validate the response JWT.
Console sign-in methods
A console account signs in with a password or with sign-in providers such as Google, never with both. This page explains what sets the method, what each screen shows, why a provider account gets no password-reset email, and how to get help.