ozznest/token-authenticator

Symfony 扩展,允许您使用基于令牌的认证

安装: 59

依赖者: 0

建议者: 0

安全: 0

星标: 0

关注者: 0

分支: 2

类型:symfony-bundle

1.3.1 2021-10-25 09:40 UTC

README

此扩展允许您使用类似于 OAuth 的令牌认证机制,但更加简化。

安装

首先,通过将以下内容添加到 AppKernel 中的 registerBundles 方法来启用扩展

...
            new Youshido\TokenAuthenticationBundle\TokenAuthenticationBundle(),

然后,在 app/config/security.yml 下创建提供者和防火墙(如果您还没有编码器,也可以在这里添加)

security:
    providers:
        api_user_provider:
            id: token_user_provider

    encoders:
        AppBundle\Entity\User: md5

    firewalls:
        api_firewall:
            pattern: ^/.*
            stateless: true
            simple_preauth:
                authenticator: token_authenticator
            provider: api_user_provider
            anonymous: ~

现在,将您的模型类名添加到服务声明中 app/config/config.yml

token_authentication:
    user_model: "AppBundle\\Entity\\User"