Skip to content

Commit d698efe

Browse files
committed
SecurityExtension: password can be dynamic [Closes #74]
1 parent 4391db3 commit d698efe

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/Bridges/SecurityDI/SecurityExtension.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ public function getConfigSchema(): Nette\Schema\Schema
3434
'debugger' => Expect::bool(),
3535
'users' => Expect::arrayOf(
3636
Expect::anyOf(
37-
Expect::string(), // user => password
37+
Expect::string()->dynamic(), // user => password
3838
Expect::structure([ // user => password + roles + data
39-
'password' => Expect::string(),
39+
'password' => Expect::string()->dynamic(),
4040
'roles' => Expect::anyOf(Expect::string(), Expect::listOf('string')),
4141
'data' => Expect::array(),
4242
])->castTo('array'),

tests/Security.DI/SecurityExtension.authenticator.phpt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ security:
2929
admin: {password: admin123, roles: [admin, user]}
3030
user: {password: user123}
3131
moderator: {password: moderator123, roles: moderator}
32+
dynamic1: ::trim(xxx)
33+
dynamic2: {password: ::trim(xxx)}
3234
', 'neon'));
3335

3436
eval($compiler->addConfig($config)->compile());
@@ -43,12 +45,16 @@ $userList = [
4345
'admin' => 'admin123',
4446
'user' => 'user123',
4547
'moderator' => 'moderator123',
48+
'dynamic1' => 'xxx',
49+
'dynamic2' => 'xxx',
4650
];
4751
$expectedRoles = [
4852
'john' => [],
4953
'admin' => ['admin', 'user'],
5054
'user' => [],
5155
'moderator' => ['moderator'],
56+
'dynamic1' => [],
57+
'dynamic2' => [],
5258
];
5359

5460
foreach ($userList as $username => $password) {

0 commit comments

Comments
 (0)