You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Decrypt JWE-encrypted access tokens before writing them to the session, at
both the callback and on token refresh, so req.oidc.accessToken and
afterCallback always receive a plaintext JWT. Enabled by setting
accessTokenDecryptionKey. The key-management algorithm is read from the JWE
header and validated against a strong-algorithm allowlist; accessTokenDecryptionAlg
can pin it. Decryption failures surface a clear error.
The request object's `aud` is set to the issuer identifier advertised in the discovery document (which may differ from `issuerBaseURL`, e.g. a trailing slash), as JAR requires. `requestObjectSigningKey` accepts the same key formats as `clientAssertionSigningKey` (PEM string, Buffer, KeyObject, JWK, CryptoKey).
568
569
569
570
Full example at [jar.js](./examples/jar.js), to run it: `npm run start:example -- jar`
571
+
572
+
## 16. Decrypt JWE-encrypted access tokens
573
+
574
+
When an Auth0 API is configured with [Token Encryption](https://auth0.com/docs/secure/tokens/access-tokens/json-web-encryption), the access token returned at the callback is a JWE. Set `accessTokenDecryptionKey` and the SDK decrypts it before writing it to the session, at both the callback and on token refresh, so `req.oidc.accessToken` and `afterCallback` always receive a plaintext JWT. No change is needed in consuming code.
575
+
576
+
```js
577
+
app.use(
578
+
auth({
579
+
authorizationParams: {
580
+
response_type:'code', // requires a client secret; JWE requires a code flow
581
+
audience:'https://your-api/',
582
+
scope:'openid profile email offline_access',
583
+
},
584
+
// Private key matching the public key uploaded to the API's Token Encryption
585
+
// settings. Accepts PEM string, Buffer, KeyObject, JWK, or CryptoKey.
// Optional pin. Omit to auto-detect the algorithm from the JWE header.
588
+
// accessTokenDecryptionAlg: 'RSA-OAEP-512',
589
+
}),
590
+
);
591
+
```
592
+
593
+
The key-management algorithm is read from the JWE protected header (validated against a strong-algorithm allowlist), so decryption works whether the tenant uses `RSA-OAEP-256`, `RSA-OAEP-512`, and so on. Set `accessTokenDecryptionAlg` only if you want to pin one. Decryption requires a code flow, since implicit flow does not return access tokens from the token endpoint.
0 commit comments