Skip to content

Commit 8f5c4c1

Browse files
committed
Add support for encrypted access tokens (JWE) in OIDC
This update introduces support for decrypting encrypted access tokens (JWE) in Symfony 7.3. It includes configuration options for enabling encryption, enforcing it, specifying decryption algorithms, and providing decryption keysets. The feature extends flexibility in handling secure tokens alongside existing signing mechanisms.
1 parent 0b180d5 commit 8f5c4c1

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

security/access_token.rst

+24-3
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,8 @@ If you haven't installed it yet, run this command:
546546
$ composer require web-token/jwt-library
547547
548548
Symfony provides a generic ``OidcTokenHandler`` to decode your token, validate
549-
it and retrieve the user info from it:
549+
it and retrieve the user info from it.
550+
Optionally, the token may be encrypted (JWE):
550551

551552
.. configuration-block::
552553

@@ -567,7 +568,11 @@ it and retrieve the user info from it:
567568
audience: 'api-example'
568569
# Issuers (`iss` claim): required for validation purpose
569570
issuers: ['https://oidc.example.com']
570-
571+
encryption:
572+
enabled: true # Default to false
573+
enforce: false # Default to false, requires an encrypted token when true
574+
algorithms: ['ECDH-ES', 'A128GCM']
575+
keyset: '{"keys": [...]}' # Encryption private keyset
571576
.. code-block:: xml
572577
573578
<!-- config/packages/security.xml -->
@@ -592,6 +597,10 @@ it and retrieve the user info from it:
592597
<algorithm>ES256</algorithm>
593598
<algorithm>RS256</algorithm>
594599
<issuer>https://oidc.example.com</issuer>
600+
<encryption enabled="true" enforce="true" keyset="{'keys': [...]}">
601+
<algorithm>ECDH-ES</algorithm>
602+
<algorithm>A128GCM</algorithm>
603+
</encryption>
595604
</oidc>
596605
</token-handler>
597606
</access-token>
@@ -611,12 +620,20 @@ it and retrieve the user info from it:
611620
->oidc()
612621
// Algorithm used to sign the JWS
613622
->algorithms(['ES256', 'RS256'])
614-
// A JSON-encoded JWK
623+
// A JSON-encoded JWKSet (public keys)
615624
->keyset('{"keys":[{"kty":"...","k":"..."}]}')
616625
// Audience (`aud` claim): required for validation purpose
617626
->audience('api-example')
618627
// Issuers (`iss` claim): required for validation purpose
619628
->issuers(['https://oidc.example.com'])
629+
->encryption()
630+
->enabled(true) //Default to false
631+
->enforce(false) //Default to false, requires an encrypted token when true
632+
// Algorithm used to decrypt the JWE
633+
->algorithms(['ECDH-ES', 'A128GCM'])
634+
// A JSON-encoded JWKSet (private keys)
635+
->keyset('{"keys":[...]}')
636+
620637
;
621638
};
622639
@@ -625,6 +642,10 @@ it and retrieve the user info from it:
625642
The support of multiple algorithms to sign the JWS was introduced in Symfony 7.1.
626643
In previous versions, only the ``ES256`` algorithm was supported.
627644

645+
.. versionadded:: 7.3
646+
647+
The support of the encryption algorithms to decrypt the JWE was introduced in Symfony 7.3.
648+
628649
Following the `OpenID Connect Specification`_, the ``sub`` claim is used by
629650
default as user identifier. To use another claim, specify it on the
630651
configuration:

0 commit comments

Comments
 (0)