Skip to content

Commit f795185

Browse files
committed
Update OidcTokenHandler dependencies and configuration
This commit replaces the individual jwt packages previously needed by 'OidcTokenHandler' with the `web-token/jwt-library`. Configuration changes have been made to support multiple signing algorithms and a keyset instead of a single key. These changes provide more flexibility and reliability for token handling and verification.
1 parent 5327456 commit f795185

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

security/access_token.rst

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -537,15 +537,12 @@ claims. To create your own user object from the claims, you must
537537
2) Configure the OidcTokenHandler
538538
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
539539

540-
The ``OidcTokenHandler`` requires ``web-token/jwt-signature``,
541-
``web-token/jwt-checker`` and ``web-token/jwt-signature-algorithm-ecdsa``
542-
packages. If you haven't installed them yet, run these commands:
540+
The ``OidcTokenHandler`` requires the package ``web-token/jwt-library``.
541+
If you haven't installed it yet, run this command:
543542

544543
.. code-block:: terminal
545544
546-
$ composer require web-token/jwt-signature
547-
$ composer require web-token/jwt-checker
548-
$ composer require web-token/jwt-signature-algorithm-ecdsa
545+
$ composer require web-token/jwt-library
549546
550547
Symfony provides a generic ``OidcTokenHandler`` to decode your token, validate
551548
it and retrieve the user info from it:
@@ -561,10 +558,10 @@ it and retrieve the user info from it:
561558
access_token:
562559
token_handler:
563560
oidc:
564-
# Algorithm used to sign the JWS
565-
algorithm: 'ES256'
561+
# Algorithms used to sign the JWS
562+
algorithms: ['ES256', 'RS256']
566563
# A JSON-encoded JWK
567-
key: '{"kty":"...","k":"..."}'
564+
keyset: '{"keys":[{"kty":"...","k":"..."}]}'
568565
# Audience (`aud` claim): required for validation purpose
569566
audience: 'api-example'
570567
# Issuers (`iss` claim): required for validation purpose
@@ -589,8 +586,10 @@ it and retrieve the user info from it:
589586
<!-- Algorithm used to sign the JWS -->
590587
<!-- A JSON-encoded JWK -->
591588
<!-- Audience (`aud` claim): required for validation purpose -->
592-
<oidc algorithm="ES256" key="{'kty':'...','k':'...'}" audience="api-example">
589+
<oidc keyset="{'keys':[{'kty':'...','k':'...'}]}" audience="api-example">
593590
<!-- Issuers (`iss` claim): required for validation purpose -->
591+
<algorithm>ES256</algorithm>
592+
<algorithm>RS256</algorithm>
594593
<issuer>https://oidc.example.com</issuer>
595594
</oidc>
596595
</token-handler>
@@ -610,9 +609,9 @@ it and retrieve the user info from it:
610609
->tokenHandler()
611610
->oidc()
612611
// Algorithm used to sign the JWS
613-
->algorithm('ES256')
612+
->algorithms(['ES256', 'RS256'])
614613
// A JSON-encoded JWK
615-
->key('{"kty":"...","k":"..."}')
614+
->keyset('{"keys":[{"kty":"...","k":"..."}]}')
616615
// Audience (`aud` claim): required for validation purpose
617616
->audience('api-example')
618617
// Issuers (`iss` claim): required for validation purpose
@@ -636,8 +635,8 @@ configuration:
636635
token_handler:
637636
oidc:
638637
claim: email
639-
algorithm: 'ES256'
640-
key: '{"kty":"...","k":"..."}'
638+
algorithms: ['ES256', 'RS256']
639+
keyset: '{"keys":[{"kty":"...","k":"..."}]}'
641640
audience: 'api-example'
642641
issuers: ['https://oidc.example.com']
643642
@@ -657,7 +656,9 @@ configuration:
657656
<firewall name="main">
658657
<access-token>
659658
<token-handler>
660-
<oidc claim="email" algorithm="ES256" key="{'kty':'...','k':'...'}" audience="api-example">
659+
<oidc claim="email" keyset="{'keys':[{'kty':'...','k':'...'}]}" audience="api-example">
660+
<algorithm>ES256</algorithm>
661+
<algorithm>RS256</algorithm>
661662
<issuer>https://oidc.example.com</issuer>
662663
</oidc>
663664
</token-handler>
@@ -677,8 +678,8 @@ configuration:
677678
->tokenHandler()
678679
->oidc()
679680
->claim('email')
680-
->algorithm('ES256')
681-
->key('{"kty":"...","k":"..."}')
681+
->algorithms(['ES256', 'RS256'])
682+
->keyset('{"keys":[{"kty":"...","k":"..."}]}')
682683
->audience('api-example')
683684
->issuers(['https://oidc.example.com'])
684685
;

0 commit comments

Comments
 (0)