@@ -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 |
@@ -262,12 +262,12 @@ discard block |
||
| 262 | 262 | $tokenExpire = time() + $expire; |
| 263 | 263 | $refreshTokenExpire = time() + $refreshExpire; |
| 264 | 264 | $this->jwt->setSecret($secret) |
| 265 | - ->setPayload([ |
|
| 266 | - 'sub' => $user->id, |
|
| 267 | - 'exp' => $tokenExpire, |
|
| 268 | - 'permissions' => $permissions, |
|
| 269 | - ]) |
|
| 270 | - ->sign(); |
|
| 265 | + ->setPayload([ |
|
| 266 | + 'sub' => $user->id, |
|
| 267 | + 'exp' => $tokenExpire, |
|
| 268 | + 'permissions' => $permissions, |
|
| 269 | + ]) |
|
| 270 | + ->sign(); |
|
| 271 | 271 | |
| 272 | 272 | $refreshToken = Str::random(64); |
| 273 | 273 | $jwtToken = $this->jwt->getToken(); |
@@ -282,16 +282,16 @@ discard block |
||
| 282 | 282 | $this->tokenRepository->save($token); |
| 283 | 283 | |
| 284 | 284 | $data = [ |
| 285 | - 'user' => [ |
|
| 285 | + 'user' => [ |
|
| 286 | 286 | 'id' => $user->id, |
| 287 | 287 | 'username' => $user->username, |
| 288 | 288 | 'lastname' => $user->lastname, |
| 289 | 289 | 'firstname' => $user->firstname, |
| 290 | 290 | 'email' => $user->email, |
| 291 | 291 | 'permissions' => $permissions, |
| 292 | - ], |
|
| 293 | - 'token' => $jwtToken, |
|
| 294 | - 'refresh_token' => $refreshToken, |
|
| 292 | + ], |
|
| 293 | + 'token' => $jwtToken, |
|
| 294 | + 'refresh_token' => $refreshToken, |
|
| 295 | 295 | ]; |
| 296 | 296 | |
| 297 | 297 | 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 |
@@ -57,8 +57,7 @@ |
||
| 57 | 57 | * @class ApiAuthenticationInterface |
| 58 | 58 | * @package Platine\Framework\Auth |
| 59 | 59 | */ |
| 60 | -interface ApiAuthenticationInterface |
|
| 61 | -{ |
|
| 60 | +interface ApiAuthenticationInterface { |
|
| 62 | 61 | /** |
| 63 | 62 | * Whether the request is authenticated |
| 64 | 63 | * @param ServerRequestInterface $request |