paysera/lib-bearer-authentication-bundle

本包最新版本(2.0.1)没有提供许可证信息。

Bearer 认证包

2.0.1 2024-06-04 11:58 UTC

This package is auto-updated.

Last update: 2024-09-04 12:31:44 UTC


README

安装

将包添加到 AppKernel.php

$bundles = [
    ...
    new Paysera\BearerAuthenticationBundle\PayseraBearerAuthenticationBundle(),
];

示例

symfony 3/4 的示例 security.yml

security:
    providers:
        bearer_user:
            id: paysera_bearer_authentication.security_user.bearer_user_provider
    
    firewalls:
        bearer_secured:
            pattern: ^/api/
            stateless: true
            bearer: true
            provider: bearer_user

Symfony 5 的示例 security.yml

security:
    enable_authenticator_manager: true
    providers:
      bearer_user:
            id: paysera_bearer_authentication.security_user.bearer_user_provider    

    firewalls:
      bearer_secured:
            pattern: ^/api
            stateless: true
            provider: bearer_user
            custom_authenticators:
              - Paysera\BearerAuthenticationBundle\Security\BearerPassportAuthenticator
            
    access_control:
        # require ROLE_ADMIN for /admin*
        - { path: '^/api', roles: ROLE_ADMIN }

所有 bearer 处理器必须标记为

<tag name="paysera_bearer_authentication.handler" />

并实现 \Paysera\BearerAuthenticationBundle\Security\User\HandlerInterface

handler services.yaml 的示例

    paysera_auth_token.security.auth_token_handler:
        class: 'App\Services\BearerHandler'
        tags:
            - { name: 'paysera_bearer_authentication.handler' }

支持矩阵

以下表格显示了本库支持的 PHP 版本,请查看每个单独包的 composer.json 文件以获取其他要求。