Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Security] Add OIDC Discovery#20579

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Merged
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
145 changes: 145 additions & 0 deletionssecurity/access_token.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -411,6 +411,72 @@
;
};

To enable the `OpenID Connect Discovery`_, the ``OidcUserInfoTokenHandler``
requires the ``symfony/cache`` package to store the OIDC configuration in
cache. If you haven't installed it yet, run this command:

.. code-block:: terminal

$ composer require symfony/cache

Then, configure the ``base_uri`` and ``discovery`` keys:

.. configuration-block::

.. code-block:: yaml

# config/packages/security.yaml
security:
firewalls:
main:
access_token:
token_handler:
oidc_user_info:
base_uri: https://www.example.com/realms/demo/
discovery:
cache: cache.app

Check failure on line 437 in security/access_token.rst

View workflow job for this annotation

GitHub Actions/ Code Blocks

[Cache Warmup] In ArrayNode.php line 304: Unrecognized option "discovery" under "security.firewalls.main.access_token .token_handler.oidc_user_info". Available options are "base_uri", "claim", "client".

.. code-block:: xml

<!-- config/packages/security.xml -->
<?xml version="1.0" encoding="UTF-8"?>
<srv:container xmlns="http://symfony.com/schema/dic/security"
xmlns:srv="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services
https://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/security
https://symfony.com/schema/dic/security/security-1.0.xsd">

<config>
<firewall name="main">
<access-token>
<token-handler>
<oidc-user-info base-uri="https://www.example.com/realms/demo/">
<discovery cache="cache.app"/>
</oidc-user-info>
</token-handler>
</access-token>
</firewall>
</config>
</srv:container>

.. code-block:: php

// config/packages/security.php
use Symfony\Config\SecurityConfig;

return static function (SecurityConfig $security) {
$security->firewall('main')
->accessToken()
->tokenHandler()
->oidcUserInfo()
->baseUri('https://www.example.com/realms/demo/')
->discovery()
->cache('cache.app')
;
};

Check failure on line 478 in security/access_token.rst

View workflow job for this annotation

GitHub Actions/ Code Blocks

[Cache Warmup] 2025-01-17T09:33:37+00:00 [critical] Uncaught Error: Call to undefined method Symfony\Config\Security\FirewallConfig\AccessToken\TokenHandler\OidcUserInfoConfig::discovery()

Following the `OpenID Connect Specification`_, the ``sub`` claim is used as user
identifier by default. To use another claim, specify it on the configuration:

Expand DownExpand Up@@ -625,6 +691,84 @@
The support of multiple algorithms to sign the JWS was introduced in Symfony 7.1.
In previous versions, only the ``ES256`` algorithm was supported.

To enable the `OpenID Connect Discovery`_, the ``OidcTokenHandler``
requires the ``symfony/cache`` package to store the OIDC configuration in
cache. If you haven't installed it yet, run this command:

.. code-block:: terminal

$ composer require symfony/cache

Then, you can remove the ``keyset`` configuration key (it will be imported from
the OpenID Connect Discovery), and configure the ``discovery`` key:

.. configuration-block::

.. code-block:: yaml

# config/packages/security.yaml
security:
firewalls:
main:
access_token:
token_handler:
oidc:
claim: email
algorithms: ['ES256', 'RS256']
audience: 'api-example'
issuers: ['https://oidc.example.com']
discovery:
base_uri: https://www.example.com/realms/demo/
cache: cache.app

Check failure on line 722 in security/access_token.rst

View workflow job for this annotation

GitHub Actions/ Code Blocks

[Cache Warmup] In ArrayNode.php line 304: Unrecognized option "discovery" under "security.firewalls.main.access_token .token_handler.oidc". Available options are "algorithm", "algorithms", "aud ience", "claim", "encryption", "issuers", "key", "keyset".

.. code-block:: xml

<!-- config/packages/security.xml -->
<?xml version="1.0" encoding="UTF-8"?>
<srv:container xmlns="http://symfony.com/schema/dic/security"
xmlns:srv="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services
https://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/security
https://symfony.com/schema/dic/security/security-1.0.xsd">

<config>
<firewall name="main">
<access-token>
<token-handler>
<oidc claim="email" audience="api-example">
<algorithm>ES256</algorithm>
<algorithm>RS256</algorithm>
<issuer>https://oidc.example.com</issuer>
<discovery base-uri="https://www.example.com/realms/demo/" cache="cache.app">
</oidc>

Check failure on line 745 in security/access_token.rst

View workflow job for this annotation

GitHub Actions/ Code Blocks

[XML syntax] Opening and ending tag mismatch: discovery line 18 and oidc
</token-handler>
</access-token>
</firewall>
</config>
</srv:container>

.. code-block:: php

// config/packages/security.php
use Symfony\Config\SecurityConfig;

return static function (SecurityConfig $security) {
$security->firewall('main')
->accessToken()
->tokenHandler()
->oidc()
->claim('email')
->algorithms(['ES256', 'RS256'])
->audience('api-example')
->issuers(['https://oidc.example.com'])
->discovery()
->baseUri('https://www.example.com/realms/demo/')
->cache('cache.app')
;
};

Check failure on line 770 in security/access_token.rst

View workflow job for this annotation

GitHub Actions/ Code Blocks

[Cache Warmup] 2025-01-17T09:33:48+00:00 [critical] Uncaught Error: Call to undefined method Symfony\Config\Security\FirewallConfig\AccessToken\TokenHandler\OidcConfig::discovery()

Following the `OpenID Connect Specification`_, the ``sub`` claim is used by
default as user identifier. To use another claim, specify it on the
configuration:
Expand DownExpand Up@@ -925,5 +1069,6 @@
.. _`JSON Web Tokens (JWT)`: https://datatracker.ietf.org/doc/html/rfc7519
.. _`OpenID Connect (OIDC)`: https://en.wikipedia.org/wiki/OpenID#OpenID_Connect_(OIDC)
.. _`OpenID Connect Specification`: https://openid.net/specs/openid-connect-core-1_0.html
.. _`OpenID Connect Discovery`: https://openid.net/specs/openid-connect-discovery-1_0.html
.. _`RFC6750`: https://datatracker.ietf.org/doc/html/rfc6750
.. _`SAML2 (XML structures)`: https://docs.oasis-open.org/security/saml/Post2.0/sstc-saml-tech-overview-2.0.html
Loading

[8]ページ先頭

©2009-2025 Movatter.jp