@@ -546,7 +546,8 @@ If you haven't installed it yet, run this command:
546
546
$ composer require web-token/jwt-library
547
547
548
548
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):
550
551
551
552
.. configuration-block ::
552
553
@@ -567,7 +568,11 @@ it and retrieve the user info from it:
567
568
audience : ' api-example'
568
569
# Issuers (`iss` claim): required for validation purpose
569
570
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
571
576
.. code-block :: xml
572
577
573
578
<!-- config/packages/security.xml -->
@@ -592,6 +597,10 @@ it and retrieve the user info from it:
592
597
<algorithm >ES256</algorithm >
593
598
<algorithm >RS256</algorithm >
594
599
<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 >
595
604
</oidc >
596
605
</token-handler >
597
606
</access-token >
@@ -611,12 +620,20 @@ it and retrieve the user info from it:
611
620
->oidc()
612
621
// Algorithm used to sign the JWS
613
622
->algorithms(['ES256', 'RS256'])
614
- // A JSON-encoded JWK
623
+ // A JSON-encoded JWKSet (public keys)
615
624
->keyset('{"keys":[{"kty":"...","k":"..."}]}')
616
625
// Audience (`aud` claim): required for validation purpose
617
626
->audience('api-example')
618
627
// Issuers (`iss` claim): required for validation purpose
619
628
->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
+
620
637
;
621
638
};
622
639
@@ -625,6 +642,10 @@ it and retrieve the user info from it:
625
642
The support of multiple algorithms to sign the JWS was introduced in Symfony 7.1.
626
643
In previous versions, only the ``ES256 `` algorithm was supported.
627
644
645
+ .. versionadded :: 7.3
646
+
647
+ The support of the encryption algorithms to decrypt the JWE was introduced in Symfony 7.3.
648
+
628
649
Following the `OpenID Connect Specification `_, the ``sub `` claim is used by
629
650
default as user identifier. To use another claim, specify it on the
630
651
configuration:
0 commit comments