@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | $this->app->bind(UserAuthenticationInterface::class, UserAuthentication::class); |
107 | 107 | |
108 | 108 | // Configuration |
109 | - $this->app->bind(Configuration::class, function (ContainerInterface $app) { |
|
109 | + $this->app->bind(Configuration::class, function(ContainerInterface $app) { |
|
110 | 110 | return new Configuration($app->get(Config::class)->get('oauth2', [])); |
111 | 111 | }); |
112 | 112 | |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | |
133 | 133 | // Servers |
134 | 134 | $this->app->bind(ResourceServerInterface::class, ResourceServer::class); |
135 | - $this->app->bind(AuthorizationServerInterface::class, function (ContainerInterface $app) { |
|
135 | + $this->app->bind(AuthorizationServerInterface::class, function(ContainerInterface $app) { |
|
136 | 136 | /** @var Configuration $cfg */ |
137 | 137 | $cfg = $app->get(Configuration::class); |
138 | 138 | $grants = $cfg->getGrants(); |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | */ |
169 | 169 | public function addRoutes(Router $router): void |
170 | 170 | { |
171 | - $router->group('/oauth2', function (Router $router) { |
|
171 | + $router->group('/oauth2', function(Router $router) { |
|
172 | 172 | $router->post('/token', AccessTokenRequestHandler::class, 'oauth2_access_token'); |
173 | 173 | $router->add('/authorize', AuthorizationRequestHandler::class, ['GET', 'POST'], 'oauth2_authorization_code'); |
174 | 174 | $router->post('/revocation', TokenRevocationRequestHandler::class, 'oauth2_revoke_access_token'); |
@@ -94,8 +94,7 @@ |
||
94 | 94 | * @class OAuth2ServiceProvider |
95 | 95 | * @package Platine\App\Provider |
96 | 96 | */ |
97 | -class OAuth2ServiceProvider extends ServiceProvider |
|
98 | -{ |
|
97 | +class OAuth2ServiceProvider extends ServiceProvider { |
|
99 | 98 | /** |
100 | 99 | * {@inheritdoc} |
101 | 100 | */ |
@@ -53,8 +53,7 @@ discard block |
||
53 | 53 | * @class TokenOwner |
54 | 54 | * @package Platine\Framework\OAuth2\User |
55 | 55 | */ |
56 | -class TokenOwner implements TokenOwnerInterface |
|
57 | -{ |
|
56 | +class TokenOwner implements TokenOwnerInterface { |
|
58 | 57 | /** |
59 | 58 | * The owner id |
60 | 59 | * @var mixed |
@@ -65,16 +64,14 @@ discard block |
||
65 | 64 | * Create new instance |
66 | 65 | * @param mixed|null $id |
67 | 66 | */ |
68 | - public function __construct($id = null) |
|
69 | - { |
|
67 | + public function __construct($id = null) { |
|
70 | 68 | $this->id = $id; |
71 | 69 | } |
72 | 70 | |
73 | 71 | /** |
74 | 72 | * {@inheritdoc} |
75 | 73 | */ |
76 | - public function getOwnerId() |
|
77 | - { |
|
74 | + public function getOwnerId() { |
|
78 | 75 | return 1; |
79 | 76 | } |
80 | 77 | } |
@@ -54,8 +54,7 @@ |
||
54 | 54 | * @class UserAuthentication |
55 | 55 | * @package Platine\Framework\OAuth2\User |
56 | 56 | */ |
57 | -class UserAuthentication implements UserAuthenticationInterface |
|
58 | -{ |
|
57 | +class UserAuthentication implements UserAuthenticationInterface { |
|
59 | 58 | /** |
60 | 59 | * {@inheritdoc} |
61 | 60 | */ |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | public function cleanExpiredTokens(): void |
86 | 86 | { |
87 | 87 | $this->query()->where('expires')->lte(date('Y-m-d H:i:s')) |
88 | - ->delete(); |
|
88 | + ->delete(); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | /** |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | public function deleteToken(BaseToken $token): bool |
95 | 95 | { |
96 | 96 | return $this->query()->where('authorization_code')->is($token->getToken()) |
97 | - ->delete() >= 0; |
|
97 | + ->delete() >= 0; |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | /** |
@@ -60,8 +60,7 @@ discard block |
||
60 | 60 | * @class AuthorizationCodeRepository |
61 | 61 | * @package Platine\Framework\OAuth2\Repository |
62 | 62 | */ |
63 | -class AuthorizationCodeRepository extends Repository implements AuthorizationCodeRepositoryInterface |
|
64 | -{ |
|
63 | +class AuthorizationCodeRepository extends Repository implements AuthorizationCodeRepositoryInterface { |
|
65 | 64 | /** |
66 | 65 | * The Client Service |
67 | 66 | * @var ClientService |
@@ -73,8 +72,7 @@ discard block |
||
73 | 72 | * @param EntityManager $manager |
74 | 73 | * @param ClientService $clientService |
75 | 74 | */ |
76 | - public function __construct(EntityManager $manager, ClientService $clientService) |
|
77 | - { |
|
75 | + public function __construct(EntityManager $manager, ClientService $clientService) { |
|
78 | 76 | parent::__construct($manager, OauthAuthorizationCode::class); |
79 | 77 | $this->clientService = $clientService; |
80 | 78 | } |
@@ -57,14 +57,12 @@ |
||
57 | 57 | * @class ClientRepository |
58 | 58 | * @package Platine\Framework\OAuth2\Repository |
59 | 59 | */ |
60 | -class ClientRepository extends Repository implements ClientRepositoryInterface |
|
61 | -{ |
|
60 | +class ClientRepository extends Repository implements ClientRepositoryInterface { |
|
62 | 61 | /** |
63 | 62 | * Create new instance |
64 | 63 | * @param EntityManager $manager |
65 | 64 | */ |
66 | - public function __construct(EntityManager $manager) |
|
67 | - { |
|
65 | + public function __construct(EntityManager $manager) { |
|
68 | 66 | parent::__construct($manager, OauthClient::class); |
69 | 67 | } |
70 | 68 |
@@ -92,8 +92,8 @@ |
||
92 | 92 | public function getDefaultScopes(): array |
93 | 93 | { |
94 | 94 | $result = $this->query() |
95 | - ->where('is_default')->is(1) |
|
96 | - ->all(); |
|
95 | + ->where('is_default')->is(1) |
|
96 | + ->all(); |
|
97 | 97 | $scopes = []; |
98 | 98 | foreach ($result as $row) { |
99 | 99 | $scopes[] = Scope::createNewScope( |
@@ -57,14 +57,12 @@ |
||
57 | 57 | * @class ScopeRepository |
58 | 58 | * @package Platine\Framework\OAuth2\Repository |
59 | 59 | */ |
60 | -class ScopeRepository extends Repository implements ScopeRepositoryInterface |
|
61 | -{ |
|
60 | +class ScopeRepository extends Repository implements ScopeRepositoryInterface { |
|
62 | 61 | /** |
63 | 62 | * Create new instance |
64 | 63 | * @param EntityManager $manager |
65 | 64 | */ |
66 | - public function __construct(EntityManager $manager) |
|
67 | - { |
|
65 | + public function __construct(EntityManager $manager) { |
|
68 | 66 | parent::__construct($manager, OauthScope::class); |
69 | 67 | } |
70 | 68 |
@@ -79,27 +79,27 @@ discard block |
||
79 | 79 | $this->clientService = $clientService; |
80 | 80 | } |
81 | 81 | |
82 | - /** |
|
83 | - * {@inheritdoc} |
|
84 | - */ |
|
82 | + /** |
|
83 | + * {@inheritdoc} |
|
84 | + */ |
|
85 | 85 | public function cleanExpiredTokens(): void |
86 | 86 | { |
87 | 87 | $this->query()->where('expires')->lte(date('Y-m-d H:i:s')) |
88 | - ->delete(); |
|
88 | + ->delete(); |
|
89 | 89 | } |
90 | 90 | |
91 | - /** |
|
92 | - * {@inheritdoc} |
|
93 | - */ |
|
91 | + /** |
|
92 | + * {@inheritdoc} |
|
93 | + */ |
|
94 | 94 | public function deleteToken(BaseToken $token): bool |
95 | 95 | { |
96 | 96 | return $this->query()->where('refresh_token')->is($token->getToken()) |
97 | - ->delete() >= 0; |
|
97 | + ->delete() >= 0; |
|
98 | 98 | } |
99 | 99 | |
100 | - /** |
|
101 | - * {@inheritdoc} |
|
102 | - */ |
|
100 | + /** |
|
101 | + * {@inheritdoc} |
|
102 | + */ |
|
103 | 103 | public function getByToken(string $token): ?BaseToken |
104 | 104 | { |
105 | 105 | $refreshToken = $this->find($token); |
@@ -121,17 +121,17 @@ discard block |
||
121 | 121 | ]); |
122 | 122 | } |
123 | 123 | |
124 | - /** |
|
125 | - * {@inheritdoc} |
|
126 | - */ |
|
124 | + /** |
|
125 | + * {@inheritdoc} |
|
126 | + */ |
|
127 | 127 | public function isTokenExists(string $token): bool |
128 | 128 | { |
129 | 129 | return $this->find($token) !== null; |
130 | 130 | } |
131 | 131 | |
132 | - /** |
|
133 | - * {@inheritdoc} |
|
134 | - */ |
|
132 | + /** |
|
133 | + * {@inheritdoc} |
|
134 | + */ |
|
135 | 135 | public function saveRefreshToken(RefreshToken $token): RefreshToken |
136 | 136 | { |
137 | 137 | $clientId = null; |
@@ -60,8 +60,7 @@ discard block |
||
60 | 60 | * @class RefreshTokenRepository |
61 | 61 | * @package Platine\Framework\OAuth2\Repository |
62 | 62 | */ |
63 | -class RefreshTokenRepository extends Repository implements RefreshTokenRepositoryInterface |
|
64 | -{ |
|
63 | +class RefreshTokenRepository extends Repository implements RefreshTokenRepositoryInterface { |
|
65 | 64 | /** |
66 | 65 | * The Client Service |
67 | 66 | * @var ClientService |
@@ -73,8 +72,7 @@ discard block |
||
73 | 72 | * @param EntityManager $manager |
74 | 73 | * @param ClientService $clientService |
75 | 74 | */ |
76 | - public function __construct(EntityManager $manager, ClientService $clientService) |
|
77 | - { |
|
75 | + public function __construct(EntityManager $manager, ClientService $clientService) { |
|
78 | 76 | parent::__construct($manager, OauthRefreshToken::class); |
79 | 77 | $this->clientService = $clientService; |
80 | 78 | } |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | public function cleanExpiredTokens(): void |
86 | 86 | { |
87 | 87 | $this->query()->where('expires')->lte(date('Y-m-d H:i:s')) |
88 | - ->delete(); |
|
88 | + ->delete(); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | /** |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | public function deleteToken(BaseToken $token): bool |
95 | 95 | { |
96 | 96 | return $this->query()->where('access_token')->is($token->getToken()) |
97 | - ->delete() >= 0; |
|
97 | + ->delete() >= 0; |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | /** |
@@ -60,8 +60,7 @@ discard block |
||
60 | 60 | * @class AccessTokenRepository |
61 | 61 | * @package Platine\Framework\OAuth2\Repository |
62 | 62 | */ |
63 | -class AccessTokenRepository extends Repository implements AccessTokenRepositoryInterface |
|
64 | -{ |
|
63 | +class AccessTokenRepository extends Repository implements AccessTokenRepositoryInterface { |
|
65 | 64 | /** |
66 | 65 | * The Client Service |
67 | 66 | * @var ClientService |
@@ -73,8 +72,7 @@ discard block |
||
73 | 72 | * @param EntityManager $manager |
74 | 73 | * @param ClientService $clientService |
75 | 74 | */ |
76 | - public function __construct(EntityManager $manager, ClientService $clientService) |
|
77 | - { |
|
75 | + public function __construct(EntityManager $manager, ClientService $clientService) { |
|
78 | 76 | parent::__construct($manager, OauthAccessToken::class); |
79 | 77 | $this->clientService = $clientService; |
80 | 78 | } |
@@ -14,16 +14,16 @@ |
||
14 | 14 | class OauthAuthorizationCode extends Entity |
15 | 15 | { |
16 | 16 | /** |
17 | - * {@inheritdoc} |
|
18 | - */ |
|
17 | + * {@inheritdoc} |
|
18 | + */ |
|
19 | 19 | public static function mapEntity(EntityMapperInterface $mapper): void |
20 | 20 | { |
21 | - $mapper->primaryKey('authorization_code'); |
|
22 | - $mapper->useTimestamp(); |
|
23 | - $mapper->casts([ |
|
21 | + $mapper->primaryKey('authorization_code'); |
|
22 | + $mapper->useTimestamp(); |
|
23 | + $mapper->casts([ |
|
24 | 24 | 'expires' => 'date', |
25 | 25 | 'created_at' => 'date', |
26 | 26 | 'updated_at' => '?date', |
27 | - ]); |
|
27 | + ]); |
|
28 | 28 | } |
29 | 29 | } |
@@ -11,8 +11,7 @@ |
||
11 | 11 | * @class OauthAuthorizationCode |
12 | 12 | * @package Platine\Framework\OAuth2\Entity |
13 | 13 | */ |
14 | -class OauthAuthorizationCode extends Entity |
|
15 | -{ |
|
14 | +class OauthAuthorizationCode extends Entity { |
|
16 | 15 | /** |
17 | 16 | * {@inheritdoc} |
18 | 17 | */ |