ciscaja/uhsa-userbundle

dev-master / 1.0.x-dev 2016-05-12 10:02 UTC

This package is not auto-updated.

Last update: 2024-09-14 19:09:27 UTC


README

Build Status

CiscajaUhsaUserBundle 为 Ciscaja 软件套件的用户系统提供后端功能。

用户可以存储在以下系统中

  • MySQL

用法

Ciscaja 套件依赖于 REST 架构和 JWT 验证,这由 LexikJWTAuthenticationBundle 和 GfreeauGetJWTBundle (可选) 实现。

将这两个包添加到 composer.json 文件中

        "lexik/jwt-authentication-bundle": "1.5.*",
        "gfreeau/get-jwt-bundle": "2.0.x-dev",

根据其文档配置这两个包,使用 CiscajaUhsaUserBundle 的用户实体和用户检查器。出于安全原因,您还应该为用户实体设置一个编码器。

注意:用户检查器是可选的。如果您不配置它,即使用户不被允许,他们也可能登录。

security.yml 的示例配置可能如下所示

security:
    encoders:
        Ciscaja\Uhsa\UserBundle\Entity\User: sha512
    providers:
        database:
            entity:
                class: CiscajaUhsaUserBundle:User
                property: username
    firewalls:
        token:
            pattern:  ^/api/token
            stateless: true
            gfreeau_get_jwt:
                user_checker: ciscaja.uhsa.userbundle.user_checker
        api:
            pattern:   ^/api
            stateless: true
            # default configuration
            lexik_jwt: ~ # check token in Authorization Header, with a value prefix of e:    bearer

测试

git clone https://github.com/ciscaja/uhsa-userbundle.git ciscaja-uhsa-userbundle
cd ciscaja-uhsa-userbundle/
composer update
bin/phpunit