anzusystems/auth-bundle

Anzu授权服务

安装数量: 4,122

依赖项: 0

建议者: 0

安全性: 0

星标: 1

关注者: 6

分支: 0

开放性问题: 0

类型:symfony-bundle

2.1.0 2024-05-29 10:45 UTC

This package is auto-updated.

Last update: 2024-08-29 11:20:30 UTC


README

为Anzusystems项目提供授权功能。

安装

在容器内执行以下命令以下载最新版本的包

$ composer require anzusystems/auth-bundle --no-scripts

步骤3:使用包

config/anzu_systems_auth.yaml中配置AnzuAuthBundle

anzu_systems_auth:
  cookie:
    domain: .anzusystems.localhost
    secure: false # use true for PROD environment!
  jwt:
    audience: anz
    algorithm: ES256 # enum (ES256|RS256), default "ES256"
    public_cert: '%env(base64:AUTH_JWT_PUBLIC_CERT)%' # string representation of a public certificate
    private_cert: '%env(base64:AUTH_JWT_PRIVATE_CERT)%' # string representation of a private certificate
  authorization:
    enabled: true
    refresh_token:
      storage:
        redis:
          service_id: SharedTokenStorageRedis # service id of \Redis instance
    auth_redirect_default_url: http://admin-dam.anzusystems.localhost
    auth_redirect_query_url_allowed_pattern: '^https?://(.*)\.anzusystems\.localhost(:\d{2,5})$'
    type: json_credentials

config/security.yaml中配置SecurityBundle

security:
  providers:
    app_user_provider_email:
      entity:
        class: App\Entity\User
        property: email

  auth:
    pattern: ^/api/auth/
    stateless: true
    provider: app_user_provider_email
    json_login:
      check_path: auth_login
      success_handler: AnzuSystems\AuthBundle\Security\AuthenticationSuccessHandler
      failure_handler: AnzuSystems\AuthBundle\Security\AuthenticationFailureHandler
    logout:
      path: auth_logout

  access_control:
    - { path: ^/api/auth/, roles: PUBLIC_ACCESS }

配置路由

$routes
    ->import('@AnzuSystemsAuthBundle/Controller/Api/JsonCredentialsAuthController.php', type: 'attribute')
    ->prefix('/api/auth/');