@@ -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,6 +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']
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
570576
571577 .. code-block :: xml
572578
@@ -592,6 +598,10 @@ it and retrieve the user info from it:
592598 <algorithm >ES256</algorithm >
593599 <algorithm >RS256</algorithm >
594600 <issuer >https://oidc.example.com</issuer >
601+ <encryption enabled =" true" enforce =" true" keyset =" {'keys': [...]}" >
602+ <algorithm >ECDH-ES</algorithm >
603+ <algorithm >A128GCM</algorithm >
604+ </encryption >
595605 </oidc >
596606 </token-handler >
597607 </access-token >
@@ -611,12 +621,20 @@ it and retrieve the user info from it:
611621 ->oidc()
612622 // Algorithm used to sign the JWS
613623 ->algorithms(['ES256', 'RS256'])
614- // A JSON-encoded JWK
624+ // A JSON-encoded JWKSet (public keys)
615625 ->keyset('{"keys":[{"kty":"...","k":"..."}]}')
616626 // Audience (`aud` claim): required for validation purpose
617627 ->audience('api-example')
618628 // Issuers (`iss` claim): required for validation purpose
619629 ->issuers(['https://oidc.example.com'])
630+ ->encryption()
631+ ->enabled(true) //Default to false
632+ ->enforce(false) //Default to false, requires an encrypted token when true
633+ // Algorithm used to decrypt the JWE
634+ ->algorithms(['ECDH-ES', 'A128GCM'])
635+ // A JSON-encoded JWKSet (private keys)
636+ ->keyset('{"keys":[...]}')
637+
620638 ;
621639 };
622640
@@ -625,6 +643,10 @@ it and retrieve the user info from it:
625643 The support of multiple algorithms to sign the JWS was introduced in Symfony 7.1.
626644 In previous versions, only the ``ES256 `` algorithm was supported.
627645
646+ .. versionadded :: 7.3
647+
648+ The support of the encryption algorithms to decrypt the JWE was introduced in Symfony 7.3.
649+
628650Following the `OpenID Connect Specification `_, the ``sub `` claim is used by
629651default as user identifier. To use another claim, specify it on the
630652configuration:
0 commit comments