linkorb/silex-provider-user-basic
Composer 安装命令:
composer require linkorb/silex-provider-user-basic
包简介
Custom Symfony Security User and in-memory User Provider for use in Silex apps.
README 文档
README
Custom Symfony Security User and in-memory User Provider for use in Silex apps.
First, create an array of users:-
// for example, in src/app.php
$users = [
'jo' => [
'password' => '$2y$12$G7...',
'roles' => ['admin'],
'display_name' => 'Joseph',
'enabled' => false,
],
'jen' => [
'password' => '$2y$12$oD...',
'roles' => ['admin'],
'display_name' => 'Jenifer',
],
];
The password value is the hashed password; these can be generated with the
accomapnying password hashing command:-
$ vendor/bin/hashpasswd -h
Usage:
hashpasswd [options]
Options:
-c, --cost=COST Algorithmic cost of the hash function. [default: 12]
-h, --help Display this help message
Help:
The command interactively asks for the password before printing its hash.
Next, register Silex's core SecurityServiceProvider and provide a firewall paramater:-
$app->register(
new SecurityServiceProvider,
[
'security.firewalls' => [
'api' => [
'pattern' => '^/api',
'http' => true,
'users' => function () use ($users) {
return new \LinkORB\BasicUser\Provider\UserProvider($users);
},
],
],
]
);
统计信息
- 总下载量: 113
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-05-25