@@ -61,8 +61,7 @@ |
||
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 |
@@ -62,8 +62,7 @@ |
||
62 | 62 | * @package Platine\Framework\Auth\Middleware |
63 | 63 | * @template T |
64 | 64 | */ |
65 | -class AuthorizationMiddleware implements MiddlewareInterface |
|
66 | -{ |
|
65 | +class AuthorizationMiddleware implements MiddlewareInterface { |
|
67 | 66 | /** |
68 | 67 | * The Authorization instance |
69 | 68 | * @var AuthorizationInterface |
@@ -51,8 +51,7 @@ |
||
51 | 51 | * @class AuthorizationInterface |
52 | 52 | * @package Platine\Framework\Auth |
53 | 53 | */ |
54 | -interface AuthorizationInterface |
|
55 | -{ |
|
54 | +interface AuthorizationInterface { |
|
56 | 55 | /** |
57 | 56 | * Check if user is granted the given permission |
58 | 57 | * @param string $permission the permission to check |
@@ -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 | } |
@@ -56,8 +56,7 @@ |
||
56 | 56 | * @class AuthenticationInterface |
57 | 57 | * @package Platine\Framework\Auth |
58 | 58 | */ |
59 | -interface AuthenticationInterface |
|
60 | -{ |
|
59 | +interface AuthenticationInterface { |
|
61 | 60 | /** |
62 | 61 | * Authenticate the user |
63 | 62 | * @param array<string, mixed> $credentials |
@@ -69,8 +69,7 @@ |
||
69 | 69 | * @package Platine\Framework\Auth\Authentication |
70 | 70 | * @template T |
71 | 71 | */ |
72 | -class JWTAuthentication implements ApiAuthenticationInterface |
|
73 | -{ |
|
72 | +class JWTAuthentication implements ApiAuthenticationInterface { |
|
74 | 73 | /** |
75 | 74 | * The JWT instance |
76 | 75 | * @var JWT |
@@ -248,12 +248,12 @@ discard block |
||
248 | 248 | $tokenExpire = time() + $expire; |
249 | 249 | $refreshTokenExpire = time() + $refreshExpire; |
250 | 250 | $this->jwt->setSecret($secret) |
251 | - ->setPayload([ |
|
252 | - 'sub' => $user->id, |
|
253 | - 'exp' => $tokenExpire, |
|
254 | - 'permissions' => $permissions, |
|
255 | - ]) |
|
256 | - ->sign(); |
|
251 | + ->setPayload([ |
|
252 | + 'sub' => $user->id, |
|
253 | + 'exp' => $tokenExpire, |
|
254 | + 'permissions' => $permissions, |
|
255 | + ]) |
|
256 | + ->sign(); |
|
257 | 257 | $refreshToken = bin2hex(random_bytes(20)); |
258 | 258 | $jwtToken = $this->jwt->getToken(); |
259 | 259 | |
@@ -267,16 +267,16 @@ discard block |
||
267 | 267 | $this->tokenRepository->save($token); |
268 | 268 | |
269 | 269 | $data = [ |
270 | - 'user' => [ |
|
270 | + 'user' => [ |
|
271 | 271 | 'id' => $user->id, |
272 | 272 | 'username' => $user->username, |
273 | 273 | 'lastname' => $user->lastname, |
274 | 274 | 'firstname' => $user->firstname, |
275 | 275 | 'email' => $user->email, |
276 | 276 | 'permissions' => $permissions, |
277 | - ], |
|
278 | - 'token' => $jwtToken, |
|
279 | - 'refresh_token' => $refreshToken, |
|
277 | + ], |
|
278 | + 'token' => $jwtToken, |
|
279 | + 'refresh_token' => $refreshToken, |
|
280 | 280 | ]; |
281 | 281 | |
282 | 282 | return array_merge($data, $this->getUserData($user, $token)); |
@@ -63,8 +63,7 @@ |
||
63 | 63 | * class SessionAuthentication |
64 | 64 | * @package Platine\Framework\Auth\Authentication |
65 | 65 | */ |
66 | -class SessionAuthentication implements AuthenticationInterface |
|
67 | -{ |
|
66 | +class SessionAuthentication implements AuthenticationInterface { |
|
68 | 67 | /** |
69 | 68 | * The session instance to use |
70 | 69 | * @var Session |
@@ -185,11 +185,11 @@ |
||
185 | 185 | } |
186 | 186 | |
187 | 187 | $data = [ |
188 | - 'id' => $user->id, |
|
189 | - 'username' => $user->username, |
|
190 | - 'lastname' => $user->lastname, |
|
191 | - 'firstname' => $user->firstname, |
|
192 | - 'permissions' => array_unique($permissions), |
|
188 | + 'id' => $user->id, |
|
189 | + 'username' => $user->username, |
|
190 | + 'lastname' => $user->lastname, |
|
191 | + 'firstname' => $user->firstname, |
|
192 | + 'permissions' => array_unique($permissions), |
|
193 | 193 | ]; |
194 | 194 | |
195 | 195 | $this->session->set('user', array_merge($data, $this->getUserData($user))); |
@@ -51,8 +51,7 @@ |
||
51 | 51 | * @class IdentityInterface |
52 | 52 | * @package Platine\Framework\Auth |
53 | 53 | */ |
54 | -interface IdentityInterface |
|
55 | -{ |
|
54 | +interface IdentityInterface { |
|
56 | 55 | /** |
57 | 56 | * Return the id of the current user |
58 | 57 | * @return mixed |
@@ -54,8 +54,7 @@ |
||
54 | 54 | * class SessionAuthorization |
55 | 55 | * @package Platine\Framework\Auth\Authorization |
56 | 56 | */ |
57 | -class SessionAuthorization implements AuthorizationInterface |
|
58 | -{ |
|
57 | +class SessionAuthorization implements AuthorizationInterface { |
|
59 | 58 | /** |
60 | 59 | * The session instance to use |
61 | 60 | * @var Session |