linkorb/flex-auth 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

linkorb/flex-auth

Composer 安装命令:

composer require linkorb/flex-auth

包简介

This libraries provides flex auth for symfony security in runtime

关键字:

README 文档

README

FlexAuth: independent library for symfony security

Allows switching the UserProvider at Runtime using environment variables.

Dynamic UserProvider that supports multiple backends based on environment variables.

To override which should provider configuration as array for runtime FlexAuth\FlexAuthTypeProviderInterface

Using FlexAuth\FlexAuthTypeProviderFactory::fromEnv('FLEX_AUTH'') and define env variables in format type?param1=value1&param2=value2&param3=value3

Example define environment variable

## Use memory provider
FLEX_AUTH=memory?users=alice:4l1c3:ROLE_ADMIN;ROLE_EXAMPLE,bob:b0b:ROLE_EXAMPLE)
## Or use userbase provider
FLEX_AUTH=userbase?dsn=https://username:password@userbase.example.com
## Or use the entity provider
FLEX_AUTH=entity?class=\App\Entities\User&property=username
## Or use a JWT provider
FLEX_AUTH=jwt?algo=RS256&publickey=@\cert\public_key.key&private_key=@\cert\privite_key.key&userField=username&groupField=permissions

A long form format could be supported like this:

FLEX_AUTH=entity
FLEX_AUTH_ENTITY_CLASS=\App\Entities\User
FLEX_AUTH_ENTITY_PROPERTY=username

Dynamically flex type provider example.

class MyFlexAuthTypeProvider implements FlexAuthTypeProviderInterface {
    protected $className = \App\Entities\User::class; // can be change in runtime
    protected $propery = 'id';
    
    //...
    public function provide(): array { // will be call every time
        return [
            'type' => 'entity',
            'class' => $this->className,
            'propery' => $this->propery, // dynamic user identificator
        ];
    }
    
    public function switchToEmail() {
        $this->propery = 'email';
    }
}

Full working example you can see /test/AuthenticationTest::testAuthenticate

Run tests

./vendor/bin/phpunit --bootstrap vendor/autoload.php tests/

Links

FlexAuthBundle - symfony bundle. Demo

FlexAuthProvider - silex provider. Demo

The Security Component(Symfony Docs)

统计信息

  • 总下载量: 1.21k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 5
  • 依赖项目数: 3
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 2
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-03-08

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固