@@ -61,8 +61,7 @@ discard block |
||
61 | 61 | * @package Platine\Framework\Auth\Middleware |
62 | 62 | * @template T |
63 | 63 | */ |
64 | -class ApiAuthenticationMiddleware implements MiddlewareInterface |
|
65 | -{ |
|
64 | +class ApiAuthenticationMiddleware implements MiddlewareInterface { |
|
66 | 65 | /** |
67 | 66 | * The Authentication instance |
68 | 67 | * @var ApiAuthenticationInterface |
@@ -83,7 +82,7 @@ discard block |
||
83 | 82 | public function __construct( |
84 | 83 | ApiAuthenticationInterface $authentication, |
85 | 84 | Config $config |
86 | - ) { |
|
85 | + ) { |
|
87 | 86 | $this->authentication = $authentication; |
88 | 87 | $this->config = $config; |
89 | 88 | } |
@@ -95,11 +94,11 @@ discard block |
||
95 | 94 | ServerRequestInterface $request, |
96 | 95 | RequestHandlerInterface $handler |
97 | 96 | ): ResponseInterface { |
98 | - if (!$this->shouldBeProcessed($request)) { |
|
97 | + if (!$this->shouldBeProcessed($request)) { |
|
99 | 98 | return $handler->handle($request); |
100 | 99 | } |
101 | 100 | |
102 | - if (!$this->authentication->isAuthenticated($request)) { |
|
101 | + if (!$this->authentication->isAuthenticated($request)) { |
|
103 | 102 | return $this->unauthorizedResponse(); |
104 | 103 | } |
105 | 104 | |
@@ -116,19 +115,19 @@ discard block |
||
116 | 115 | //If no route has been match no need check for authentication |
117 | 116 | /** @var ?Route $route */ |
118 | 117 | $route = $request->getAttribute(Route::class); |
119 | - if (!$route) { |
|
118 | + if (!$route) { |
|
120 | 119 | return false; |
121 | 120 | } |
122 | 121 | |
123 | 122 | //Check if the path match |
124 | 123 | $path = $this->config->get('api.auth.path', '/'); |
125 | - if (!preg_match('~^' . $path . '~', $route->getPattern())) { |
|
124 | + if (!preg_match('~^' . $path . '~', $route->getPattern())) { |
|
126 | 125 | return false; |
127 | 126 | } |
128 | 127 | |
129 | 128 | //check if is url whitelist |
130 | 129 | $urls = $this->config->get('api.auth.url_whitelist', []); |
131 | - if (in_array($route->getName(), $urls)) { |
|
130 | + if (in_array($route->getName(), $urls)) { |
|
132 | 131 | return false; |
133 | 132 | } |
134 | 133 |
@@ -62,8 +62,7 @@ discard block |
||
62 | 62 | * @package Platine\Framework\Auth\Middleware |
63 | 63 | * @template T |
64 | 64 | */ |
65 | -class AuthenticationMiddleware implements MiddlewareInterface |
|
66 | -{ |
|
65 | +class AuthenticationMiddleware implements MiddlewareInterface { |
|
67 | 66 | /** |
68 | 67 | * The Authentication instance |
69 | 68 | * @var AuthenticationInterface |
@@ -92,7 +91,7 @@ discard block |
||
92 | 91 | AuthenticationInterface $authentication, |
93 | 92 | Config $config, |
94 | 93 | RouteHelper $routeHelper |
95 | - ) { |
|
94 | + ) { |
|
96 | 95 | $this->authentication = $authentication; |
97 | 96 | $this->config = $config; |
98 | 97 | $this->routeHelper = $routeHelper; |
@@ -105,11 +104,11 @@ discard block |
||
105 | 104 | ServerRequestInterface $request, |
106 | 105 | RequestHandlerInterface $handler |
107 | 106 | ): ResponseInterface { |
108 | - if (!$this->shouldBeProcessed($request)) { |
|
107 | + if (!$this->shouldBeProcessed($request)) { |
|
109 | 108 | return $handler->handle($request); |
110 | 109 | } |
111 | 110 | |
112 | - if (!$this->authentication->isLogged()) { |
|
111 | + if (!$this->authentication->isLogged()) { |
|
113 | 112 | $authRoute = $this->config->get('auth.authentication.login_route'); |
114 | 113 | $next = $request->getUri()->getPath(); |
115 | 114 | return new RedirectResponse( |
@@ -130,13 +129,13 @@ discard block |
||
130 | 129 | //If no route has been match no need check for authentication |
131 | 130 | /** @var ?Route $route */ |
132 | 131 | $route = $request->getAttribute(Route::class); |
133 | - if (!$route) { |
|
132 | + if (!$route) { |
|
134 | 133 | return false; |
135 | 134 | } |
136 | 135 | |
137 | 136 | //check if is url whitelist |
138 | 137 | $urls = $this->config->get('auth.authentication.url_whitelist', []); |
139 | - if (in_array($route->getName(), $urls)) { |
|
138 | + if (in_array($route->getName(), $urls)) { |
|
140 | 139 | return false; |
141 | 140 | } |
142 | 141 |
@@ -37,6 +37,5 @@ |
||
37 | 37 | * @class AccountLockedException |
38 | 38 | * @package Platine\Framework\Auth\Exception |
39 | 39 | */ |
40 | -class AccountLockedException extends AuthenticationException |
|
41 | -{ |
|
40 | +class AccountLockedException extends AuthenticationException { |
|
42 | 41 | } |
@@ -37,6 +37,5 @@ |
||
37 | 37 | * @class MissingCredentialsException |
38 | 38 | * @package Platine\Framework\Auth\Exception |
39 | 39 | */ |
40 | -class MissingCredentialsException extends AuthenticationException |
|
41 | -{ |
|
40 | +class MissingCredentialsException extends AuthenticationException { |
|
42 | 41 | } |
@@ -39,6 +39,5 @@ |
||
39 | 39 | * @class AuthenticationException |
40 | 40 | * @package Platine\Framework\Auth\Exception |
41 | 41 | */ |
42 | -class AuthenticationException extends Exception |
|
43 | -{ |
|
42 | +class AuthenticationException extends Exception { |
|
44 | 43 | } |
@@ -37,6 +37,5 @@ |
||
37 | 37 | * @class InvalidCredentialsException |
38 | 38 | * @package Platine\Framework\Auth\Exception |
39 | 39 | */ |
40 | -class InvalidCredentialsException extends AuthenticationException |
|
41 | -{ |
|
40 | +class InvalidCredentialsException extends AuthenticationException { |
|
42 | 41 | } |
@@ -37,6 +37,5 @@ |
||
37 | 37 | * @class AccountNotFoundException |
38 | 38 | * @package Platine\Framework\Auth\Exception |
39 | 39 | */ |
40 | -class AccountNotFoundException extends AuthenticationException |
|
41 | -{ |
|
40 | +class AccountNotFoundException extends AuthenticationException { |
|
42 | 41 | } |
@@ -54,8 +54,7 @@ discard block |
||
54 | 54 | * @class AuthInvalidPasswordEvent |
55 | 55 | * @package Platine\Framework\Auth\Event |
56 | 56 | */ |
57 | -class AuthInvalidPasswordEvent extends Event |
|
58 | -{ |
|
57 | +class AuthInvalidPasswordEvent extends Event { |
|
59 | 58 | /** |
60 | 59 | * The authentication user |
61 | 60 | * @var User |
@@ -66,8 +65,7 @@ discard block |
||
66 | 65 | * Create new instance |
67 | 66 | * @param User $user |
68 | 67 | */ |
69 | - public function __construct(User $user) |
|
70 | - { |
|
68 | + public function __construct(User $user) { |
|
71 | 69 | parent::__construct(__CLASS__, []); |
72 | 70 | $this->user = $user; |
73 | 71 | } |
@@ -54,8 +54,7 @@ discard block |
||
54 | 54 | * @class AuthLoginEvent |
55 | 55 | * @package Platine\Framework\Auth\Event |
56 | 56 | */ |
57 | -class AuthLoginEvent extends Event |
|
58 | -{ |
|
57 | +class AuthLoginEvent extends Event { |
|
59 | 58 | /** |
60 | 59 | * The authentication user |
61 | 60 | * @var User |
@@ -66,8 +65,7 @@ discard block |
||
66 | 65 | * Create new instance |
67 | 66 | * @param User $user |
68 | 67 | */ |
69 | - public function __construct(User $user) |
|
70 | - { |
|
68 | + public function __construct(User $user) { |
|
71 | 69 | parent::__construct(__CLASS__, []); |
72 | 70 | $this->user = $user; |
73 | 71 | } |