|
1
|
|
|
<?php |
|
2
|
|
|
declare(strict_types=1); |
|
3
|
|
|
|
|
4
|
|
|
namespace SlayerBirden\DataFlowServer\Authentication\Factory; |
|
5
|
|
|
|
|
6
|
|
|
use Interop\Container\ContainerInterface; |
|
7
|
|
|
use SlayerBirden\DataFlowServer\Authentication\Controller\CreatePasswordAction; |
|
8
|
|
|
use SlayerBirden\DataFlowServer\Authentication\Controller\GenerateTemporaryTokenAction; |
|
9
|
|
|
use SlayerBirden\DataFlowServer\Authentication\Controller\GetTokenAction; |
|
10
|
|
|
use SlayerBirden\DataFlowServer\Authentication\Controller\InvalidateTokenAction; |
|
11
|
|
|
use SlayerBirden\DataFlowServer\Authentication\Controller\InvalidateTokensAction; |
|
12
|
|
|
use SlayerBirden\DataFlowServer\Authentication\Controller\UpdatePasswordAction; |
|
13
|
|
|
use SlayerBirden\DataFlowServer\Authentication\Middleware\ActivePasswordMiddleware; |
|
14
|
|
|
use SlayerBirden\DataFlowServer\Authentication\Middleware\PasswordConfirmationMiddleware; |
|
15
|
|
|
use SlayerBirden\DataFlowServer\Authentication\Middleware\TokenMiddleware; |
|
16
|
|
|
use SlayerBirden\DataFlowServer\Domain\Middleware\SetOwnerMiddleware; |
|
17
|
|
|
use SlayerBirden\DataFlowServer\Domain\Middleware\ValidateOwnerMiddleware; |
|
18
|
|
|
use Zend\Expressive\Application; |
|
19
|
|
|
use Zend\Expressive\Helper\BodyParams\BodyParamsMiddleware; |
|
20
|
|
|
use Zend\ServiceManager\Factory\DelegatorFactoryInterface; |
|
21
|
|
|
|
|
22
|
|
|
final class RoutesDelegator implements DelegatorFactoryInterface |
|
|
|
|
|
|
23
|
|
|
{ |
|
24
|
|
|
/** |
|
25
|
|
|
* @inheritdoc |
|
26
|
|
|
*/ |
|
27
|
144 |
|
public function __invoke(ContainerInterface $container, $name, callable $callback, array $options = null) |
|
28
|
|
|
{ |
|
29
|
|
|
/** @var $app Application */ |
|
30
|
144 |
|
$app = $callback(); |
|
31
|
|
|
|
|
32
|
144 |
|
$app->post( |
|
33
|
144 |
|
'/gettmptoken/{id:\d+}', |
|
34
|
|
|
[ |
|
35
|
144 |
|
TokenMiddleware::class, |
|
36
|
|
|
'UserResourceMiddleware', |
|
37
|
|
|
BodyParamsMiddleware::class, |
|
38
|
|
|
GenerateTemporaryTokenAction::class, |
|
39
|
|
|
], |
|
40
|
144 |
|
'get_tmp_token' |
|
41
|
|
|
); |
|
42
|
|
|
|
|
43
|
144 |
|
$app->post( |
|
44
|
144 |
|
'/password', |
|
45
|
|
|
[ |
|
46
|
144 |
|
TokenMiddleware::class, |
|
47
|
|
|
BodyParamsMiddleware::class, |
|
48
|
|
|
ActivePasswordMiddleware::class, |
|
49
|
|
|
SetOwnerMiddleware::class, |
|
50
|
|
|
CreatePasswordAction::class, |
|
51
|
|
|
], |
|
52
|
144 |
|
'create_password' |
|
53
|
|
|
); |
|
54
|
|
|
|
|
55
|
144 |
|
$app->post( |
|
56
|
144 |
|
'/gettoken', |
|
57
|
|
|
[ |
|
58
|
144 |
|
BodyParamsMiddleware::class, |
|
59
|
|
|
GetTokenAction::class, |
|
60
|
|
|
], |
|
61
|
144 |
|
'get_token' |
|
62
|
|
|
); |
|
63
|
|
|
|
|
64
|
144 |
|
$app->put( |
|
65
|
144 |
|
'/invalidatetoken/{id:\d+}', |
|
66
|
|
|
[ |
|
67
|
144 |
|
TokenMiddleware::class, |
|
68
|
|
|
'TokenResourceMiddleware', |
|
69
|
|
|
ValidateOwnerMiddleware::class, |
|
70
|
|
|
InvalidateTokenAction::class, |
|
71
|
|
|
], |
|
72
|
144 |
|
'invalidate_token' |
|
73
|
|
|
); |
|
74
|
|
|
|
|
75
|
144 |
|
$app->post( |
|
76
|
144 |
|
'/invalidatetokens', |
|
77
|
|
|
[ |
|
78
|
144 |
|
TokenMiddleware::class, |
|
79
|
|
|
BodyParamsMiddleware::class, |
|
80
|
|
|
InvalidateTokensAction::class, |
|
81
|
|
|
], |
|
82
|
144 |
|
'invalidate_tokens' |
|
83
|
|
|
); |
|
84
|
|
|
|
|
85
|
144 |
|
$app->post( |
|
86
|
144 |
|
'/updatepassword', |
|
87
|
|
|
[ |
|
88
|
144 |
|
TokenMiddleware::class, |
|
89
|
|
|
BodyParamsMiddleware::class, |
|
90
|
|
|
ValidateOwnerMiddleware::class, |
|
91
|
|
|
PasswordConfirmationMiddleware::class, |
|
92
|
|
|
SetOwnerMiddleware::class, |
|
93
|
|
|
UpdatePasswordAction::class, |
|
94
|
|
|
], |
|
95
|
144 |
|
'update_password' |
|
96
|
|
|
); |
|
97
|
|
|
|
|
98
|
144 |
|
return $app; |
|
99
|
|
|
} |
|
100
|
|
|
} |
|
101
|
|
|
|