1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* The MIT License (MIT) |
7
|
|
|
* |
8
|
|
|
* Copyright (c) 2014-2017 Spomky-Labs |
9
|
|
|
* |
10
|
|
|
* This software may be modified and distributed under the terms |
11
|
|
|
* of the MIT license. See the LICENSE file for details. |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
namespace OAuth2Framework\Component\Server\Tests\Application; |
15
|
|
|
|
16
|
|
|
use Http\Client\HttpClient; |
17
|
|
|
use Http\Factory\Diactoros\ResponseFactory; |
18
|
|
|
use Http\Factory\Diactoros\ServerRequestFactory; |
19
|
|
|
use Http\Factory\Diactoros\UriFactory; |
20
|
|
|
use Http\Mock\Client; |
21
|
|
|
use Interop\Http\Factory\ResponseFactoryInterface; |
22
|
|
|
use Interop\Http\Factory\ServerRequestFactoryInterface; |
23
|
|
|
use Interop\Http\Factory\UriFactoryInterface; |
24
|
|
|
use Jose\Checker\CheckerManager; |
25
|
|
|
use Jose\Checker\CriticalHeaderChecker; |
26
|
|
|
use Jose\Checker\ExpirationTimeChecker; |
27
|
|
|
use Jose\Checker\IssuedAtChecker; |
28
|
|
|
use Jose\Checker\NotBeforeChecker; |
29
|
|
|
use Jose\Decrypter; |
30
|
|
|
use Jose\Encrypter; |
31
|
|
|
use Jose\Factory\JWKFactory; |
32
|
|
|
use Jose\JWTCreator; |
33
|
|
|
use Jose\JWTLoader; |
34
|
|
|
use Jose\Object\JWK; |
35
|
|
|
use Jose\Object\JWKSet; |
36
|
|
|
use Jose\Object\JWKSetInterface; |
37
|
|
|
use Jose\Object\JWKSets; |
38
|
|
|
use Jose\Object\StorableJWKSet; |
39
|
|
|
use Jose\Signer; |
40
|
|
|
use Jose\Verifier; |
41
|
|
|
use OAuth2Framework\Component\Server\Command\AccessToken\CreateAccessTokenCommand; |
42
|
|
|
use OAuth2Framework\Component\Server\Command\AccessToken\CreateAccessTokenCommandHandler; |
43
|
|
|
use OAuth2Framework\Component\Server\Command\AccessToken\CreateAccessTokenWithRefreshTokenCommand; |
44
|
|
|
use OAuth2Framework\Component\Server\Command\AccessToken\CreateAccessTokenWithRefreshTokenCommandHandler; |
45
|
|
|
use OAuth2Framework\Component\Server\Command\AccessToken\RevokeAccessTokenCommand; |
46
|
|
|
use OAuth2Framework\Component\Server\Command\AccessToken\RevokeAccessTokenCommandHandler; |
47
|
|
|
use OAuth2Framework\Component\Server\Command\AuthCode\CreateAuthCodeCommand; |
48
|
|
|
use OAuth2Framework\Component\Server\Command\AuthCode\CreateAuthCodeCommandHandler; |
49
|
|
|
use OAuth2Framework\Component\Server\Command\AuthCode\MarkAuthCodeAsUsedCommand; |
50
|
|
|
use OAuth2Framework\Component\Server\Command\AuthCode\MarkAuthCodeAsUsedCommandHandler; |
51
|
|
|
use OAuth2Framework\Component\Server\Command\AuthCode\RevokeAuthCodeCommand; |
52
|
|
|
use OAuth2Framework\Component\Server\Command\AuthCode\RevokeAuthCodeCommandHandler; |
53
|
|
|
use OAuth2Framework\Component\Server\Command\Client\CreateClientCommand; |
54
|
|
|
use OAuth2Framework\Component\Server\Command\Client\CreateClientCommandHandler; |
55
|
|
|
use OAuth2Framework\Component\Server\Command\Client\DeleteClientCommand; |
56
|
|
|
use OAuth2Framework\Component\Server\Command\Client\DeleteClientCommandHandler; |
57
|
|
|
use OAuth2Framework\Component\Server\Command\Client\UpdateClientCommand; |
58
|
|
|
use OAuth2Framework\Component\Server\Command\Client\UpdateClientCommandHandler; |
59
|
|
|
use OAuth2Framework\Component\Server\Command\RefreshToken\CreateRefreshTokenCommand; |
60
|
|
|
use OAuth2Framework\Component\Server\Command\RefreshToken\CreateRefreshTokenCommandHandler; |
61
|
|
|
use OAuth2Framework\Component\Server\Command\RefreshToken\RevokeRefreshTokenCommand; |
62
|
|
|
use OAuth2Framework\Component\Server\Command\RefreshToken\RevokeRefreshTokenCommandHandler; |
63
|
|
|
use OAuth2Framework\Component\Server\Command\ResourceServer\CreateResourceServerCommand; |
64
|
|
|
use OAuth2Framework\Component\Server\Command\ResourceServer\CreateResourceServerCommandHandler; |
65
|
|
|
use OAuth2Framework\Component\Server\Command\ResourceServer\DeleteResourceServerCommand; |
66
|
|
|
use OAuth2Framework\Component\Server\Command\ResourceServer\DeleteResourceServerCommandHandler; |
67
|
|
|
use OAuth2Framework\Component\Server\Command\ResourceServer\UpdateResourceServerCommand; |
68
|
|
|
use OAuth2Framework\Component\Server\Command\ResourceServer\UpdateResourceServerCommandHandler; |
69
|
|
|
use OAuth2Framework\Component\Server\Endpoint\Authorization\AfterConsentScreen\AfterConsentScreenManager; |
70
|
|
|
use OAuth2Framework\Component\Server\Endpoint\Authorization\AuthorizationFactory; |
71
|
|
|
use OAuth2Framework\Component\Server\Endpoint\Authorization\AuthorizationRequestLoader; |
72
|
|
|
use OAuth2Framework\Component\Server\Endpoint\Authorization\BeforeConsentScreen\BeforeConsentScreenManager; |
73
|
|
|
use OAuth2Framework\Component\Server\Endpoint\Authorization\BeforeConsentScreen\PreConfiguredAuthorizationExtension; |
74
|
|
|
use OAuth2Framework\Component\Server\Endpoint\Authorization\ParameterChecker\DisplayParameterChecker; |
75
|
|
|
use OAuth2Framework\Component\Server\Endpoint\Authorization\ParameterChecker\NonceParameterChecker; |
76
|
|
|
use OAuth2Framework\Component\Server\Endpoint\Authorization\ParameterChecker\ParameterCheckerManager; |
77
|
|
|
use OAuth2Framework\Component\Server\Endpoint\Authorization\ParameterChecker\PromptParameterChecker; |
78
|
|
|
use OAuth2Framework\Component\Server\Endpoint\Authorization\ParameterChecker\RedirectUriParameterChecker; |
79
|
|
|
use OAuth2Framework\Component\Server\Endpoint\Authorization\ParameterChecker\ResponseTypeAndResponseModeParameterChecker; |
80
|
|
|
use OAuth2Framework\Component\Server\Endpoint\Authorization\ParameterChecker\ScopeParameterChecker; |
81
|
|
|
use OAuth2Framework\Component\Server\Endpoint\Authorization\ParameterChecker\StateParameterChecker; |
82
|
|
|
use OAuth2Framework\Component\Server\Endpoint\Authorization\ParameterChecker\TokenTypeParameterChecker; |
83
|
|
|
use OAuth2Framework\Component\Server\Endpoint\Authorization\UserAccountDiscovery\IdTokenHintDiscovery; |
84
|
|
|
use OAuth2Framework\Component\Server\Endpoint\Authorization\UserAccountDiscovery\LoginParameterChecker; |
85
|
|
|
use OAuth2Framework\Component\Server\Endpoint\Authorization\UserAccountDiscovery\MaxAgeParameterChecker; |
86
|
|
|
use OAuth2Framework\Component\Server\Endpoint\Authorization\UserAccountDiscovery\PromptNoneParameterChecker; |
87
|
|
|
use OAuth2Framework\Component\Server\Endpoint\Authorization\UserAccountDiscovery\UserAccountDiscoveryManager; |
88
|
|
|
use OAuth2Framework\Component\Server\Endpoint\ClientConfiguration\ClientConfigurationEndpoint; |
89
|
|
|
use OAuth2Framework\Component\Server\Endpoint\ClientRegistration\ClientRegistrationEndpoint; |
90
|
|
|
use OAuth2Framework\Component\Server\Endpoint\IFrame\IFrameEndpoint; |
91
|
|
|
use OAuth2Framework\Component\Server\Endpoint\IssuerDiscovery\IssuerDiscoveryEndpoint; |
92
|
|
|
use OAuth2Framework\Component\Server\Endpoint\JWKSet\JWKSetEndpoint; |
93
|
|
|
use OAuth2Framework\Component\Server\Endpoint\Metadata\Metadata; |
94
|
|
|
use OAuth2Framework\Component\Server\Endpoint\Metadata\MetadataEndpoint; |
95
|
|
|
use OAuth2Framework\Component\Server\Endpoint\Token\Extension\OpenIdConnectExtension; |
96
|
|
|
use OAuth2Framework\Component\Server\Endpoint\Token\Processor\ProcessorManager; |
97
|
|
|
use OAuth2Framework\Component\Server\Endpoint\Token\TokenEndpoint; |
98
|
|
|
use OAuth2Framework\Component\Server\Endpoint\Token\TokenEndpointExtensionManager; |
99
|
|
|
use OAuth2Framework\Component\Server\Endpoint\TokenIntrospection\TokenIntrospectionEndpoint; |
100
|
|
|
use OAuth2Framework\Component\Server\Endpoint\TokenRevocation\TokenRevocationGetEndpoint; |
101
|
|
|
use OAuth2Framework\Component\Server\Endpoint\TokenRevocation\TokenRevocationPostEndpoint; |
102
|
|
|
use OAuth2Framework\Component\Server\Endpoint\UserInfo\ClaimSource\ClaimSourceManager; |
103
|
|
|
use OAuth2Framework\Component\Server\Endpoint\UserInfo\Pairwise\EncryptedSubjectIdentifier; |
104
|
|
|
use OAuth2Framework\Component\Server\Endpoint\UserInfo\Pairwise\PairwiseSubjectIdentifierAlgorithmInterface; |
105
|
|
|
use OAuth2Framework\Component\Server\Endpoint\UserInfo\ScopeSupport\AddressScopeSupport; |
106
|
|
|
use OAuth2Framework\Component\Server\Endpoint\UserInfo\ScopeSupport\EmailScopeSupport; |
107
|
|
|
use OAuth2Framework\Component\Server\Endpoint\UserInfo\ScopeSupport\PhoneScopeSupport; |
108
|
|
|
use OAuth2Framework\Component\Server\Endpoint\UserInfo\ScopeSupport\ProfilScopeSupport; |
109
|
|
|
use OAuth2Framework\Component\Server\Endpoint\UserInfo\ScopeSupport\UserInfoScopeSupportManager; |
110
|
|
|
use OAuth2Framework\Component\Server\Endpoint\UserInfo\UserInfo; |
111
|
|
|
use OAuth2Framework\Component\Server\Endpoint\UserInfo\UserInfoEndpoint; |
112
|
|
|
use OAuth2Framework\Component\Server\Event\AccessToken\AccessTokenCreatedEvent; |
113
|
|
|
use OAuth2Framework\Component\Server\Event\AccessToken\AccessTokenRevokedEvent; |
114
|
|
|
use OAuth2Framework\Component\Server\Event\AuthCode\AuthCodeCreatedEvent; |
115
|
|
|
use OAuth2Framework\Component\Server\Event\AuthCode\AuthCodeMarkedAsUsedEvent; |
116
|
|
|
use OAuth2Framework\Component\Server\Event\AuthCode\AuthCodeRevokedEvent; |
117
|
|
|
use OAuth2Framework\Component\Server\Event\Client\ClientCreatedEvent; |
118
|
|
|
use OAuth2Framework\Component\Server\Event\Client\ClientDeletedEvent; |
119
|
|
|
use OAuth2Framework\Component\Server\Event\Client\ClientParametersUpdatedEvent; |
120
|
|
|
use OAuth2Framework\Component\Server\Event\InitialAccessToken\InitialAccessTokenCreatedEvent; |
121
|
|
|
use OAuth2Framework\Component\Server\Event\InitialAccessToken\InitialAccessTokenRevokedEvent; |
122
|
|
|
use OAuth2Framework\Component\Server\Event\RefreshToken\RefreshTokenCreatedEvent; |
123
|
|
|
use OAuth2Framework\Component\Server\Event\RefreshToken\RefreshTokenRevokedEvent; |
124
|
|
|
use OAuth2Framework\Component\Server\GrantType\AuthorizationCodeGrantType; |
125
|
|
|
use OAuth2Framework\Component\Server\GrantType\ClientCredentialsGrantType; |
126
|
|
|
use OAuth2Framework\Component\Server\GrantType\GrantTypeManager; |
127
|
|
|
use OAuth2Framework\Component\Server\GrantType\JWTBearerGrantType; |
128
|
|
|
use OAuth2Framework\Component\Server\GrantType\PKCEMethod\PKCEMethodInterface; |
129
|
|
|
use OAuth2Framework\Component\Server\GrantType\PKCEMethod\PKCEMethodManager; |
130
|
|
|
use OAuth2Framework\Component\Server\GrantType\PKCEMethod\Plain; |
131
|
|
|
use OAuth2Framework\Component\Server\GrantType\PKCEMethod\S256; |
132
|
|
|
use OAuth2Framework\Component\Server\GrantType\RefreshTokenGrantType; |
133
|
|
|
use OAuth2Framework\Component\Server\GrantType\ResourceOwnerPasswordCredentialsGrantType; |
134
|
|
|
use OAuth2Framework\Component\Server\Middleware\ClientAuthenticationMiddleware; |
135
|
|
|
use OAuth2Framework\Component\Server\Middleware\GrantTypeMiddleware; |
136
|
|
|
use OAuth2Framework\Component\Server\Middleware\HttpMethod; |
137
|
|
|
use OAuth2Framework\Component\Server\Middleware\InitialAccessTokenMiddleware; |
138
|
|
|
use OAuth2Framework\Component\Server\Middleware\OAuth2ResponseMiddleware; |
139
|
|
|
use OAuth2Framework\Component\Server\Middleware\OAuth2SecurityMiddleware; |
140
|
|
|
use OAuth2Framework\Component\Server\Middleware\Pipe; |
141
|
|
|
use OAuth2Framework\Component\Server\Middleware\ResourceServerAuthenticationMiddleware; |
142
|
|
|
use OAuth2Framework\Component\Server\Middleware\TokenTypeMiddleware; |
143
|
|
|
use OAuth2Framework\Component\Server\Model\AccessToken\AccessTokenRepositoryInterface; |
144
|
|
|
use OAuth2Framework\Component\Server\Model\AuthCode\AuthCodeRepositoryInterface; |
145
|
|
|
use OAuth2Framework\Component\Server\Model\Client\Rule\CommonParametersRule; |
146
|
|
|
use OAuth2Framework\Component\Server\Model\Client\Rule\GrantTypeFlowRule; |
147
|
|
|
use OAuth2Framework\Component\Server\Model\Client\Rule\RedirectionUriRule; |
148
|
|
|
use OAuth2Framework\Component\Server\Model\Client\Rule\RuleManager; |
149
|
|
|
use OAuth2Framework\Component\Server\Model\Client\Rule\ScopeRule; |
150
|
|
|
use OAuth2Framework\Component\Server\Model\Client\Rule\SoftwareRule; |
151
|
|
|
use OAuth2Framework\Component\Server\Model\Client\Rule\SubjectTypeRule; |
152
|
|
|
use OAuth2Framework\Component\Server\Model\Client\Rule\TokenEndpointAuthMethodEndpointRule; |
153
|
|
|
use OAuth2Framework\Component\Server\Model\Event\EventStoreInterface; |
154
|
|
|
use OAuth2Framework\Component\Server\Model\IdToken\IdTokenBuilderFactory; |
155
|
|
|
use OAuth2Framework\Component\Server\Model\IdToken\IdTokenLoader; |
156
|
|
|
use OAuth2Framework\Component\Server\Model\InitialAccessToken\InitialAccessTokenRepositoryInterface; |
157
|
|
|
use OAuth2Framework\Component\Server\Model\RefreshToken\RefreshTokenRepositoryInterface; |
158
|
|
|
use OAuth2Framework\Component\Server\Model\Scope\DefaultScopePolicy; |
159
|
|
|
use OAuth2Framework\Component\Server\Model\Scope\ErrorScopePolicy; |
160
|
|
|
use OAuth2Framework\Component\Server\Model\Scope\ScopePolicyInterface; |
161
|
|
|
use OAuth2Framework\Component\Server\Model\Scope\ScopeRepositoryInterface; |
162
|
|
|
use OAuth2Framework\Component\Server\Model\UserAccount\UserAccountManagerInterface; |
163
|
|
|
use OAuth2Framework\Component\Server\Model\UserAccount\UserAccountRepositoryInterface; |
164
|
|
|
use OAuth2Framework\Component\Server\Response\Factory\AccessDeniedResponseFactory; |
165
|
|
|
use OAuth2Framework\Component\Server\Response\Factory\BadRequestResponseFactory; |
166
|
|
|
use OAuth2Framework\Component\Server\Response\Factory\MethodNotAllowedResponseFactory; |
167
|
|
|
use OAuth2Framework\Component\Server\Response\Factory\NotImplementedResponseFactory; |
168
|
|
|
use OAuth2Framework\Component\Server\Response\Factory\RedirectResponseFactory; |
169
|
|
|
use OAuth2Framework\Component\Server\Response\OAuth2ResponseFactoryManager; |
170
|
|
|
use OAuth2Framework\Component\Server\ResponseMode\FormPostResponseMode; |
171
|
|
|
use OAuth2Framework\Component\Server\ResponseMode\FragmentResponseMode; |
172
|
|
|
use OAuth2Framework\Component\Server\ResponseMode\QueryResponseMode; |
173
|
|
|
use OAuth2Framework\Component\Server\ResponseMode\ResponseModeManager; |
174
|
|
|
use OAuth2Framework\Component\Server\ResponseType\CodeResponseType; |
175
|
|
|
use OAuth2Framework\Component\Server\ResponseType\IdTokenResponseType; |
176
|
|
|
use OAuth2Framework\Component\Server\ResponseType\NoneResponseType; |
177
|
|
|
use OAuth2Framework\Component\Server\ResponseType\ResponseTypeManager; |
178
|
|
|
use OAuth2Framework\Component\Server\ResponseType\TokenResponseType; |
179
|
|
|
use OAuth2Framework\Component\Server\Schema\DomainConverter; |
180
|
|
|
use OAuth2Framework\Component\Server\Security\AccessTokenHandlerManager; |
181
|
|
|
use OAuth2Framework\Component\Server\Tests\Stub\AccessTokenHandlerUsingRepository; |
182
|
|
|
use OAuth2Framework\Component\Server\Tests\Stub\AccessTokenRepository; |
183
|
|
|
use OAuth2Framework\Component\Server\Tests\Stub\AuthCodeRepository; |
184
|
|
|
use OAuth2Framework\Component\Server\Tests\Stub\AuthenticateResponseFactory; |
185
|
|
|
use OAuth2Framework\Component\Server\Tests\Stub\AuthenticateResponseFactoryForTokenIntrospection; |
186
|
|
|
use OAuth2Framework\Component\Server\Tests\Stub\AuthorizationEndpoint; |
187
|
|
|
use OAuth2Framework\Component\Server\Tests\Stub\ClientAssertionJwt; |
188
|
|
|
use OAuth2Framework\Component\Server\Tests\Stub\ClientIdRule; |
189
|
|
|
use OAuth2Framework\Component\Server\Tests\Stub\ClientRegistrationManagementRule; |
190
|
|
|
use OAuth2Framework\Component\Server\Tests\Stub\ClientRepository; |
191
|
|
|
use OAuth2Framework\Component\Server\Tests\Stub\ClientSecretBasic; |
192
|
|
|
use OAuth2Framework\Component\Server\Tests\Stub\ClientSecretPost; |
193
|
|
|
use OAuth2Framework\Component\Server\Tests\Stub\Container; |
194
|
|
|
use OAuth2Framework\Component\Server\Tests\Stub\DistributedClaimSource; |
195
|
|
|
use OAuth2Framework\Component\Server\Tests\Stub\Event\AccessTokenCreatedEventHandler; |
196
|
|
|
use OAuth2Framework\Component\Server\Tests\Stub\Event\AccessTokenRevokedEventHandler; |
197
|
|
|
use OAuth2Framework\Component\Server\Tests\Stub\Event\AuthCodeCreatedEventHandler; |
198
|
|
|
use OAuth2Framework\Component\Server\Tests\Stub\Event\AuthCodeMarkedAsUsedEventHandler; |
199
|
|
|
use OAuth2Framework\Component\Server\Tests\Stub\Event\AuthCodeRevokedEventHandler; |
200
|
|
|
use OAuth2Framework\Component\Server\Tests\Stub\Event\ClientCreatedEventHandler; |
201
|
|
|
use OAuth2Framework\Component\Server\Tests\Stub\Event\ClientDeletedEventHandler; |
202
|
|
|
use OAuth2Framework\Component\Server\Tests\Stub\Event\ClientUpdatedEventHandler; |
203
|
|
|
use OAuth2Framework\Component\Server\Tests\Stub\Event\EventStore; |
204
|
|
|
use OAuth2Framework\Component\Server\Tests\Stub\Event\RefreshTokenCreatedEventHandler; |
205
|
|
|
use OAuth2Framework\Component\Server\Tests\Stub\Event\RefreshTokenRevokedEventHandler; |
206
|
|
|
use OAuth2Framework\Component\Server\Tests\Stub\FormPostResponseRenderer; |
207
|
|
|
use OAuth2Framework\Component\Server\Tests\Stub\InitialAccessTokenRepository; |
208
|
|
|
use OAuth2Framework\Component\Server\Tests\Stub\IpAddressMiddleware; |
209
|
|
|
use OAuth2Framework\Component\Server\Tests\Stub\MacToken; |
210
|
|
|
use OAuth2Framework\Component\Server\Tests\Stub\PreConfiguredAuthorizationRepository; |
211
|
|
|
use OAuth2Framework\Component\Server\Tests\Stub\RefreshTokenRepository; |
212
|
|
|
use OAuth2Framework\Component\Server\Tests\Stub\ResourceRepository; |
213
|
|
|
use OAuth2Framework\Component\Server\Tests\Stub\ResourceServerAuthMethodByIpAddress; |
214
|
|
|
use OAuth2Framework\Component\Server\Tests\Stub\ResourceServerRepository; |
215
|
|
|
use OAuth2Framework\Component\Server\Tests\Stub\ScopeRepository; |
216
|
|
|
use OAuth2Framework\Component\Server\Tests\Stub\SecurityLayer; |
217
|
|
|
use OAuth2Framework\Component\Server\Tests\Stub\ServiceLocator; |
218
|
|
|
use OAuth2Framework\Component\Server\Tests\Stub\SessionStateParameterExtension; |
219
|
|
|
use OAuth2Framework\Component\Server\Tests\Stub\SubjectChecker; |
220
|
|
|
use OAuth2Framework\Component\Server\Tests\Stub\TrustedIssuer; |
221
|
|
|
use OAuth2Framework\Component\Server\Tests\Stub\UriExtension; |
222
|
|
|
use OAuth2Framework\Component\Server\Tests\Stub\UserAccountManager; |
223
|
|
|
use OAuth2Framework\Component\Server\Tests\Stub\UserAccountRepository; |
224
|
|
|
use OAuth2Framework\Component\Server\TokenEndpointAuthMethod\None; |
225
|
|
|
use OAuth2Framework\Component\Server\TokenEndpointAuthMethod\TokenEndpointAuthMethodManager; |
226
|
|
|
use OAuth2Framework\Component\Server\TokenIntrospectionEndpointAuthMethod\TokenIntrospectionEndpointAuthMethodManager; |
227
|
|
|
use OAuth2Framework\Component\Server\TokenType\BearerToken; |
228
|
|
|
use OAuth2Framework\Component\Server\TokenType\TokenTypeManager; |
229
|
|
|
use OAuth2Framework\Component\Server\TokenTypeHint\AccessTokenTypeHint; |
230
|
|
|
use OAuth2Framework\Component\Server\TokenTypeHint\AuthCodeTypeHint; |
231
|
|
|
use OAuth2Framework\Component\Server\TokenTypeHint\RefreshTokenTypeHint; |
232
|
|
|
use OAuth2Framework\Component\Server\TokenTypeHint\TokenTypeHintManager; |
233
|
|
|
use SimpleBus\Message\Bus\Middleware\FinishesHandlingMessageBeforeHandlingNext; |
234
|
|
|
use SimpleBus\Message\Bus\Middleware\MessageBusSupportingMiddleware; |
235
|
|
|
use SimpleBus\Message\CallableResolver\CallableCollection; |
236
|
|
|
use SimpleBus\Message\CallableResolver\CallableMap; |
237
|
|
|
use SimpleBus\Message\CallableResolver\ServiceLocatorAwareCallableResolver; |
238
|
|
|
use SimpleBus\Message\Handler\DelegatesToMessageHandlerMiddleware; |
239
|
|
|
use SimpleBus\Message\Handler\Resolver\NameBasedMessageHandlerResolver; |
240
|
|
|
use SimpleBus\Message\Name\ClassBasedNameResolver; |
241
|
|
|
use SimpleBus\Message\Recorder\HandlesRecordedMessagesMiddleware; |
242
|
|
|
use SimpleBus\Message\Recorder\PublicMessageRecorder; |
243
|
|
|
use SimpleBus\Message\Subscriber\NotifiesMessageSubscribersMiddleware; |
244
|
|
|
use SimpleBus\Message\Subscriber\Resolver\NameBasedMessageSubscriberResolver; |
245
|
|
|
|
246
|
|
|
final class Application |
247
|
|
|
{ |
248
|
|
|
/** |
249
|
|
|
* @var string |
250
|
|
|
*/ |
251
|
|
|
private $pairwiseKey = 'This is my secret Key !!!'; |
252
|
|
|
/** |
253
|
|
|
* @var string |
254
|
|
|
*/ |
255
|
|
|
private $pairwiseAdditionalData = 'This is my salt or my IV !!!'; |
256
|
|
|
|
257
|
|
|
public function __construct() |
258
|
|
|
{ |
259
|
|
|
if (PHP_SESSION_ACTIVE !== session_status()) { |
260
|
|
|
session_start(); |
261
|
|
|
} |
262
|
|
|
} |
263
|
|
|
|
264
|
|
|
public function __destruct() |
265
|
|
|
{ |
266
|
|
|
if (PHP_SESSION_ACTIVE === session_status()) { |
267
|
|
|
session_destroy(); |
268
|
|
|
} |
269
|
|
|
|
270
|
|
|
foreach (['getPrivateECKeys', 'getPrivateRSAKeys', 'getPrivateNoneKeys'] as $method) { |
271
|
|
|
$keyset = $this->$method(); |
272
|
|
|
$keyset->delete(); |
273
|
|
|
} |
274
|
|
|
} |
275
|
|
|
|
276
|
|
|
/** |
277
|
|
|
* @return string |
278
|
|
|
*/ |
279
|
|
|
protected function getPairwiseKey() |
280
|
|
|
{ |
281
|
|
|
return $this->pairwiseKey; |
282
|
|
|
} |
283
|
|
|
|
284
|
|
|
/** |
285
|
|
|
* @return string |
286
|
|
|
*/ |
287
|
|
|
protected function getPairwiseAdditionalData() |
288
|
|
|
{ |
289
|
|
|
return mb_substr($this->pairwiseAdditionalData, 0, 16, '8bit'); |
290
|
|
|
} |
291
|
|
|
|
292
|
|
|
/** |
293
|
|
|
* @var null|OAuth2ResponseFactoryManager |
294
|
|
|
*/ |
295
|
|
|
private $oauth2ResponseFactory = null; |
296
|
|
|
|
297
|
|
|
/** |
298
|
|
|
* @var null|OAuth2ResponseMiddleware |
299
|
|
|
*/ |
300
|
|
|
private $oauth2ResponseMiddleware = null; |
301
|
|
|
|
302
|
|
|
/** |
303
|
|
|
* @return OAuth2ResponseFactoryManager |
304
|
|
|
*/ |
305
|
|
|
public function getOAuth2ResponseFactory(): OAuth2ResponseFactoryManager |
306
|
|
|
{ |
307
|
|
|
if (null === $this->oauth2ResponseFactory) { |
308
|
|
|
$this->oauth2ResponseFactory = new OAuth2ResponseFactoryManager($this->getResponseFactory()); |
309
|
|
|
$this->oauth2ResponseFactory->addExtension(new UriExtension()); |
310
|
|
|
|
311
|
|
|
$this->oauth2ResponseFactory->addResponseFactory(new AuthenticateResponseFactory( |
312
|
|
|
$this->getTokenEndpointAuthMethodManager() |
313
|
|
|
)); |
314
|
|
|
$this->oauth2ResponseFactory->addResponseFactory(new AccessDeniedResponseFactory()); |
315
|
|
|
$this->oauth2ResponseFactory->addResponseFactory(new BadRequestResponseFactory()); |
316
|
|
|
$this->oauth2ResponseFactory->addResponseFactory(new MethodNotAllowedResponseFactory()); |
317
|
|
|
$this->oauth2ResponseFactory->addResponseFactory(new NotImplementedResponseFactory()); |
318
|
|
|
$this->oauth2ResponseFactory->addResponseFactory(new RedirectResponseFactory()); |
319
|
|
|
} |
320
|
|
|
|
321
|
|
|
return $this->oauth2ResponseFactory; |
322
|
|
|
} |
323
|
|
|
|
324
|
|
|
/** |
325
|
|
|
* @return OAuth2ResponseFactoryManager |
326
|
|
|
*/ |
327
|
|
|
public function getOAuth2ResponseFactoryForTokenIntrospection(): OAuth2ResponseFactoryManager |
328
|
|
|
{ |
329
|
|
|
if (null === $this->oauth2ResponseFactory) { |
330
|
|
|
$this->oauth2ResponseFactory = new OAuth2ResponseFactoryManager($this->getResponseFactory()); |
331
|
|
|
$this->oauth2ResponseFactory->addResponseFactory(new AuthenticateResponseFactoryForTokenIntrospection( |
332
|
|
|
$this->getTokenIntrospectionEndpointAuthMethodManager() |
333
|
|
|
)); |
334
|
|
|
$this->oauth2ResponseFactory->addResponseFactory(new BadRequestResponseFactory()); |
335
|
|
|
} |
336
|
|
|
|
337
|
|
|
return $this->oauth2ResponseFactory; |
338
|
|
|
} |
339
|
|
|
|
340
|
|
|
/** |
341
|
|
|
* @return OAuth2ResponseMiddleware |
342
|
|
|
*/ |
343
|
|
|
public function getOAuth2ResponseMiddleware(): OAuth2ResponseMiddleware |
344
|
|
|
{ |
345
|
|
|
if (null === $this->oauth2ResponseMiddleware) { |
346
|
|
|
$this->oauth2ResponseMiddleware = new OAuth2ResponseMiddleware( |
347
|
|
|
$this->getOAuth2ResponseFactory() |
348
|
|
|
); |
349
|
|
|
} |
350
|
|
|
|
351
|
|
|
return $this->oauth2ResponseMiddleware; |
352
|
|
|
} |
353
|
|
|
|
354
|
|
|
/** |
355
|
|
|
* @var null|ClientRepository |
356
|
|
|
*/ |
357
|
|
|
private $clientRepository = null; |
358
|
|
|
|
359
|
|
|
/** |
360
|
|
|
* @return ClientRepository |
361
|
|
|
*/ |
362
|
|
|
public function getClientRepository(): ClientRepository |
363
|
|
|
{ |
364
|
|
|
if (null === $this->clientRepository) { |
365
|
|
|
$this->clientRepository = new ClientRepository( |
366
|
|
|
$this->getClientEventStore(), |
367
|
|
|
$this->getPublicMessageRecorder() |
368
|
|
|
); |
369
|
|
|
} |
370
|
|
|
|
371
|
|
|
return $this->clientRepository; |
372
|
|
|
} |
373
|
|
|
|
374
|
|
|
/** |
375
|
|
|
* @var null|ResourceServerRepository |
376
|
|
|
*/ |
377
|
|
|
private $resourceServerRepository = null; |
378
|
|
|
|
379
|
|
|
/** |
380
|
|
|
* @return ResourceServerRepository |
381
|
|
|
*/ |
382
|
|
|
public function getResourceServerRepository(): ResourceServerRepository |
383
|
|
|
{ |
384
|
|
|
if (null === $this->resourceServerRepository) { |
385
|
|
|
$this->resourceServerRepository = new ResourceServerRepository( |
386
|
|
|
$this->getResourceServerEventStore(), |
387
|
|
|
$this->getPublicMessageRecorder() |
388
|
|
|
); |
389
|
|
|
} |
390
|
|
|
|
391
|
|
|
return $this->resourceServerRepository; |
392
|
|
|
} |
393
|
|
|
|
394
|
|
|
/** |
395
|
|
|
* @var null|ClientRegistrationEndpoint |
396
|
|
|
*/ |
397
|
|
|
private $clientRegistrationEndpoint = null; |
398
|
|
|
|
399
|
|
|
/** |
400
|
|
|
* @return ClientRegistrationEndpoint |
401
|
|
|
*/ |
402
|
|
|
public function getClientRegistrationEndpoint(): ClientRegistrationEndpoint |
403
|
|
|
{ |
404
|
|
|
if (null === $this->clientRegistrationEndpoint) { |
405
|
|
|
$this->clientRegistrationEndpoint = new ClientRegistrationEndpoint( |
406
|
|
|
$this->getResponseFactory(), |
407
|
|
|
$this->getCommandBus() |
408
|
|
|
); |
409
|
|
|
} |
410
|
|
|
|
411
|
|
|
return $this->clientRegistrationEndpoint; |
412
|
|
|
} |
413
|
|
|
|
414
|
|
|
/** |
415
|
|
|
* @var null|Pipe |
416
|
|
|
*/ |
417
|
|
|
private $clientRegistrationPipe = null; |
418
|
|
|
|
419
|
|
|
/** |
420
|
|
|
* @return Pipe |
421
|
|
|
*/ |
422
|
|
|
public function getClientRegistrationPipe(): Pipe |
423
|
|
|
{ |
424
|
|
|
if (null === $this->clientRegistrationPipe) { |
425
|
|
|
$this->clientRegistrationPipe = new Pipe(); |
426
|
|
|
|
427
|
|
|
$this->clientRegistrationPipe->appendMiddleware($this->getOAuth2ResponseMiddleware()); |
428
|
|
|
$this->clientRegistrationPipe->appendMiddleware($this->getInitialAccessTokenMiddleware()); |
429
|
|
|
$this->clientRegistrationPipe->appendMiddleware($this->getClientRegistrationEndpoint()); |
430
|
|
|
} |
431
|
|
|
|
432
|
|
|
return $this->clientRegistrationPipe; |
433
|
|
|
} |
434
|
|
|
|
435
|
|
|
/** |
436
|
|
|
* @var null|ClientAuthenticationMiddleware |
437
|
|
|
*/ |
438
|
|
|
private $clientAuthenticationMiddleware = null; |
439
|
|
|
|
440
|
|
|
/** |
441
|
|
|
* @return ClientAuthenticationMiddleware |
442
|
|
|
*/ |
443
|
|
|
public function getClientAuthenticationMiddleware(): ClientAuthenticationMiddleware |
444
|
|
|
{ |
445
|
|
|
if (null === $this->clientAuthenticationMiddleware) { |
446
|
|
|
$this->clientAuthenticationMiddleware = new ClientAuthenticationMiddleware( |
447
|
|
|
$this->getClientRepository(), |
448
|
|
|
$this->getTokenEndpointAuthMethodManager(), |
449
|
|
|
false |
450
|
|
|
); |
451
|
|
|
} |
452
|
|
|
|
453
|
|
|
return $this->clientAuthenticationMiddleware; |
454
|
|
|
} |
455
|
|
|
|
456
|
|
|
/** |
457
|
|
|
* @var null|ResourceServerAuthenticationMiddleware |
458
|
|
|
*/ |
459
|
|
|
private $resourceServerAuthenticationMiddleware = null; |
460
|
|
|
|
461
|
|
|
/** |
462
|
|
|
* @return ResourceServerAuthenticationMiddleware |
463
|
|
|
*/ |
464
|
|
|
public function getResourceServerAuthenticationMiddleware(): ResourceServerAuthenticationMiddleware |
465
|
|
|
{ |
466
|
|
|
if (null === $this->resourceServerAuthenticationMiddleware) { |
467
|
|
|
$this->resourceServerAuthenticationMiddleware = new ResourceServerAuthenticationMiddleware( |
468
|
|
|
$this->getResourceServerRepository(), |
469
|
|
|
$this->getTokenIntrospectionEndpointAuthMethodManager() |
470
|
|
|
); |
471
|
|
|
} |
472
|
|
|
|
473
|
|
|
return $this->resourceServerAuthenticationMiddleware; |
474
|
|
|
} |
475
|
|
|
|
476
|
|
|
/** |
477
|
|
|
* @var null|ClientAuthenticationMiddleware |
478
|
|
|
*/ |
479
|
|
|
private $clientAuthenticationMiddlewareWithRequirement = null; |
480
|
|
|
|
481
|
|
|
/** |
482
|
|
|
* @return ClientAuthenticationMiddleware |
483
|
|
|
*/ |
484
|
|
|
public function getClientAuthenticationMiddlewareWithRequirement(): ClientAuthenticationMiddleware |
485
|
|
|
{ |
486
|
|
|
if (null === $this->clientAuthenticationMiddlewareWithRequirement) { |
487
|
|
|
$this->clientAuthenticationMiddlewareWithRequirement = new ClientAuthenticationMiddleware( |
488
|
|
|
$this->getClientRepository(), |
489
|
|
|
$this->getTokenEndpointAuthMethodManager(), |
490
|
|
|
true |
491
|
|
|
); |
492
|
|
|
} |
493
|
|
|
|
494
|
|
|
return $this->clientAuthenticationMiddlewareWithRequirement; |
495
|
|
|
} |
496
|
|
|
|
497
|
|
|
/** |
498
|
|
|
* @var null|TokenEndpointAuthMethodManager |
499
|
|
|
*/ |
500
|
|
|
private $tokenEndpointAuthMethodManager = null; |
501
|
|
|
|
502
|
|
|
/** |
503
|
|
|
* @return TokenEndpointAuthMethodManager |
504
|
|
|
*/ |
505
|
|
|
public function getTokenEndpointAuthMethodManager(): TokenEndpointAuthMethodManager |
506
|
|
|
{ |
507
|
|
|
if (null === $this->tokenEndpointAuthMethodManager) { |
508
|
|
|
$this->tokenEndpointAuthMethodManager = new TokenEndpointAuthMethodManager(); |
509
|
|
|
$this->tokenEndpointAuthMethodManager->addTokenEndpointAuthMethod(new None()); |
510
|
|
|
$this->tokenEndpointAuthMethodManager->addTokenEndpointAuthMethod(new ClientSecretBasic('My service')); |
511
|
|
|
$this->tokenEndpointAuthMethodManager->addTokenEndpointAuthMethod(new ClientSecretPost()); |
512
|
|
|
$this->tokenEndpointAuthMethodManager->addTokenEndpointAuthMethod(new ClientAssertionJwt( |
513
|
|
|
$this->getJwtLoader() |
514
|
|
|
)); |
515
|
|
|
} |
516
|
|
|
|
517
|
|
|
return $this->tokenEndpointAuthMethodManager; |
518
|
|
|
} |
519
|
|
|
|
520
|
|
|
/** |
521
|
|
|
* @var null|TokenIntrospectionEndpointAuthMethodManager |
522
|
|
|
*/ |
523
|
|
|
private $tokenIntrospectionEndpointAuthMethodManager = null; |
524
|
|
|
|
525
|
|
|
/** |
526
|
|
|
* @return TokenIntrospectionEndpointAuthMethodManager |
527
|
|
|
*/ |
528
|
|
|
public function getTokenIntrospectionEndpointAuthMethodManager(): TokenIntrospectionEndpointAuthMethodManager |
529
|
|
|
{ |
530
|
|
|
if (null === $this->tokenIntrospectionEndpointAuthMethodManager) { |
531
|
|
|
$this->tokenIntrospectionEndpointAuthMethodManager = new TokenIntrospectionEndpointAuthMethodManager(); |
532
|
|
|
$this->tokenIntrospectionEndpointAuthMethodManager->addTokenIntrospectionEndpointAuthMethod(new ResourceServerAuthMethodByIpAddress()); |
533
|
|
|
} |
534
|
|
|
|
535
|
|
|
return $this->tokenIntrospectionEndpointAuthMethodManager; |
536
|
|
|
} |
537
|
|
|
|
538
|
|
|
/** |
539
|
|
|
* @var null|AuthCodeCreatedEventHandler |
540
|
|
|
*/ |
541
|
|
|
private $authCodeCreatedEventHandler = null; |
542
|
|
|
|
543
|
|
|
/** |
544
|
|
|
* @return AuthCodeCreatedEventHandler |
545
|
|
|
*/ |
546
|
|
|
public function getAuthCodeCreatedEventHandler(): AuthCodeCreatedEventHandler |
547
|
|
|
{ |
548
|
|
|
if (null === $this->authCodeCreatedEventHandler) { |
549
|
|
|
$this->authCodeCreatedEventHandler = new AuthCodeCreatedEventHandler(); |
550
|
|
|
} |
551
|
|
|
|
552
|
|
|
return $this->authCodeCreatedEventHandler; |
553
|
|
|
} |
554
|
|
|
|
555
|
|
|
/** |
556
|
|
|
* @var null|AuthCodeMarkedAsUsedEventHandler |
557
|
|
|
*/ |
558
|
|
|
private $authCodeMarkedAsUsedEventHandler = null; |
559
|
|
|
|
560
|
|
|
/** |
561
|
|
|
* @return AuthCodeMarkedAsUsedEventHandler |
562
|
|
|
*/ |
563
|
|
|
public function getAuthCodeMarkedAsUsedEventHandler(): AuthCodeMarkedAsUsedEventHandler |
564
|
|
|
{ |
565
|
|
|
if (null === $this->authCodeMarkedAsUsedEventHandler) { |
566
|
|
|
$this->authCodeMarkedAsUsedEventHandler = new AuthCodeMarkedAsUsedEventHandler(); |
567
|
|
|
} |
568
|
|
|
|
569
|
|
|
return $this->authCodeMarkedAsUsedEventHandler; |
570
|
|
|
} |
571
|
|
|
|
572
|
|
|
/** |
573
|
|
|
* @var null|AuthCodeRevokedEventHandler |
574
|
|
|
*/ |
575
|
|
|
private $authCodeRevokedEventHandler = null; |
576
|
|
|
|
577
|
|
|
/** |
578
|
|
|
* @return AuthCodeRevokedEventHandler |
579
|
|
|
*/ |
580
|
|
|
public function getAuthCodeRevokedEventHandler(): AuthCodeRevokedEventHandler |
581
|
|
|
{ |
582
|
|
|
if (null === $this->authCodeRevokedEventHandler) { |
583
|
|
|
$this->authCodeRevokedEventHandler = new AuthCodeRevokedEventHandler(); |
584
|
|
|
} |
585
|
|
|
|
586
|
|
|
return $this->authCodeRevokedEventHandler; |
587
|
|
|
} |
588
|
|
|
|
589
|
|
|
/** |
590
|
|
|
* @var null|ClientCreatedEventHandler |
591
|
|
|
*/ |
592
|
|
|
private $clientCreatedEventHandler = null; |
593
|
|
|
|
594
|
|
|
/** |
595
|
|
|
* @return ClientCreatedEventHandler |
596
|
|
|
*/ |
597
|
|
|
public function getClientCreatedEventHandler(): ClientCreatedEventHandler |
598
|
|
|
{ |
599
|
|
|
if (null === $this->clientCreatedEventHandler) { |
600
|
|
|
$this->clientCreatedEventHandler = new ClientCreatedEventHandler( |
601
|
|
|
$this->getClientRepository() |
602
|
|
|
); |
603
|
|
|
} |
604
|
|
|
|
605
|
|
|
return $this->clientCreatedEventHandler; |
606
|
|
|
} |
607
|
|
|
|
608
|
|
|
/** |
609
|
|
|
* @var null|ClientDeletedEventHandler |
610
|
|
|
*/ |
611
|
|
|
private $clientDeletedEventHandler = null; |
612
|
|
|
|
613
|
|
|
/** |
614
|
|
|
* @return ClientDeletedEventHandler |
615
|
|
|
*/ |
616
|
|
|
public function getClientDeletedEventHandler(): ClientDeletedEventHandler |
617
|
|
|
{ |
618
|
|
|
if (null === $this->clientDeletedEventHandler) { |
619
|
|
|
$this->clientDeletedEventHandler = new ClientDeletedEventHandler(); |
620
|
|
|
} |
621
|
|
|
|
622
|
|
|
return $this->clientDeletedEventHandler; |
623
|
|
|
} |
624
|
|
|
|
625
|
|
|
/** |
626
|
|
|
* @var null|ClientUpdatedEventHandler |
627
|
|
|
*/ |
628
|
|
|
private $clientUpdatedEventHandler = null; |
629
|
|
|
|
630
|
|
|
/** |
631
|
|
|
* @return ClientUpdatedEventHandler |
632
|
|
|
*/ |
633
|
|
|
public function getClientUpdatedEventHandler(): ClientUpdatedEventHandler |
634
|
|
|
{ |
635
|
|
|
if (null === $this->clientUpdatedEventHandler) { |
636
|
|
|
$this->clientUpdatedEventHandler = new ClientUpdatedEventHandler(); |
637
|
|
|
} |
638
|
|
|
|
639
|
|
|
return $this->clientUpdatedEventHandler; |
640
|
|
|
} |
641
|
|
|
|
642
|
|
|
/** |
643
|
|
|
* @var null|MessageBusSupportingMiddleware |
644
|
|
|
*/ |
645
|
|
|
private $commandBus = null; |
646
|
|
|
|
647
|
|
|
/** |
648
|
|
|
* @return MessageBusSupportingMiddleware |
649
|
|
|
*/ |
650
|
|
|
public function getCommandBus(): MessageBusSupportingMiddleware |
651
|
|
|
{ |
652
|
|
|
if (null === $this->commandBus) { |
653
|
|
|
$this->commandBus = new MessageBusSupportingMiddleware(); |
654
|
|
|
$this->commandBus->appendMiddleware(new HandlesRecordedMessagesMiddleware( |
655
|
|
|
$this->getPublicMessageRecorder(), |
656
|
|
|
$this->getEventBus() |
657
|
|
|
)); |
658
|
|
|
$this->commandBus->appendMiddleware(new FinishesHandlingMessageBeforeHandlingNext()); |
659
|
|
|
$this->commandBus->appendMiddleware(new DelegatesToMessageHandlerMiddleware( |
660
|
|
|
$this->getCommandHandlerResolver() |
661
|
|
|
)); |
662
|
|
|
} |
663
|
|
|
|
664
|
|
|
return $this->commandBus; |
665
|
|
|
} |
666
|
|
|
|
667
|
|
|
/** |
668
|
|
|
* @var null|CallableMap |
669
|
|
|
*/ |
670
|
|
|
private $commandHandlerMap = null; |
671
|
|
|
|
672
|
|
|
/** |
673
|
|
|
* @return CallableMap |
674
|
|
|
*/ |
675
|
|
|
public function getCommandHandlerMap(): CallableMap |
676
|
|
|
{ |
677
|
|
|
if (null === $this->commandHandlerMap) { |
678
|
|
|
$this->commandHandlerMap = new CallableMap( |
679
|
|
|
[ |
680
|
|
|
CreateClientCommand::class => CreateClientCommandHandler::class, |
681
|
|
|
DeleteClientCommand::class => DeleteClientCommandHandler::class, |
682
|
|
|
UpdateClientCommand::class => UpdateClientCommandHandler::class, |
683
|
|
|
CreateResourceServerCommand::class => CreateResourceServerCommandHandler::class, |
684
|
|
|
DeleteResourceServerCommand::class => DeleteResourceServerCommandHandler::class, |
685
|
|
|
UpdateResourceServerCommand::class => UpdateResourceServerCommandHandler::class, |
686
|
|
|
CreateAccessTokenCommand::class => CreateAccessTokenCommandHandler::class, |
687
|
|
|
CreateAccessTokenWithRefreshTokenCommand::class => CreateAccessTokenWithRefreshTokenCommandHandler::class, |
688
|
|
|
RevokeAccessTokenCommand::class => RevokeAccessTokenCommandHandler::class, |
689
|
|
|
|
690
|
|
|
CreateRefreshTokenCommand::class => CreateRefreshTokenCommandHandler::class, |
691
|
|
|
RevokeRefreshTokenCommand::class => RevokeRefreshTokenCommandHandler::class, |
692
|
|
|
|
693
|
|
|
CreateAuthCodeCommand::class => CreateAuthCodeCommandHandler::class, |
694
|
|
|
MarkAuthCodeAsUsedCommand::class => MarkAuthCodeAsUsedCommandHandler::class, |
695
|
|
|
RevokeAuthCodeCommand::class => RevokeAuthCodeCommandHandler::class, |
696
|
|
|
], |
697
|
|
|
$this->getServiceLocatorAwareCallableResolver() |
698
|
|
|
); |
699
|
|
|
} |
700
|
|
|
|
701
|
|
|
return $this->commandHandlerMap; |
702
|
|
|
} |
703
|
|
|
|
704
|
|
|
/** |
705
|
|
|
* @var null|NameBasedMessageHandlerResolver |
706
|
|
|
*/ |
707
|
|
|
private $commandHandlerResolver = null; |
708
|
|
|
|
709
|
|
|
/** |
710
|
|
|
* @return NameBasedMessageHandlerResolver |
711
|
|
|
*/ |
712
|
|
|
public function getCommandHandlerResolver(): NameBasedMessageHandlerResolver |
713
|
|
|
{ |
714
|
|
|
if (null === $this->commandHandlerResolver) { |
715
|
|
|
$this->commandHandlerResolver = new NameBasedMessageHandlerResolver( |
716
|
|
|
new ClassBasedNameResolver(), |
717
|
|
|
$this->getCommandHandlerMap() |
718
|
|
|
); |
719
|
|
|
} |
720
|
|
|
|
721
|
|
|
return $this->commandHandlerResolver; |
722
|
|
|
} |
723
|
|
|
|
724
|
|
|
/** |
725
|
|
|
* @var null|Container |
726
|
|
|
*/ |
727
|
|
|
private $container = null; |
728
|
|
|
|
729
|
|
|
/** |
730
|
|
|
* @return Container |
731
|
|
|
*/ |
732
|
|
|
public function getContainer(): Container |
733
|
|
|
{ |
734
|
|
|
if (null === $this->container) { |
735
|
|
|
$this->container = new Container(); |
736
|
|
|
|
737
|
|
|
$this->container->add($this->getCreateClientCommandHandler()); |
738
|
|
|
$this->container->add($this->getDeleteClientCommandHandler()); |
739
|
|
|
$this->container->add($this->getUpdateClientCommandHandler()); |
740
|
|
|
|
741
|
|
|
$this->container->add($this->getCreateResourceServerCommandHandler()); |
742
|
|
|
$this->container->add($this->getDeleteResourceServerCommandHandler()); |
743
|
|
|
$this->container->add($this->getUpdateResourceServerCommandHandler()); |
744
|
|
|
|
745
|
|
|
$this->container->add($this->getCreateAccessTokenCommandHandler()); |
746
|
|
|
$this->container->add($this->getCreateAccessTokenWithRefreshTokenCommandHandler()); |
747
|
|
|
$this->container->add($this->getRevokeAccessTokenCommandHandler()); |
748
|
|
|
|
749
|
|
|
$this->container->add($this->getCreateRefreshTokenCommandHandler()); |
750
|
|
|
$this->container->add($this->getRevokeRefreshTokenCommandHandler()); |
751
|
|
|
|
752
|
|
|
$this->container->add($this->getCreateAuthCodeCommandHandler()); |
753
|
|
|
$this->container->add($this->getMarkAuthCodeAsUsedCommandHandler()); |
754
|
|
|
$this->container->add($this->getRevokeAuthCodeCommandHandler()); |
755
|
|
|
|
756
|
|
|
$this->container->add($this->getClientCreatedEventHandler()); |
757
|
|
|
$this->container->add($this->getClientDeletedEventHandler()); |
758
|
|
|
$this->container->add($this->getClientUpdatedEventHandler()); |
759
|
|
|
|
760
|
|
|
$this->container->add($this->getAuthCodeCreatedEventHandler()); |
761
|
|
|
$this->container->add($this->getAuthCodeMarkedAsUsedEventHandler()); |
762
|
|
|
$this->container->add($this->getAuthCodeRevokedEventHandler()); |
763
|
|
|
|
764
|
|
|
$this->container->add($this->getAccessTokenRevokedEventHandler()); |
765
|
|
|
$this->container->add($this->getAccessTokenCreatedEventHandler()); |
766
|
|
|
|
767
|
|
|
$this->container->add($this->getRefreshTokenCreatedEventHandler()); |
768
|
|
|
$this->container->add($this->getRefreshTokenRevokedEventHandler()); |
769
|
|
|
} |
770
|
|
|
|
771
|
|
|
return $this->container; |
772
|
|
|
} |
773
|
|
|
|
774
|
|
|
/** |
775
|
|
|
* @var null|CreateClientCommandHandler |
776
|
|
|
*/ |
777
|
|
|
private $createClientCommandHandler = null; |
778
|
|
|
|
779
|
|
|
/** |
780
|
|
|
* @return CreateClientCommandHandler |
781
|
|
|
*/ |
782
|
|
|
public function getCreateClientCommandHandler(): CreateClientCommandHandler |
783
|
|
|
{ |
784
|
|
|
if (null === $this->createClientCommandHandler) { |
785
|
|
|
$this->createClientCommandHandler = new CreateClientCommandHandler( |
786
|
|
|
$this->getClientRepository(), |
787
|
|
|
$this->getRuleManager() |
788
|
|
|
); |
789
|
|
|
} |
790
|
|
|
|
791
|
|
|
return $this->createClientCommandHandler; |
792
|
|
|
} |
793
|
|
|
|
794
|
|
|
/** |
795
|
|
|
* @var null|DeleteClientCommandHandler |
796
|
|
|
*/ |
797
|
|
|
private $deleteClientCommandHandler = null; |
798
|
|
|
|
799
|
|
|
/** |
800
|
|
|
* @return DeleteClientCommandHandler |
801
|
|
|
*/ |
802
|
|
|
public function getDeleteClientCommandHandler(): DeleteClientCommandHandler |
803
|
|
|
{ |
804
|
|
|
if (null === $this->deleteClientCommandHandler) { |
805
|
|
|
$this->deleteClientCommandHandler = new DeleteClientCommandHandler( |
806
|
|
|
$this->getClientRepository() |
807
|
|
|
); |
808
|
|
|
} |
809
|
|
|
|
810
|
|
|
return $this->deleteClientCommandHandler; |
811
|
|
|
} |
812
|
|
|
|
813
|
|
|
/** |
814
|
|
|
* @var null|UpdateClientCommandHandler |
815
|
|
|
*/ |
816
|
|
|
private $updateClientCommandHandler = null; |
817
|
|
|
|
818
|
|
|
/** |
819
|
|
|
* @return UpdateClientCommandHandler |
820
|
|
|
*/ |
821
|
|
|
public function getUpdateClientCommandHandler(): UpdateClientCommandHandler |
822
|
|
|
{ |
823
|
|
|
if (null === $this->updateClientCommandHandler) { |
824
|
|
|
$this->updateClientCommandHandler = new UpdateClientCommandHandler( |
825
|
|
|
$this->getClientRepository(), |
826
|
|
|
$this->getRuleManager() |
827
|
|
|
); |
828
|
|
|
} |
829
|
|
|
|
830
|
|
|
return $this->updateClientCommandHandler; |
831
|
|
|
} |
832
|
|
|
|
833
|
|
|
/** |
834
|
|
|
* @var null|CreateResourceServerCommandHandler |
835
|
|
|
*/ |
836
|
|
|
private $createResourceServerCommandHandler = null; |
837
|
|
|
|
838
|
|
|
/** |
839
|
|
|
* @return CreateResourceServerCommandHandler |
840
|
|
|
*/ |
841
|
|
|
public function getCreateResourceServerCommandHandler(): CreateResourceServerCommandHandler |
842
|
|
|
{ |
843
|
|
|
if (null === $this->createResourceServerCommandHandler) { |
844
|
|
|
$this->createResourceServerCommandHandler = new CreateResourceServerCommandHandler( |
845
|
|
|
$this->getResourceServerRepository() |
846
|
|
|
); |
847
|
|
|
} |
848
|
|
|
|
849
|
|
|
return $this->createResourceServerCommandHandler; |
850
|
|
|
} |
851
|
|
|
|
852
|
|
|
/** |
853
|
|
|
* @var null|DeleteResourceServerCommandHandler |
854
|
|
|
*/ |
855
|
|
|
private $deleteResourceServerCommandHandler = null; |
856
|
|
|
|
857
|
|
|
/** |
858
|
|
|
* @return DeleteResourceServerCommandHandler |
859
|
|
|
*/ |
860
|
|
|
public function getDeleteResourceServerCommandHandler(): DeleteResourceServerCommandHandler |
861
|
|
|
{ |
862
|
|
|
if (null === $this->deleteResourceServerCommandHandler) { |
863
|
|
|
$this->deleteResourceServerCommandHandler = new DeleteResourceServerCommandHandler( |
864
|
|
|
$this->getResourceServerRepository() |
865
|
|
|
); |
866
|
|
|
} |
867
|
|
|
|
868
|
|
|
return $this->deleteResourceServerCommandHandler; |
869
|
|
|
} |
870
|
|
|
|
871
|
|
|
/** |
872
|
|
|
* @var null|UpdateResourceServerCommandHandler |
873
|
|
|
*/ |
874
|
|
|
private $updateResourceServerCommandHandler = null; |
875
|
|
|
|
876
|
|
|
/** |
877
|
|
|
* @return UpdateResourceServerCommandHandler |
878
|
|
|
*/ |
879
|
|
|
public function getUpdateResourceServerCommandHandler(): UpdateResourceServerCommandHandler |
880
|
|
|
{ |
881
|
|
|
if (null === $this->updateResourceServerCommandHandler) { |
882
|
|
|
$this->updateResourceServerCommandHandler = new UpdateResourceServerCommandHandler( |
883
|
|
|
$this->getResourceServerRepository() |
884
|
|
|
); |
885
|
|
|
} |
886
|
|
|
|
887
|
|
|
return $this->updateResourceServerCommandHandler; |
888
|
|
|
} |
889
|
|
|
|
890
|
|
|
/** |
891
|
|
|
* @var null|MessageBusSupportingMiddleware |
892
|
|
|
*/ |
893
|
|
|
private $eventBus = null; |
894
|
|
|
|
895
|
|
|
/** |
896
|
|
|
* @return MessageBusSupportingMiddleware |
897
|
|
|
*/ |
898
|
|
|
public function getEventBus(): MessageBusSupportingMiddleware |
899
|
|
|
{ |
900
|
|
|
if (null === $this->eventBus) { |
901
|
|
|
$this->eventBus = new MessageBusSupportingMiddleware(); |
902
|
|
|
$this->eventBus->appendMiddleware(new FinishesHandlingMessageBeforeHandlingNext()); |
903
|
|
|
$this->eventBus->appendMiddleware(new NotifiesMessageSubscribersMiddleware( |
904
|
|
|
$this->getEventHandlerResolver() |
905
|
|
|
)); |
906
|
|
|
} |
907
|
|
|
|
908
|
|
|
return $this->eventBus; |
909
|
|
|
} |
910
|
|
|
|
911
|
|
|
/** |
912
|
|
|
* @var null|NameBasedMessageSubscriberResolver |
913
|
|
|
*/ |
914
|
|
|
private $eventHandlerResolver = null; |
915
|
|
|
|
916
|
|
|
/** |
917
|
|
|
* @return NameBasedMessageSubscriberResolver |
918
|
|
|
*/ |
919
|
|
|
public function getEventHandlerResolver(): NameBasedMessageSubscriberResolver |
920
|
|
|
{ |
921
|
|
|
if (null === $this->eventHandlerResolver) { |
922
|
|
|
$this->eventHandlerResolver = new NameBasedMessageSubscriberResolver( |
923
|
|
|
new ClassBasedNameResolver(), |
924
|
|
|
$this->getEventHandlerCollection() |
925
|
|
|
); |
926
|
|
|
} |
927
|
|
|
|
928
|
|
|
return $this->eventHandlerResolver; |
929
|
|
|
} |
930
|
|
|
|
931
|
|
|
/** |
932
|
|
|
* @var null|CallableCollection |
933
|
|
|
*/ |
934
|
|
|
private $eventHandlerCollection = null; |
935
|
|
|
|
936
|
|
|
/** |
937
|
|
|
* @return CallableCollection |
938
|
|
|
*/ |
939
|
|
|
public function getEventHandlerCollection(): CallableCollection |
940
|
|
|
{ |
941
|
|
|
if (null === $this->eventHandlerCollection) { |
942
|
|
|
$this->eventHandlerCollection = new CallableCollection( |
943
|
|
|
[ |
944
|
|
|
AccessTokenCreatedEvent::class => [AccessTokenCreatedEventHandler::class], |
945
|
|
|
AccessTokenRevokedEvent::class => [AccessTokenRevokedEventHandler::class], |
946
|
|
|
AuthCodeCreatedEvent::class => [AuthCodeCreatedEventHandler::class], |
947
|
|
|
AuthCodeMarkedAsUsedEvent::class => [AuthCodeMarkedAsUsedEventHandler::class], |
948
|
|
|
AuthCodeRevokedEvent::class => [AuthCodeRevokedEventHandler::class], |
949
|
|
|
ClientCreatedEvent::class => [ClientCreatedEventHandler::class], |
950
|
|
|
ClientDeletedEvent::class => [ClientDeletedEventHandler::class], |
951
|
|
|
ClientParametersUpdatedEvent::class => [ClientUpdatedEventHandler::class], |
952
|
|
|
InitialAccessTokenCreatedEvent::class => [], |
953
|
|
|
InitialAccessTokenRevokedEvent::class => [], |
954
|
|
|
RefreshTokenCreatedEvent::class => [RefreshTokenCreatedEventHandler::class], |
955
|
|
|
RefreshTokenRevokedEvent::class => [RefreshTokenRevokedEventHandler::class], |
956
|
|
|
], |
957
|
|
|
$this->getServiceLocatorAwareCallableResolver() |
958
|
|
|
); |
959
|
|
|
} |
960
|
|
|
|
961
|
|
|
return $this->eventHandlerCollection; |
962
|
|
|
} |
963
|
|
|
|
964
|
|
|
/** |
965
|
|
|
* @var null|PublicMessageRecorder |
966
|
|
|
*/ |
967
|
|
|
private $publicMessageRecorder = null; |
968
|
|
|
|
969
|
|
|
/** |
970
|
|
|
* @return PublicMessageRecorder |
971
|
|
|
*/ |
972
|
|
|
public function getPublicMessageRecorder(): PublicMessageRecorder |
973
|
|
|
{ |
974
|
|
|
if (null === $this->publicMessageRecorder) { |
975
|
|
|
$this->publicMessageRecorder = new PublicMessageRecorder(); |
976
|
|
|
} |
977
|
|
|
|
978
|
|
|
return $this->publicMessageRecorder; |
979
|
|
|
} |
980
|
|
|
|
981
|
|
|
/** |
982
|
|
|
* @var null|ResponseFactoryInterface |
983
|
|
|
*/ |
984
|
|
|
private $responseFactory = null; |
985
|
|
|
|
986
|
|
|
/** |
987
|
|
|
* @return ResponseFactoryInterface |
988
|
|
|
*/ |
989
|
|
|
public function getResponseFactory(): ResponseFactoryInterface |
990
|
|
|
{ |
991
|
|
|
if (null === $this->responseFactory) { |
992
|
|
|
$this->responseFactory = new ResponseFactory(); |
993
|
|
|
} |
994
|
|
|
|
995
|
|
|
return $this->responseFactory; |
996
|
|
|
} |
997
|
|
|
|
998
|
|
|
/** |
999
|
|
|
* @var null|UriFactoryInterface |
1000
|
|
|
*/ |
1001
|
|
|
private $uriFactory = null; |
1002
|
|
|
|
1003
|
|
|
/** |
1004
|
|
|
* @return UriFactoryInterface |
1005
|
|
|
*/ |
1006
|
|
|
public function getUriFactory(): UriFactoryInterface |
1007
|
|
|
{ |
1008
|
|
|
if (null === $this->uriFactory) { |
1009
|
|
|
$this->uriFactory = new UriFactory(); |
1010
|
|
|
} |
1011
|
|
|
|
1012
|
|
|
return $this->uriFactory; |
1013
|
|
|
} |
1014
|
|
|
|
1015
|
|
|
/** |
1016
|
|
|
* @var null|RuleManager |
1017
|
|
|
*/ |
1018
|
|
|
private $ruleManager = null; |
1019
|
|
|
|
1020
|
|
|
/** |
1021
|
|
|
* @return RuleManager |
1022
|
|
|
*/ |
1023
|
|
|
public function getRuleManager(): RuleManager |
1024
|
|
|
{ |
1025
|
|
|
if (null === $this->ruleManager) { |
1026
|
|
|
$this->ruleManager = new RuleManager( |
1027
|
|
|
new ClientIdRule() |
1028
|
|
|
); |
1029
|
|
|
$this->ruleManager |
1030
|
|
|
->add(new ClientRegistrationManagementRule()) |
1031
|
|
|
->add(new CommonParametersRule()) |
1032
|
|
|
->add($this->getGrantTypeFlowRule()) |
1033
|
|
|
->add(new RedirectionUriRule()) |
1034
|
|
|
->add(new ScopeRule($this->getScopeRepository())) |
1035
|
|
|
->add($this->getSoftwareRule()) |
1036
|
|
|
->add(new SubjectTypeRule($this->getUserInfo())) |
1037
|
|
|
->add(new TokenEndpointAuthMethodEndpointRule($this->getTokenEndpointAuthMethodManager())); |
1038
|
|
|
} |
1039
|
|
|
|
1040
|
|
|
return $this->ruleManager; |
1041
|
|
|
} |
1042
|
|
|
|
1043
|
|
|
/** |
1044
|
|
|
* @var null|SoftwareRule |
1045
|
|
|
*/ |
1046
|
|
|
private $softwareRule = null; |
1047
|
|
|
|
1048
|
|
|
/** |
1049
|
|
|
* @return SoftwareRule |
1050
|
|
|
*/ |
1051
|
|
|
private function getSoftwareRule(): SoftwareRule |
1052
|
|
|
{ |
1053
|
|
|
if (null === $this->softwareRule) { |
1054
|
|
|
$this->softwareRule = new SoftwareRule( |
1055
|
|
|
$this->getJwtLoader(), |
1056
|
|
|
$this->getPublicKeys(), |
1057
|
|
|
false, |
1058
|
|
|
['ES256'] |
1059
|
|
|
); |
1060
|
|
|
} |
1061
|
|
|
|
1062
|
|
|
return $this->softwareRule; |
1063
|
|
|
} |
1064
|
|
|
|
1065
|
|
|
/** |
1066
|
|
|
* @return JWKSetInterface |
1067
|
|
|
*/ |
1068
|
|
|
private function getPublicKeys(): JWKSetInterface |
1069
|
|
|
{ |
1070
|
|
|
return JWKFactory::createPublicKeySet($this->getPrivateKeys()); |
1071
|
|
|
} |
1072
|
|
|
|
1073
|
|
|
/** |
1074
|
|
|
* @var null|JWKSetInterface |
1075
|
|
|
*/ |
1076
|
|
|
private $privateKeys = null; |
1077
|
|
|
|
1078
|
|
|
/** |
1079
|
|
|
* @return JWKSetInterface |
1080
|
|
|
*/ |
1081
|
|
|
public function getPrivateKeys(): JWKSetInterface |
1082
|
|
|
{ |
1083
|
|
|
if (null === $this->privateKeys) { |
1084
|
|
|
$ecKeys = $this->getPrivateECKeys(); |
1085
|
|
|
$rsaKeys = $this->getPrivateRSAKeys(); |
1086
|
|
|
$noneKeys = $this->getPrivateNoneKeys(); |
1087
|
|
|
|
1088
|
|
|
$this->privateKeys = new JWKSets([ |
1089
|
|
|
$ecKeys, |
1090
|
|
|
$rsaKeys, |
1091
|
|
|
$noneKeys, |
1092
|
|
|
]); |
1093
|
|
|
} |
1094
|
|
|
|
1095
|
|
|
return $this->privateKeys; |
1096
|
|
|
} |
1097
|
|
|
|
1098
|
|
|
/** |
1099
|
|
|
* @var null|StorableJWKSet |
1100
|
|
|
*/ |
1101
|
|
|
private $privateECKeys = null; |
1102
|
|
|
|
1103
|
|
|
/** |
1104
|
|
|
* @return StorableJWKSet |
1105
|
|
|
*/ |
1106
|
|
|
public function getPrivateECKeys(): StorableJWKSet |
1107
|
|
|
{ |
1108
|
|
|
if (null === $this->privateECKeys) { |
1109
|
|
|
$this->privateECKeys = JWKFactory::createStorableKeySet( |
1110
|
|
|
tempnam(sys_get_temp_dir(), 'EC.keys'), |
1111
|
|
|
[ |
1112
|
|
|
'kty' => 'EC', |
1113
|
|
|
'alg' => 'ES256', |
1114
|
|
|
'crv' => 'P-256', |
1115
|
|
|
], |
1116
|
|
|
2 |
1117
|
|
|
); |
1118
|
|
|
} |
1119
|
|
|
|
1120
|
|
|
return $this->privateECKeys; |
1121
|
|
|
} |
1122
|
|
|
|
1123
|
|
|
/** |
1124
|
|
|
* @var null|StorableJWKSet |
1125
|
|
|
*/ |
1126
|
|
|
private $privateNoneKeys = null; |
1127
|
|
|
|
1128
|
|
|
/** |
1129
|
|
|
* @return StorableJWKSet |
1130
|
|
|
*/ |
1131
|
|
|
public function getPrivateNoneKeys(): StorableJWKSet |
1132
|
|
|
{ |
1133
|
|
|
if (null === $this->privateNoneKeys) { |
1134
|
|
|
$this->privateNoneKeys = JWKFactory::createStorableKeySet( |
1135
|
|
|
tempnam(sys_get_temp_dir(), 'none.keys'), |
1136
|
|
|
[ |
1137
|
|
|
'kty' => 'none', |
1138
|
|
|
'alg' => 'none', |
1139
|
|
|
], |
1140
|
|
|
1 |
1141
|
|
|
); |
1142
|
|
|
} |
1143
|
|
|
|
1144
|
|
|
return $this->privateNoneKeys; |
1145
|
|
|
} |
1146
|
|
|
|
1147
|
|
|
/** |
1148
|
|
|
* @var null|StorableJWKSet |
1149
|
|
|
*/ |
1150
|
|
|
private $privateRSAKeys = null; |
1151
|
|
|
|
1152
|
|
|
/** |
1153
|
|
|
* @return StorableJWKSet |
1154
|
|
|
*/ |
1155
|
|
|
public function getPrivateRSAKeys(): StorableJWKSet |
1156
|
|
|
{ |
1157
|
|
|
if (null === $this->privateRSAKeys) { |
1158
|
|
|
$this->privateRSAKeys = JWKFactory::createStorableKeySet( |
1159
|
|
|
tempnam(sys_get_temp_dir(), 'RSA.keys'), |
1160
|
|
|
[ |
1161
|
|
|
'kty' => 'RSA', |
1162
|
|
|
'alg' => 'RS256', |
1163
|
|
|
'size' => '1024', |
1164
|
|
|
], |
1165
|
|
|
2 |
1166
|
|
|
); |
1167
|
|
|
} |
1168
|
|
|
|
1169
|
|
|
return $this->privateRSAKeys; |
1170
|
|
|
} |
1171
|
|
|
|
1172
|
|
|
/** |
1173
|
|
|
* @var null|ServerRequestFactoryInterface |
1174
|
|
|
*/ |
1175
|
|
|
private $serverRequestFactory = null; |
1176
|
|
|
|
1177
|
|
|
/** |
1178
|
|
|
* @return ServerRequestFactoryInterface |
1179
|
|
|
*/ |
1180
|
|
|
public function getServerRequestFactory(): ServerRequestFactoryInterface |
1181
|
|
|
{ |
1182
|
|
|
if (null === $this->serverRequestFactory) { |
1183
|
|
|
$this->serverRequestFactory = new ServerRequestFactory(); |
1184
|
|
|
} |
1185
|
|
|
|
1186
|
|
|
return $this->serverRequestFactory; |
1187
|
|
|
} |
1188
|
|
|
|
1189
|
|
|
/** |
1190
|
|
|
* @var null|ServiceLocatorAwareCallableResolver |
1191
|
|
|
*/ |
1192
|
|
|
private $serviceLocatorAwareCallableResolver = null; |
1193
|
|
|
|
1194
|
|
|
/** |
1195
|
|
|
* @return ServiceLocatorAwareCallableResolver |
1196
|
|
|
*/ |
1197
|
|
|
public function getServiceLocatorAwareCallableResolver(): ServiceLocatorAwareCallableResolver |
1198
|
|
|
{ |
1199
|
|
|
if (null === $this->serviceLocatorAwareCallableResolver) { |
1200
|
|
|
$this->serviceLocatorAwareCallableResolver = new ServiceLocatorAwareCallableResolver( |
1201
|
|
|
$this->getServiceLocator() |
1202
|
|
|
); |
1203
|
|
|
} |
1204
|
|
|
|
1205
|
|
|
return $this->serviceLocatorAwareCallableResolver; |
1206
|
|
|
} |
1207
|
|
|
|
1208
|
|
|
/** |
1209
|
|
|
* @var null|ServiceLocator |
1210
|
|
|
*/ |
1211
|
|
|
private $serviceLocator = null; |
1212
|
|
|
|
1213
|
|
|
/** |
1214
|
|
|
* @return ServiceLocator |
1215
|
|
|
*/ |
1216
|
|
|
public function getServiceLocator(): ServiceLocator |
1217
|
|
|
{ |
1218
|
|
|
if (null === $this->serviceLocator) { |
1219
|
|
|
$this->serviceLocator = new ServiceLocator( |
1220
|
|
|
$this->getContainer() |
1221
|
|
|
); |
1222
|
|
|
} |
1223
|
|
|
|
1224
|
|
|
return $this->serviceLocator; |
1225
|
|
|
} |
1226
|
|
|
|
1227
|
|
|
/** |
1228
|
|
|
* @var null|GrantTypeFlowRule |
1229
|
|
|
*/ |
1230
|
|
|
private $grantTypeFlowRule = null; |
1231
|
|
|
|
1232
|
|
|
/** |
1233
|
|
|
* @return GrantTypeFlowRule |
1234
|
|
|
*/ |
1235
|
|
|
public function getGrantTypeFlowRule(): GrantTypeFlowRule |
1236
|
|
|
{ |
1237
|
|
|
if (null === $this->grantTypeFlowRule) { |
1238
|
|
|
$this->grantTypeFlowRule = new GrantTypeFlowRule( |
1239
|
|
|
$this->getGrantTypeManager(), |
1240
|
|
|
$this->getResponseTypeManager() |
1241
|
|
|
); |
1242
|
|
|
} |
1243
|
|
|
|
1244
|
|
|
return $this->grantTypeFlowRule; |
1245
|
|
|
} |
1246
|
|
|
|
1247
|
|
|
/** |
1248
|
|
|
* @var null|GrantTypeManager |
1249
|
|
|
*/ |
1250
|
|
|
private $grantTypeManager = null; |
1251
|
|
|
|
1252
|
|
|
/** |
1253
|
|
|
* @return GrantTypeManager |
1254
|
|
|
*/ |
1255
|
|
|
public function getGrantTypeManager(): GrantTypeManager |
1256
|
|
|
{ |
1257
|
|
|
if (null === $this->grantTypeManager) { |
1258
|
|
|
$this->grantTypeManager = new GrantTypeManager(); |
1259
|
|
|
$this->grantTypeManager->add($this->getAuthorizationCodeGrantType()); |
1260
|
|
|
$this->grantTypeManager->add($this->getClientCredentialsGrantType()); |
1261
|
|
|
$this->grantTypeManager->add($this->getJWTBearerGrantType()); |
1262
|
|
|
$this->grantTypeManager->add($this->getResourceOwnerPasswordCredentialsGrantType()); |
1263
|
|
|
$this->grantTypeManager->add($this->getRefreshTokenGrantType()); |
1264
|
|
|
} |
1265
|
|
|
|
1266
|
|
|
return $this->grantTypeManager; |
1267
|
|
|
} |
1268
|
|
|
|
1269
|
|
|
/** |
1270
|
|
|
* @var null|ResponseTypeManager |
1271
|
|
|
*/ |
1272
|
|
|
private $responseTypeManager = null; |
1273
|
|
|
|
1274
|
|
|
/** |
1275
|
|
|
* @return ResponseTypeManager |
1276
|
|
|
*/ |
1277
|
|
|
public function getResponseTypeManager(): ResponseTypeManager |
1278
|
|
|
{ |
1279
|
|
|
if (null === $this->responseTypeManager) { |
1280
|
|
|
$this->responseTypeManager = new ResponseTypeManager(); |
1281
|
|
|
$this->responseTypeManager->add($this->getCodeResponseType()); |
1282
|
|
|
$this->responseTypeManager->add($this->getTokenResponseType()); |
1283
|
|
|
$this->responseTypeManager->add($this->getIdTokenResponseType()); |
1284
|
|
|
$this->responseTypeManager->add($this->getNoneResponseType()); |
1285
|
|
|
} |
1286
|
|
|
|
1287
|
|
|
return $this->responseTypeManager; |
1288
|
|
|
} |
1289
|
|
|
|
1290
|
|
|
/** |
1291
|
|
|
* @var null|ClientCredentialsGrantType |
1292
|
|
|
*/ |
1293
|
|
|
private $clientCredentialsGrantType = null; |
1294
|
|
|
|
1295
|
|
|
/** |
1296
|
|
|
* @return ClientCredentialsGrantType |
1297
|
|
|
*/ |
1298
|
|
|
public function getClientCredentialsGrantType(): ClientCredentialsGrantType |
1299
|
|
|
{ |
1300
|
|
|
if (null === $this->clientCredentialsGrantType) { |
1301
|
|
|
$this->clientCredentialsGrantType = new ClientCredentialsGrantType(false); |
1302
|
|
|
} |
1303
|
|
|
|
1304
|
|
|
return $this->clientCredentialsGrantType; |
1305
|
|
|
} |
1306
|
|
|
|
1307
|
|
|
/** |
1308
|
|
|
* @var null|AuthorizationCodeGrantType |
1309
|
|
|
*/ |
1310
|
|
|
private $authorizationCodeGrantType = null; |
1311
|
|
|
|
1312
|
|
|
/** |
1313
|
|
|
* @return AuthorizationCodeGrantType |
1314
|
|
|
*/ |
1315
|
|
|
public function getAuthorizationCodeGrantType(): AuthorizationCodeGrantType |
1316
|
|
|
{ |
1317
|
|
|
if (null === $this->authorizationCodeGrantType) { |
1318
|
|
|
$this->authorizationCodeGrantType = new AuthorizationCodeGrantType( |
1319
|
|
|
$this->getAuthorizationCodeRepository(), |
1320
|
|
|
$this->getPKCEMethodManager(), |
1321
|
|
|
$this->getCommandBus() |
1322
|
|
|
); |
1323
|
|
|
} |
1324
|
|
|
|
1325
|
|
|
return $this->authorizationCodeGrantType; |
1326
|
|
|
} |
1327
|
|
|
|
1328
|
|
|
/** |
1329
|
|
|
* @var null|RefreshTokenGrantType |
1330
|
|
|
*/ |
1331
|
|
|
private $refreshTokenGrantType = null; |
1332
|
|
|
|
1333
|
|
|
/** |
1334
|
|
|
* @return RefreshTokenGrantType |
1335
|
|
|
*/ |
1336
|
|
|
public function getRefreshTokenGrantType(): RefreshTokenGrantType |
1337
|
|
|
{ |
1338
|
|
|
if (null === $this->refreshTokenGrantType) { |
1339
|
|
|
$this->refreshTokenGrantType = new RefreshTokenGrantType( |
1340
|
|
|
$this->getRefreshTokenRepository() |
1341
|
|
|
); |
1342
|
|
|
} |
1343
|
|
|
|
1344
|
|
|
return $this->refreshTokenGrantType; |
1345
|
|
|
} |
1346
|
|
|
|
1347
|
|
|
/** |
1348
|
|
|
* @var null|ResourceOwnerPasswordCredentialsGrantType |
1349
|
|
|
*/ |
1350
|
|
|
private $resourceOwnerPasswordCredentialsGrantType = null; |
1351
|
|
|
|
1352
|
|
|
/** |
1353
|
|
|
* @return ResourceOwnerPasswordCredentialsGrantType |
1354
|
|
|
*/ |
1355
|
|
|
public function getResourceOwnerPasswordCredentialsGrantType(): ResourceOwnerPasswordCredentialsGrantType |
1356
|
|
|
{ |
1357
|
|
|
if (null === $this->resourceOwnerPasswordCredentialsGrantType) { |
1358
|
|
|
$this->resourceOwnerPasswordCredentialsGrantType = new ResourceOwnerPasswordCredentialsGrantType( |
1359
|
|
|
$this->getUserAccountManager(), |
1360
|
|
|
$this->getUserAccountRepository(), |
1361
|
|
|
true, |
1362
|
|
|
false |
1363
|
|
|
); |
1364
|
|
|
} |
1365
|
|
|
|
1366
|
|
|
return $this->resourceOwnerPasswordCredentialsGrantType; |
1367
|
|
|
} |
1368
|
|
|
|
1369
|
|
|
/** |
1370
|
|
|
* @var null|JWTBearerGrantType |
1371
|
|
|
*/ |
1372
|
|
|
private $jwtBearerGrantType = null; |
1373
|
|
|
|
1374
|
|
|
/** |
1375
|
|
|
* @return JWTBearerGrantType |
1376
|
|
|
*/ |
1377
|
|
|
public function getJWTBearerGrantType(): JWTBearerGrantType |
1378
|
|
|
{ |
1379
|
|
|
if (null === $this->jwtBearerGrantType) { |
1380
|
|
|
$this->jwtBearerGrantType = new JWTBearerGrantType($this->getJwtLoader(), $this->getClientRepository(), $this->getUserAccountRepository()); |
1381
|
|
|
$this->jwtBearerGrantType->enableEncryptedAssertions(false, $this->getPrivateKeys()); |
1382
|
|
|
|
1383
|
|
|
$publicKeys = new JWKSet(); |
1384
|
|
|
$publicKeys->addKey(new JWK([ |
1385
|
|
|
'kty' => 'RSA', |
1386
|
|
|
'kid' => '[email protected]', |
1387
|
|
|
'use' => 'sig', |
1388
|
|
|
'n' => 'n4EPtAOCc9AlkeQHPzHStgAbgs7bTZLwUBZdR8_KuKPEHLd4rHVTeT-O-XV2jRojdNhxJWTDvNd7nqQ0VEiZQHz_AJmSCpMaJMRBSFKrKb2wqVwGU_NsYOYL-QtiWN2lbzcEe6XC0dApr5ydQLrHqkHHig3RBordaZ6Aj-oBHqFEHYpPe7Tpe-OfVfHd1E6cS6M1FZcD1NNLYD5lFHpPI9bTwJlsde3uhGqC0ZCuEHg8lhzwOHrtIQbS0FVbb9k3-tVTU4fg_3L_vniUFAKwuCLqKnS2BYwdq_mzSnbLY7h_qixoR7jig3__kRhuaxwUkRz5iaiQkqgc5gHdrNP5zw', |
1389
|
|
|
'e' => 'AQAB', |
1390
|
|
|
'd' => 'bWUC9B-EFRIo8kpGfh0ZuyGPvMNKvYWNtB_ikiH9k20eT-O1q_I78eiZkpXxXQ0UTEs2LsNRS-8uJbvQ-A1irkwMSMkK1J3XTGgdrhCku9gRldY7sNA_AKZGh-Q661_42rINLRCe8W-nZ34ui_qOfkLnK9QWDDqpaIsA-bMwWWSDFu2MUBYwkHTMEzLYGqOe04noqeq1hExBTHBOBdkMXiuFhUq1BU6l-DqEiWxqg82sXt2h-LMnT3046AOYJoRioz75tSUQfGCshWTBnP5uDjd18kKhyv07lhfSJdrPdM5Plyl21hsFf4L_mHCuoFau7gdsPfHPxxjVOcOpBrQzwQ', |
1391
|
|
|
'p' => '3Slxg_DwTXJcb6095RoXygQCAZ5RnAvZlno1yhHtnUex_fp7AZ_9nRaO7HX_-SFfGQeutao2TDjDAWU4Vupk8rw9JR0AzZ0N2fvuIAmr_WCsmGpeNqQnev1T7IyEsnh8UMt-n5CafhkikzhEsrmndH6LxOrvRJlsPp6Zv8bUq0k', |
1392
|
|
|
'q' => 'uKE2dh-cTf6ERF4k4e_jy78GfPYUIaUyoSSJuBzp3Cubk3OCqs6grT8bR_cu0Dm1MZwWmtdqDyI95HrUeq3MP15vMMON8lHTeZu2lmKvwqW7anV5UzhM1iZ7z4yMkuUwFWoBvyY898EXvRD-hdqRxHlSqAZ192zB3pVFJ0s7pFc', |
1393
|
|
|
'dp' => 'B8PVvXkvJrj2L-GYQ7v3y9r6Kw5g9SahXBwsWUzp19TVlgI-YV85q1NIb1rxQtD-IsXXR3-TanevuRPRt5OBOdiMGQp8pbt26gljYfKU_E9xn-RULHz0-ed9E9gXLKD4VGngpz-PfQ_q29pk5xWHoJp009Qf1HvChixRX59ehik', |
1394
|
|
|
'dq' => 'CLDmDGduhylc9o7r84rEUVn7pzQ6PF83Y-iBZx5NT-TpnOZKF1pErAMVeKzFEl41DlHHqqBLSM0W1sOFbwTxYWZDm6sI6og5iTbwQGIC3gnJKbi_7k_vJgGHwHxgPaX2PnvP-zyEkDERuf-ry4c_Z11Cq9AqC2yeL6kdKT1cYF8', |
1395
|
|
|
'qi' => '3PiqvXQN0zwMeE-sBvZgi289XP9XCQF3VWqPzMKnIgQp7_Tugo6-NZBKCQsMf3HaEGBjTVJs_jcK8-TRXvaKe-7ZMaQj8VfBdYkssbu0NKDDhjJ-GtiseaDVWt7dcH0cfwxgFUHpQh7FoCrjFJ6h6ZEpMF6xmujs4qMpPz8aaI4', |
1396
|
|
|
])); |
1397
|
|
|
$this->jwtBearerGrantType->addTrustedIssuer(new TrustedIssuer( |
1398
|
|
|
'https://my.trusted.issuer', |
1399
|
|
|
['RS256'], |
1400
|
|
|
$publicKeys |
1401
|
|
|
)); |
1402
|
|
|
} |
1403
|
|
|
|
1404
|
|
|
return $this->jwtBearerGrantType; |
1405
|
|
|
} |
1406
|
|
|
|
1407
|
|
|
/** |
1408
|
|
|
* @var null|UserAccountRepositoryInterface |
1409
|
|
|
*/ |
1410
|
|
|
private $userAccountRepository = null; |
1411
|
|
|
|
1412
|
|
|
/** |
1413
|
|
|
* @return UserAccountRepositoryInterface |
1414
|
|
|
*/ |
1415
|
|
|
public function getUserAccountRepository(): UserAccountRepositoryInterface |
1416
|
|
|
{ |
1417
|
|
|
if (null === $this->userAccountRepository) { |
1418
|
|
|
$this->userAccountRepository = new UserAccountRepository(); |
1419
|
|
|
} |
1420
|
|
|
|
1421
|
|
|
return $this->userAccountRepository; |
1422
|
|
|
} |
1423
|
|
|
|
1424
|
|
|
/** |
1425
|
|
|
* @var null|UserAccountManagerInterface |
1426
|
|
|
*/ |
1427
|
|
|
private $userAccountManager = null; |
1428
|
|
|
|
1429
|
|
|
/** |
1430
|
|
|
* @return UserAccountManagerInterface |
1431
|
|
|
*/ |
1432
|
|
|
public function getUserAccountManager(): UserAccountManagerInterface |
1433
|
|
|
{ |
1434
|
|
|
if (null === $this->userAccountManager) { |
1435
|
|
|
$this->userAccountManager = new UserAccountManager( |
1436
|
|
|
$this->getUserAccountRepository() |
1437
|
|
|
); |
1438
|
|
|
} |
1439
|
|
|
|
1440
|
|
|
return $this->userAccountManager; |
1441
|
|
|
} |
1442
|
|
|
|
1443
|
|
|
/** |
1444
|
|
|
* @var null|PKCEMethodManager |
1445
|
|
|
*/ |
1446
|
|
|
private $pkceMethodManager = null; |
1447
|
|
|
|
1448
|
|
|
/** |
1449
|
|
|
* @var null|PKCEMethodInterface |
1450
|
|
|
*/ |
1451
|
|
|
private $pkceMethodPlain = null; |
1452
|
|
|
|
1453
|
|
|
/** |
1454
|
|
|
* @var null|PKCEMethodInterface |
1455
|
|
|
*/ |
1456
|
|
|
private $pkceMethodS256 = null; |
1457
|
|
|
|
1458
|
|
|
/** |
1459
|
|
|
* @return PKCEMethodManager |
1460
|
|
|
*/ |
1461
|
|
|
public function getPKCEMethodManager(): PKCEMethodManager |
1462
|
|
|
{ |
1463
|
|
|
if (null === $this->pkceMethodManager) { |
1464
|
|
|
$this->pkceMethodManager = new PKCEMethodManager(); |
1465
|
|
|
$this->pkceMethodManager |
1466
|
|
|
->add($this->getPKCEMethodPlain()) |
1467
|
|
|
->add($this->getPKCEMethodS256()); |
1468
|
|
|
} |
1469
|
|
|
|
1470
|
|
|
return $this->pkceMethodManager; |
1471
|
|
|
} |
1472
|
|
|
|
1473
|
|
|
/** |
1474
|
|
|
* @return PKCEMethodInterface |
1475
|
|
|
*/ |
1476
|
|
|
protected function getPKCEMethodPlain(): PKCEMethodInterface |
1477
|
|
|
{ |
1478
|
|
|
if (null === $this->pkceMethodPlain) { |
1479
|
|
|
$this->pkceMethodPlain = new Plain(); |
1480
|
|
|
} |
1481
|
|
|
|
1482
|
|
|
return $this->pkceMethodPlain; |
1483
|
|
|
} |
1484
|
|
|
|
1485
|
|
|
/** |
1486
|
|
|
* @return PKCEMethodInterface |
1487
|
|
|
*/ |
1488
|
|
|
protected function getPKCEMethodS256(): PKCEMethodInterface |
1489
|
|
|
{ |
1490
|
|
|
if (null === $this->pkceMethodS256) { |
1491
|
|
|
$this->pkceMethodS256 = new S256(); |
1492
|
|
|
} |
1493
|
|
|
|
1494
|
|
|
return $this->pkceMethodS256; |
1495
|
|
|
} |
1496
|
|
|
|
1497
|
|
|
/** |
1498
|
|
|
* @var null|ScopeRepository |
1499
|
|
|
*/ |
1500
|
|
|
private $scopeRepository = null; |
1501
|
|
|
|
1502
|
|
|
/** |
1503
|
|
|
* @var null|ScopePolicyInterface |
1504
|
|
|
*/ |
1505
|
|
|
private $scopePolicyDefault = null; |
1506
|
|
|
|
1507
|
|
|
/** |
1508
|
|
|
* @var null|ScopePolicyInterface |
1509
|
|
|
*/ |
1510
|
|
|
private $scopePolicyError = null; |
1511
|
|
|
|
1512
|
|
|
/** |
1513
|
|
|
* @return ScopeRepositoryInterface |
1514
|
|
|
*/ |
1515
|
|
|
public function getScopeRepository(): ScopeRepositoryInterface |
1516
|
|
|
{ |
1517
|
|
|
if (null === $this->scopeRepository) { |
1518
|
|
|
$this->scopeRepository = new ScopeRepository( |
1519
|
|
|
['data_read', 'data_write', 'openid', 'profile', 'email', 'phone', 'address', 'offline_access'] |
1520
|
|
|
); |
1521
|
|
|
$this->scopeRepository |
1522
|
|
|
->addScopePolicy($this->getScopePolicyDefault()) |
1523
|
|
|
->addScopePolicy($this->getScopePolicyError()); |
1524
|
|
|
} |
1525
|
|
|
|
1526
|
|
|
return $this->scopeRepository; |
1527
|
|
|
} |
1528
|
|
|
|
1529
|
|
|
/** |
1530
|
|
|
* @return ScopePolicyInterface |
1531
|
|
|
*/ |
1532
|
|
|
public function getScopePolicyDefault(): ScopePolicyInterface |
1533
|
|
|
{ |
1534
|
|
|
if (null === $this->scopePolicyDefault) { |
1535
|
|
|
$this->scopePolicyDefault = new DefaultScopePolicy([ |
1536
|
|
|
'data_read', |
1537
|
|
|
]); |
1538
|
|
|
} |
1539
|
|
|
|
1540
|
|
|
return $this->scopePolicyDefault; |
1541
|
|
|
} |
1542
|
|
|
|
1543
|
|
|
/** |
1544
|
|
|
* @return ScopePolicyInterface |
1545
|
|
|
*/ |
1546
|
|
|
public function getScopePolicyError(): ScopePolicyInterface |
1547
|
|
|
{ |
1548
|
|
|
if (null === $this->scopePolicyError) { |
1549
|
|
|
$this->scopePolicyError = new ErrorScopePolicy(); |
1550
|
|
|
} |
1551
|
|
|
|
1552
|
|
|
return $this->scopePolicyError; |
1553
|
|
|
} |
1554
|
|
|
|
1555
|
|
|
/** |
1556
|
|
|
* @var null|InitialAccessTokenMiddleware |
1557
|
|
|
*/ |
1558
|
|
|
private $initialAccessTokenMiddleware = null; |
1559
|
|
|
|
1560
|
|
|
/** |
1561
|
|
|
* @return InitialAccessTokenMiddleware |
1562
|
|
|
*/ |
1563
|
|
|
public function getInitialAccessTokenMiddleware(): InitialAccessTokenMiddleware |
1564
|
|
|
{ |
1565
|
|
|
if (null === $this->initialAccessTokenMiddleware) { |
1566
|
|
|
$this->initialAccessTokenMiddleware = new InitialAccessTokenMiddleware( |
1567
|
|
|
$this->getBearerTokenType(), |
1568
|
|
|
$this->getInitialAccessTokenRepository() |
1569
|
|
|
); |
1570
|
|
|
} |
1571
|
|
|
|
1572
|
|
|
return $this->initialAccessTokenMiddleware; |
1573
|
|
|
} |
1574
|
|
|
|
1575
|
|
|
/** |
1576
|
|
|
* @var null|BearerToken |
1577
|
|
|
*/ |
1578
|
|
|
private $bearerTokenType = null; |
1579
|
|
|
|
1580
|
|
|
/** |
1581
|
|
|
* @return BearerToken |
1582
|
|
|
*/ |
1583
|
|
|
public function getBearerTokenType(): BearerToken |
1584
|
|
|
{ |
1585
|
|
|
if (null === $this->bearerTokenType) { |
1586
|
|
|
$this->bearerTokenType = new BearerToken( |
1587
|
|
|
'**My Service**', |
1588
|
|
|
true, |
1589
|
|
|
false, |
1590
|
|
|
false |
1591
|
|
|
); |
1592
|
|
|
} |
1593
|
|
|
|
1594
|
|
|
return $this->bearerTokenType; |
1595
|
|
|
} |
1596
|
|
|
|
1597
|
|
|
/** |
1598
|
|
|
* @var null|MacToken |
1599
|
|
|
*/ |
1600
|
|
|
private $macTokenType = null; |
1601
|
|
|
|
1602
|
|
|
/** |
1603
|
|
|
* @return MacToken |
1604
|
|
|
*/ |
1605
|
|
|
public function getMacTokenType(): MacToken |
1606
|
|
|
{ |
1607
|
|
|
if (null === $this->macTokenType) { |
1608
|
|
|
$this->macTokenType = new MacToken('hmac-sha-256', 30); |
1609
|
|
|
} |
1610
|
|
|
|
1611
|
|
|
return $this->macTokenType; |
1612
|
|
|
} |
1613
|
|
|
|
1614
|
|
|
/** |
1615
|
|
|
* @var null|InitialAccessTokenRepositoryInterface |
1616
|
|
|
*/ |
1617
|
|
|
private $initialAccessTokenRepository = null; |
1618
|
|
|
|
1619
|
|
|
/** |
1620
|
|
|
* @return InitialAccessTokenRepositoryInterface |
1621
|
|
|
*/ |
1622
|
|
|
public function getInitialAccessTokenRepository(): InitialAccessTokenRepositoryInterface |
1623
|
|
|
{ |
1624
|
|
|
if (null === $this->initialAccessTokenRepository) { |
1625
|
|
|
$this->initialAccessTokenRepository = new InitialAccessTokenRepository( |
1626
|
|
|
$this->getInitialAccessTokenEventStore(), |
1627
|
|
|
$this->getPublicMessageRecorder() |
1628
|
|
|
); |
1629
|
|
|
} |
1630
|
|
|
|
1631
|
|
|
return $this->initialAccessTokenRepository; |
1632
|
|
|
} |
1633
|
|
|
|
1634
|
|
|
/** |
1635
|
|
|
* @var null|JWTCreator |
1636
|
|
|
*/ |
1637
|
|
|
private $jwtCreator = null; |
1638
|
|
|
|
1639
|
|
|
/** |
1640
|
|
|
* @var null|JWTLoader |
1641
|
|
|
*/ |
1642
|
|
|
private $jwtLoader = null; |
1643
|
|
|
|
1644
|
|
|
/** |
1645
|
|
|
* @var null|Signer |
1646
|
|
|
*/ |
1647
|
|
|
private $jwtSigner = null; |
1648
|
|
|
|
1649
|
|
|
/** |
1650
|
|
|
* @var null|Verifier |
1651
|
|
|
*/ |
1652
|
|
|
private $jwtVerifier = null; |
1653
|
|
|
|
1654
|
|
|
/** |
1655
|
|
|
* @var null|Encrypter |
1656
|
|
|
*/ |
1657
|
|
|
private $jwtEncrypter = null; |
1658
|
|
|
|
1659
|
|
|
/** |
1660
|
|
|
* @var null|Decrypter |
1661
|
|
|
*/ |
1662
|
|
|
private $jwtDecrypter = null; |
1663
|
|
|
|
1664
|
|
|
/** |
1665
|
|
|
* @var null|CheckerManager |
1666
|
|
|
*/ |
1667
|
|
|
private $jwtCheckerManager = null; |
1668
|
|
|
|
1669
|
|
|
/** |
1670
|
|
|
* @return JWTCreator |
1671
|
|
|
*/ |
1672
|
|
|
public function getJwtCreator(): JWTCreator |
1673
|
|
|
{ |
1674
|
|
|
if (null === $this->jwtCreator) { |
1675
|
|
|
$this->jwtCreator = new JWTCreator( |
1676
|
|
|
$this->getJwtSigner() |
1677
|
|
|
); |
1678
|
|
|
$this->jwtCreator->enableEncryptionSupport( |
1679
|
|
|
$this->getJwtEncrypter() |
1680
|
|
|
); |
1681
|
|
|
} |
1682
|
|
|
|
1683
|
|
|
return $this->jwtCreator; |
1684
|
|
|
} |
1685
|
|
|
|
1686
|
|
|
/** |
1687
|
|
|
* @return JWTLoader |
1688
|
|
|
*/ |
1689
|
|
|
public function getJwtLoader(): JWTLoader |
1690
|
|
|
{ |
1691
|
|
|
if (null === $this->jwtLoader) { |
1692
|
|
|
$this->jwtLoader = new JWTLoader( |
1693
|
|
|
$this->getJwtChecker(), |
1694
|
|
|
$this->getJwtVerifier() |
1695
|
|
|
); |
1696
|
|
|
|
1697
|
|
|
$this->jwtLoader->enableDecryptionSupport( |
1698
|
|
|
$this->getJwtDecrypter() |
1699
|
|
|
); |
1700
|
|
|
} |
1701
|
|
|
|
1702
|
|
|
return $this->jwtLoader; |
1703
|
|
|
} |
1704
|
|
|
|
1705
|
|
|
private function getJwtChecker(): CheckerManager |
1706
|
|
|
{ |
1707
|
|
|
if (null === $this->jwtCheckerManager) { |
1708
|
|
|
$this->jwtCheckerManager = new CheckerManager(); |
1709
|
|
|
//$this->jwtCheckerManager->addHeaderChecker(new CriticalHeaderChecker()); |
1710
|
|
|
//$this->jwtCheckerManager->addClaimChecker(new IssuedAtChecker()); |
1711
|
|
|
//$this->jwtCheckerManager->addClaimChecker(new NotBeforeChecker()); |
1712
|
|
|
//$this->jwtCheckerManager->addClaimChecker(new ExpirationTimeChecker()); |
1713
|
|
|
//$this->jwtCheckerManager->addClaimChecker(new SubjectChecker()); |
1714
|
|
|
} |
1715
|
|
|
|
1716
|
|
|
return $this->jwtCheckerManager; |
1717
|
|
|
} |
1718
|
|
|
|
1719
|
|
|
private function getJwtSigner(): Signer |
1720
|
|
|
{ |
1721
|
|
|
if (null === $this->jwtSigner) { |
1722
|
|
|
$this->jwtSigner = new Signer([ |
1723
|
|
|
'HS256', |
1724
|
|
|
'RS256', |
1725
|
|
|
'ES256', |
1726
|
|
|
'none', |
1727
|
|
|
]); |
1728
|
|
|
} |
1729
|
|
|
|
1730
|
|
|
return $this->jwtSigner; |
1731
|
|
|
} |
1732
|
|
|
|
1733
|
|
|
private function getJwtVerifier(): Verifier |
1734
|
|
|
{ |
1735
|
|
|
if (null === $this->jwtVerifier) { |
1736
|
|
|
$this->jwtVerifier = new Verifier([ |
1737
|
|
|
'HS256', |
1738
|
|
|
'RS256', |
1739
|
|
|
'ES256', |
1740
|
|
|
'none', |
1741
|
|
|
]); |
1742
|
|
|
} |
1743
|
|
|
|
1744
|
|
|
return $this->jwtVerifier; |
1745
|
|
|
} |
1746
|
|
|
|
1747
|
|
|
private function getJwtEncrypter(): Encrypter |
1748
|
|
|
{ |
1749
|
|
|
if (null === $this->jwtEncrypter) { |
1750
|
|
|
$this->jwtEncrypter = new Encrypter( |
1751
|
|
|
['RSA-OAEP', 'RSA-OAEP-256'], |
1752
|
|
|
['A256GCM', 'A256CBC-HS512'], |
1753
|
|
|
['DEF'] |
1754
|
|
|
); |
1755
|
|
|
} |
1756
|
|
|
|
1757
|
|
|
return $this->jwtEncrypter; |
1758
|
|
|
} |
1759
|
|
|
|
1760
|
|
|
private function getJwtDecrypter(): Decrypter |
1761
|
|
|
{ |
1762
|
|
|
if (null === $this->jwtDecrypter) { |
1763
|
|
|
$this->jwtDecrypter = new Decrypter( |
1764
|
|
|
['RSA-OAEP', 'RSA-OAEP-256'], |
1765
|
|
|
['A256GCM', 'A256CBC-HS512'], |
1766
|
|
|
['DEF'] |
1767
|
|
|
); |
1768
|
|
|
} |
1769
|
|
|
|
1770
|
|
|
return $this->jwtDecrypter; |
1771
|
|
|
} |
1772
|
|
|
|
1773
|
|
|
/** |
1774
|
|
|
* @var null|ClientConfigurationEndpoint |
1775
|
|
|
*/ |
1776
|
|
|
private $clientConfigurationEndpoint = null; |
1777
|
|
|
|
1778
|
|
|
/** |
1779
|
|
|
* @return ClientConfigurationEndpoint |
1780
|
|
|
*/ |
1781
|
|
|
public function getClientConfigurationEndpoint(): ClientConfigurationEndpoint |
1782
|
|
|
{ |
1783
|
|
|
if (null === $this->clientConfigurationEndpoint) { |
1784
|
|
|
$this->clientConfigurationEndpoint = new ClientConfigurationEndpoint( |
1785
|
|
|
$this->getBearerTokenType(), |
1786
|
|
|
$this->getCommandBus(), |
1787
|
|
|
$this->getResponseFactory() |
1788
|
|
|
); |
1789
|
|
|
} |
1790
|
|
|
|
1791
|
|
|
return $this->clientConfigurationEndpoint; |
1792
|
|
|
} |
1793
|
|
|
|
1794
|
|
|
/** |
1795
|
|
|
* @var null|Pipe |
1796
|
|
|
*/ |
1797
|
|
|
private $clientConfigurationPipe = null; |
1798
|
|
|
|
1799
|
|
|
/** |
1800
|
|
|
* @return Pipe |
1801
|
|
|
*/ |
1802
|
|
|
public function getClientConfigurationPipe(): Pipe |
1803
|
|
|
{ |
1804
|
|
|
if (null === $this->clientConfigurationPipe) { |
1805
|
|
|
$this->clientConfigurationPipe = new Pipe(); |
1806
|
|
|
|
1807
|
|
|
$this->clientConfigurationPipe->appendMiddleware($this->getOAuth2ResponseMiddleware()); |
1808
|
|
|
$this->clientConfigurationPipe->appendMiddleware($this->getClientConfigurationEndpoint()); |
1809
|
|
|
} |
1810
|
|
|
|
1811
|
|
|
return $this->clientConfigurationPipe; |
1812
|
|
|
} |
1813
|
|
|
|
1814
|
|
|
/** |
1815
|
|
|
* @var null|TokenTypeHintManager |
1816
|
|
|
*/ |
1817
|
|
|
private $tokenTypeHintManager = null; |
1818
|
|
|
|
1819
|
|
|
/** |
1820
|
|
|
* @return TokenTypeHintManager |
1821
|
|
|
*/ |
1822
|
|
|
public function getTokenTypeHintManager(): TokenTypeHintManager |
1823
|
|
|
{ |
1824
|
|
|
if (null === $this->tokenTypeHintManager) { |
1825
|
|
|
$this->tokenTypeHintManager = new TokenTypeHintManager(); |
1826
|
|
|
$this->tokenTypeHintManager->add($this->getAccessTokenTypeHint()); // Access Token |
1827
|
|
|
$this->tokenTypeHintManager->add($this->getRefreshTokenTypeHint()); // Refresh Token |
1828
|
|
|
$this->tokenTypeHintManager->add($this->getAuthCodeTypeHint()); // Auth Code |
1829
|
|
|
} |
1830
|
|
|
|
1831
|
|
|
return $this->tokenTypeHintManager; |
1832
|
|
|
} |
1833
|
|
|
|
1834
|
|
|
/** |
1835
|
|
|
* @var null|TokenRevocationGetEndpoint |
1836
|
|
|
*/ |
1837
|
|
|
private $tokenRevocationGetEndpoint = null; |
1838
|
|
|
|
1839
|
|
|
/** |
1840
|
|
|
* @return TokenRevocationGetEndpoint |
1841
|
|
|
*/ |
1842
|
|
|
public function getTokenRevocationGetEndpoint(): TokenRevocationGetEndpoint |
1843
|
|
|
{ |
1844
|
|
|
if (null === $this->tokenRevocationGetEndpoint) { |
1845
|
|
|
$this->tokenRevocationGetEndpoint = new TokenRevocationGetEndpoint( |
1846
|
|
|
$this->getTokenTypeHintManager(), |
1847
|
|
|
$this->getResponseFactory(), |
1848
|
|
|
true |
1849
|
|
|
); |
1850
|
|
|
} |
1851
|
|
|
|
1852
|
|
|
return $this->tokenRevocationGetEndpoint; |
1853
|
|
|
} |
1854
|
|
|
|
1855
|
|
|
/** |
1856
|
|
|
* @var null|TokenRevocationPostEndpoint |
1857
|
|
|
*/ |
1858
|
|
|
private $tokenRevocationPostEndpoint = null; |
1859
|
|
|
|
1860
|
|
|
/** |
1861
|
|
|
* @return TokenRevocationPostEndpoint |
1862
|
|
|
*/ |
1863
|
|
|
public function getTokenRevocationPostEndpoint(): TokenRevocationPostEndpoint |
1864
|
|
|
{ |
1865
|
|
|
if (null === $this->tokenRevocationPostEndpoint) { |
1866
|
|
|
$this->tokenRevocationPostEndpoint = new TokenRevocationPostEndpoint( |
1867
|
|
|
$this->getTokenTypeHintManager(), |
1868
|
|
|
$this->getResponseFactory() |
1869
|
|
|
); |
1870
|
|
|
} |
1871
|
|
|
|
1872
|
|
|
return $this->tokenRevocationPostEndpoint; |
1873
|
|
|
} |
1874
|
|
|
|
1875
|
|
|
/** |
1876
|
|
|
* @var null|Pipe |
1877
|
|
|
*/ |
1878
|
|
|
private $tokenRevocationPipe = null; |
1879
|
|
|
|
1880
|
|
|
/** |
1881
|
|
|
* @return Pipe |
1882
|
|
|
*/ |
1883
|
|
|
public function getTokenRevocationPipe(): Pipe |
1884
|
|
|
{ |
1885
|
|
|
if (null === $this->tokenRevocationPipe) { |
1886
|
|
|
$this->tokenRevocationPipe = new Pipe(); |
1887
|
|
|
|
1888
|
|
|
$this->tokenRevocationPipe->appendMiddleware($this->getOAuth2ResponseMiddleware()); |
1889
|
|
|
$this->tokenRevocationPipe->appendMiddleware($this->getClientAuthenticationMiddlewareWithRequirement()); |
1890
|
|
|
$this->tokenRevocationPipe->appendMiddleware($this->getTokenRevocationHttpMethod()); |
1891
|
|
|
} |
1892
|
|
|
|
1893
|
|
|
return $this->tokenRevocationPipe; |
1894
|
|
|
} |
1895
|
|
|
|
1896
|
|
|
/** |
1897
|
|
|
* @var null|HttpMethod |
1898
|
|
|
*/ |
1899
|
|
|
private $tokenRevocationHttpMethod = null; |
1900
|
|
|
|
1901
|
|
|
/** |
1902
|
|
|
* @return HttpMethod |
1903
|
|
|
*/ |
1904
|
|
|
public function getTokenRevocationHttpMethod(): HttpMethod |
1905
|
|
|
{ |
1906
|
|
|
if (null === $this->tokenRevocationHttpMethod) { |
1907
|
|
|
$this->tokenRevocationHttpMethod = new HttpMethod(); |
1908
|
|
|
$this->tokenRevocationHttpMethod->addMiddleware('POST', $this->getTokenRevocationPostEndpoint()); |
1909
|
|
|
$this->tokenRevocationHttpMethod->addMiddleware('GET', $this->getTokenRevocationGetEndpoint()); |
1910
|
|
|
} |
1911
|
|
|
|
1912
|
|
|
return $this->tokenRevocationHttpMethod; |
1913
|
|
|
} |
1914
|
|
|
|
1915
|
|
|
/** |
1916
|
|
|
* @var null|TokenIntrospectionEndpoint |
1917
|
|
|
*/ |
1918
|
|
|
private $tokenIntrospectionEndpoint = null; |
1919
|
|
|
|
1920
|
|
|
/** |
1921
|
|
|
* @return TokenIntrospectionEndpoint |
1922
|
|
|
*/ |
1923
|
|
|
public function getTokenIntrospectionEndpoint(): TokenIntrospectionEndpoint |
1924
|
|
|
{ |
1925
|
|
|
if (null === $this->tokenIntrospectionEndpoint) { |
1926
|
|
|
$this->tokenIntrospectionEndpoint = new TokenIntrospectionEndpoint( |
1927
|
|
|
$this->getTokenTypeHintManager(), |
1928
|
|
|
$this->getResponseFactory() |
1929
|
|
|
); |
1930
|
|
|
} |
1931
|
|
|
|
1932
|
|
|
return $this->tokenIntrospectionEndpoint; |
1933
|
|
|
} |
1934
|
|
|
|
1935
|
|
|
/** |
1936
|
|
|
* @var null|Pipe |
1937
|
|
|
*/ |
1938
|
|
|
private $tokenIntrospectionPipe = null; |
1939
|
|
|
|
1940
|
|
|
/** |
1941
|
|
|
* @return Pipe |
1942
|
|
|
*/ |
1943
|
|
|
public function getTokenIntrospectionPipe(): Pipe |
1944
|
|
|
{ |
1945
|
|
|
if (null === $this->tokenIntrospectionPipe) { |
1946
|
|
|
$this->tokenIntrospectionPipe = new Pipe(); |
1947
|
|
|
|
1948
|
|
|
$this->tokenIntrospectionPipe->appendMiddleware(new IpAddressMiddleware()); |
1949
|
|
|
$this->tokenIntrospectionPipe->appendMiddleware($this->getOAuth2ResponseMiddleware()); |
1950
|
|
|
$this->tokenIntrospectionPipe->appendMiddleware($this->getResourceServerAuthenticationMiddleware()); |
1951
|
|
|
$this->tokenIntrospectionPipe->appendMiddleware($this->getTokenIntrospectionHttpMethod()); |
1952
|
|
|
} |
1953
|
|
|
|
1954
|
|
|
return $this->tokenIntrospectionPipe; |
1955
|
|
|
} |
1956
|
|
|
|
1957
|
|
|
/** |
1958
|
|
|
* @var null|HttpMethod |
1959
|
|
|
*/ |
1960
|
|
|
private $tokenIntrospectionHttpMethod = null; |
1961
|
|
|
|
1962
|
|
|
/** |
1963
|
|
|
* @return HttpMethod |
1964
|
|
|
*/ |
1965
|
|
|
public function getTokenIntrospectionHttpMethod(): HttpMethod |
1966
|
|
|
{ |
1967
|
|
|
if (null === $this->tokenIntrospectionHttpMethod) { |
1968
|
|
|
$this->tokenIntrospectionHttpMethod = new HttpMethod(); |
1969
|
|
|
$this->tokenIntrospectionHttpMethod->addMiddleware('POST', $this->getTokenIntrospectionEndpoint()); |
1970
|
|
|
} |
1971
|
|
|
|
1972
|
|
|
return $this->tokenIntrospectionHttpMethod; |
1973
|
|
|
} |
1974
|
|
|
|
1975
|
|
|
/** |
1976
|
|
|
* @var null|AccessTokenTypeHint |
1977
|
|
|
*/ |
1978
|
|
|
private $accessTokenTypeHint = null; |
1979
|
|
|
|
1980
|
|
|
/** |
1981
|
|
|
* @return AccessTokenTypeHint |
1982
|
|
|
*/ |
1983
|
|
|
public function getAccessTokenTypeHint(): AccessTokenTypeHint |
1984
|
|
|
{ |
1985
|
|
|
if (null === $this->accessTokenTypeHint) { |
1986
|
|
|
$this->accessTokenTypeHint = new AccessTokenTypeHint( |
1987
|
|
|
$this->getAccessTokenRepository(), |
1988
|
|
|
$this->getCommandBus() |
1989
|
|
|
); |
1990
|
|
|
} |
1991
|
|
|
|
1992
|
|
|
return $this->accessTokenTypeHint; |
1993
|
|
|
} |
1994
|
|
|
|
1995
|
|
|
/** |
1996
|
|
|
* @var null|RefreshTokenTypeHint |
1997
|
|
|
*/ |
1998
|
|
|
private $refreshTokenTypeHint = null; |
1999
|
|
|
|
2000
|
|
|
/** |
2001
|
|
|
* @return RefreshTokenTypeHint |
2002
|
|
|
*/ |
2003
|
|
|
public function getRefreshTokenTypeHint(): RefreshTokenTypeHint |
2004
|
|
|
{ |
2005
|
|
|
if (null === $this->refreshTokenTypeHint) { |
2006
|
|
|
$this->refreshTokenTypeHint = new RefreshTokenTypeHint( |
2007
|
|
|
$this->getRefreshTokenRepository(), |
2008
|
|
|
$this->getCommandBus() |
2009
|
|
|
); |
2010
|
|
|
} |
2011
|
|
|
|
2012
|
|
|
return $this->refreshTokenTypeHint; |
2013
|
|
|
} |
2014
|
|
|
|
2015
|
|
|
/** |
2016
|
|
|
* @var null|AuthCodeTypeHint |
2017
|
|
|
*/ |
2018
|
|
|
private $authCodeTypeHint = null; |
2019
|
|
|
|
2020
|
|
|
/** |
2021
|
|
|
* @return AuthCodeTypeHint |
2022
|
|
|
*/ |
2023
|
|
|
public function getAuthCodeTypeHint(): AuthCodeTypeHint |
2024
|
|
|
{ |
2025
|
|
|
if (null === $this->authCodeTypeHint) { |
2026
|
|
|
$this->authCodeTypeHint = new AuthCodeTypeHint( |
2027
|
|
|
$this->getAuthorizationCodeRepository(), |
2028
|
|
|
$this->getCommandBus() |
2029
|
|
|
); |
2030
|
|
|
} |
2031
|
|
|
|
2032
|
|
|
return $this->authCodeTypeHint; |
2033
|
|
|
} |
2034
|
|
|
|
2035
|
|
|
/** |
2036
|
|
|
* @var null|AccessTokenRepositoryInterface |
2037
|
|
|
*/ |
2038
|
|
|
private $accessTokenRepository = null; |
2039
|
|
|
|
2040
|
|
|
/** |
2041
|
|
|
* @return AccessTokenRepositoryInterface |
2042
|
|
|
*/ |
2043
|
|
|
public function getAccessTokenRepository(): AccessTokenRepositoryInterface |
2044
|
|
|
{ |
2045
|
|
|
if (null === $this->accessTokenRepository) { |
2046
|
|
|
$this->accessTokenRepository = new AccessTokenRepository( |
2047
|
|
|
$this->getAccessTokenEventStore(), |
2048
|
|
|
$this->getPublicMessageRecorder(), |
2049
|
|
|
'now +10 minutes' |
2050
|
|
|
); |
2051
|
|
|
} |
2052
|
|
|
|
2053
|
|
|
return $this->accessTokenRepository; |
2054
|
|
|
} |
2055
|
|
|
|
2056
|
|
|
/** |
2057
|
|
|
* @var null|RefreshTokenRepositoryInterface |
2058
|
|
|
*/ |
2059
|
|
|
private $refreshTokenRepository = null; |
2060
|
|
|
|
2061
|
|
|
/** |
2062
|
|
|
* @return RefreshTokenRepositoryInterface |
2063
|
|
|
*/ |
2064
|
|
|
public function getRefreshTokenRepository(): RefreshTokenRepositoryInterface |
2065
|
|
|
{ |
2066
|
|
|
if (null === $this->refreshTokenRepository) { |
2067
|
|
|
$this->refreshTokenRepository = new RefreshTokenRepository( |
2068
|
|
|
$this->getRefreshTokenEventStore(), |
2069
|
|
|
$this->getPublicMessageRecorder(), |
2070
|
|
|
'now +7 day' |
2071
|
|
|
); |
2072
|
|
|
} |
2073
|
|
|
|
2074
|
|
|
return $this->refreshTokenRepository; |
2075
|
|
|
} |
2076
|
|
|
|
2077
|
|
|
/** |
2078
|
|
|
* @var null|EventStoreInterface |
2079
|
|
|
*/ |
2080
|
|
|
private $accessTokenEventStore = null; |
2081
|
|
|
|
2082
|
|
|
/** |
2083
|
|
|
* @return EventStoreInterface |
2084
|
|
|
*/ |
2085
|
|
|
public function getAccessTokenEventStore(): EventStoreInterface |
2086
|
|
|
{ |
2087
|
|
|
if (null === $this->accessTokenEventStore) { |
2088
|
|
|
$this->accessTokenEventStore = new EventStore( |
2089
|
|
|
$this->getDomainConverter() |
2090
|
|
|
); |
2091
|
|
|
} |
2092
|
|
|
|
2093
|
|
|
return $this->accessTokenEventStore; |
2094
|
|
|
} |
2095
|
|
|
|
2096
|
|
|
/** |
2097
|
|
|
* @var null|EventStoreInterface |
2098
|
|
|
*/ |
2099
|
|
|
private $initialAccessTokenEventStore = null; |
2100
|
|
|
|
2101
|
|
|
/** |
2102
|
|
|
* @return EventStoreInterface |
2103
|
|
|
*/ |
2104
|
|
|
public function getInitialAccessTokenEventStore(): EventStoreInterface |
2105
|
|
|
{ |
2106
|
|
|
if (null === $this->initialAccessTokenEventStore) { |
2107
|
|
|
$this->initialAccessTokenEventStore = new EventStore( |
2108
|
|
|
$this->getDomainConverter() |
2109
|
|
|
); |
2110
|
|
|
} |
2111
|
|
|
|
2112
|
|
|
return $this->initialAccessTokenEventStore; |
2113
|
|
|
} |
2114
|
|
|
|
2115
|
|
|
/** |
2116
|
|
|
* @var null|EventStoreInterface |
2117
|
|
|
*/ |
2118
|
|
|
private $preConfiguredAuthorizationEventStore = null; |
2119
|
|
|
|
2120
|
|
|
/** |
2121
|
|
|
* @return EventStoreInterface |
2122
|
|
|
*/ |
2123
|
|
|
public function getPreConfiguredAuthorizationEventStore(): EventStoreInterface |
2124
|
|
|
{ |
2125
|
|
|
if (null === $this->preConfiguredAuthorizationEventStore) { |
2126
|
|
|
$this->preConfiguredAuthorizationEventStore = new EventStore( |
2127
|
|
|
$this->getDomainConverter() |
2128
|
|
|
); |
2129
|
|
|
} |
2130
|
|
|
|
2131
|
|
|
return $this->preConfiguredAuthorizationEventStore; |
2132
|
|
|
} |
2133
|
|
|
|
2134
|
|
|
/** |
2135
|
|
|
* @var null|EventStoreInterface |
2136
|
|
|
*/ |
2137
|
|
|
private $refreshTokenEventStore = null; |
2138
|
|
|
|
2139
|
|
|
/** |
2140
|
|
|
* @return EventStoreInterface |
2141
|
|
|
*/ |
2142
|
|
|
public function getRefreshTokenEventStore(): EventStoreInterface |
2143
|
|
|
{ |
2144
|
|
|
if (null === $this->refreshTokenEventStore) { |
2145
|
|
|
$this->refreshTokenEventStore = new EventStore( |
2146
|
|
|
$this->getDomainConverter() |
2147
|
|
|
); |
2148
|
|
|
} |
2149
|
|
|
|
2150
|
|
|
return $this->refreshTokenEventStore; |
2151
|
|
|
} |
2152
|
|
|
|
2153
|
|
|
/** |
2154
|
|
|
* @var null|EventStoreInterface |
2155
|
|
|
*/ |
2156
|
|
|
private $authCodeEventStore = null; |
2157
|
|
|
|
2158
|
|
|
/** |
2159
|
|
|
* @return EventStoreInterface |
2160
|
|
|
*/ |
2161
|
|
|
public function getAuthCodeEventStore(): EventStoreInterface |
2162
|
|
|
{ |
2163
|
|
|
if (null === $this->authCodeEventStore) { |
2164
|
|
|
$this->authCodeEventStore = new EventStore( |
2165
|
|
|
$this->getDomainConverter() |
2166
|
|
|
); |
2167
|
|
|
} |
2168
|
|
|
|
2169
|
|
|
return $this->authCodeEventStore; |
2170
|
|
|
} |
2171
|
|
|
|
2172
|
|
|
/** |
2173
|
|
|
* @var null|EventStoreInterface |
2174
|
|
|
*/ |
2175
|
|
|
private $clientEventStore = null; |
2176
|
|
|
|
2177
|
|
|
/** |
2178
|
|
|
* @return EventStoreInterface |
2179
|
|
|
*/ |
2180
|
|
|
public function getClientEventStore(): EventStoreInterface |
2181
|
|
|
{ |
2182
|
|
|
if (null === $this->clientEventStore) { |
2183
|
|
|
$this->clientEventStore = new EventStore( |
2184
|
|
|
$this->getDomainConverter() |
2185
|
|
|
); |
2186
|
|
|
} |
2187
|
|
|
|
2188
|
|
|
return $this->clientEventStore; |
2189
|
|
|
} |
2190
|
|
|
|
2191
|
|
|
/** |
2192
|
|
|
* @var null|EventStoreInterface |
2193
|
|
|
*/ |
2194
|
|
|
private $resourceServerEventStore = null; |
2195
|
|
|
|
2196
|
|
|
/** |
2197
|
|
|
* @return EventStoreInterface |
2198
|
|
|
*/ |
2199
|
|
|
public function getResourceServerEventStore(): EventStoreInterface |
2200
|
|
|
{ |
2201
|
|
|
if (null === $this->resourceServerEventStore) { |
2202
|
|
|
$this->resourceServerEventStore = new EventStore( |
2203
|
|
|
$this->getDomainConverter() |
2204
|
|
|
); |
2205
|
|
|
} |
2206
|
|
|
|
2207
|
|
|
return $this->resourceServerEventStore; |
2208
|
|
|
} |
2209
|
|
|
|
2210
|
|
|
/** |
2211
|
|
|
* @var null|AuthCodeRepositoryInterface |
2212
|
|
|
*/ |
2213
|
|
|
private $authCodeRepository = null; |
2214
|
|
|
|
2215
|
|
|
/** |
2216
|
|
|
* @return AuthCodeRepositoryInterface |
2217
|
|
|
*/ |
2218
|
|
|
public function getAuthorizationCodeRepository(): AuthCodeRepositoryInterface |
2219
|
|
|
{ |
2220
|
|
|
if (null === $this->authCodeRepository) { |
2221
|
|
|
$this->authCodeRepository = new AuthCodeRepository( |
2222
|
|
|
$this->getAuthCodeEventStore(), |
2223
|
|
|
$this->getPublicMessageRecorder(), |
2224
|
|
|
'now +30 seconds' |
2225
|
|
|
); |
2226
|
|
|
} |
2227
|
|
|
|
2228
|
|
|
return $this->authCodeRepository; |
2229
|
|
|
} |
2230
|
|
|
|
2231
|
|
|
/** |
2232
|
|
|
* @var null|RevokeAccessTokenCommandHandler |
2233
|
|
|
*/ |
2234
|
|
|
private $revokeAccessTokenCommandHandler = null; |
2235
|
|
|
|
2236
|
|
|
/** |
2237
|
|
|
* @return RevokeAccessTokenCommandHandler |
2238
|
|
|
*/ |
2239
|
|
|
public function getRevokeAccessTokenCommandHandler(): RevokeAccessTokenCommandHandler |
2240
|
|
|
{ |
2241
|
|
|
if (null === $this->revokeAccessTokenCommandHandler) { |
2242
|
|
|
$this->revokeAccessTokenCommandHandler = new RevokeAccessTokenCommandHandler( |
2243
|
|
|
$this->getAccessTokenRepository() |
2244
|
|
|
); |
2245
|
|
|
} |
2246
|
|
|
|
2247
|
|
|
return $this->revokeAccessTokenCommandHandler; |
2248
|
|
|
} |
2249
|
|
|
|
2250
|
|
|
/** |
2251
|
|
|
* @var null|AccessTokenRevokedEventHandler |
2252
|
|
|
*/ |
2253
|
|
|
private $accessTokenRevokedEventHandler = null; |
2254
|
|
|
|
2255
|
|
|
/** |
2256
|
|
|
* @return AccessTokenRevokedEventHandler |
2257
|
|
|
*/ |
2258
|
|
|
public function getAccessTokenRevokedEventHandler(): AccessTokenRevokedEventHandler |
2259
|
|
|
{ |
2260
|
|
|
if (null === $this->accessTokenRevokedEventHandler) { |
2261
|
|
|
$this->accessTokenRevokedEventHandler = new AccessTokenRevokedEventHandler(); |
2262
|
|
|
} |
2263
|
|
|
|
2264
|
|
|
return $this->accessTokenRevokedEventHandler; |
2265
|
|
|
} |
2266
|
|
|
|
2267
|
|
|
/** |
2268
|
|
|
* @var null|AccessTokenCreatedEventHandler |
2269
|
|
|
*/ |
2270
|
|
|
private $accessTokenCreatedEventHandler = null; |
2271
|
|
|
|
2272
|
|
|
/** |
2273
|
|
|
* @return AccessTokenCreatedEventHandler |
2274
|
|
|
*/ |
2275
|
|
|
public function getAccessTokenCreatedEventHandler(): AccessTokenCreatedEventHandler |
2276
|
|
|
{ |
2277
|
|
|
if (null === $this->accessTokenCreatedEventHandler) { |
2278
|
|
|
$this->accessTokenCreatedEventHandler = new AccessTokenCreatedEventHandler(); |
2279
|
|
|
} |
2280
|
|
|
|
2281
|
|
|
return $this->accessTokenCreatedEventHandler; |
2282
|
|
|
} |
2283
|
|
|
|
2284
|
|
|
/** |
2285
|
|
|
* @var null|RefreshTokenCreatedEventHandler |
2286
|
|
|
*/ |
2287
|
|
|
private $refreshTokenCreatedEventHandler = null; |
2288
|
|
|
|
2289
|
|
|
/** |
2290
|
|
|
* @return RefreshTokenCreatedEventHandler |
2291
|
|
|
*/ |
2292
|
|
|
public function getRefreshTokenCreatedEventHandler(): RefreshTokenCreatedEventHandler |
2293
|
|
|
{ |
2294
|
|
|
if (null === $this->refreshTokenCreatedEventHandler) { |
2295
|
|
|
$this->refreshTokenCreatedEventHandler = new RefreshTokenCreatedEventHandler(); |
2296
|
|
|
} |
2297
|
|
|
|
2298
|
|
|
return $this->refreshTokenCreatedEventHandler; |
2299
|
|
|
} |
2300
|
|
|
|
2301
|
|
|
/** |
2302
|
|
|
* @var null|RefreshTokenCreatedEventHandler |
2303
|
|
|
*/ |
2304
|
|
|
private $refreshTokenRevokedEventHandler = null; |
2305
|
|
|
|
2306
|
|
|
/** |
2307
|
|
|
* @return RefreshTokenRevokedEventHandler |
2308
|
|
|
*/ |
2309
|
|
|
public function getRefreshTokenRevokedEventHandler(): RefreshTokenRevokedEventHandler |
2310
|
|
|
{ |
2311
|
|
|
if (null === $this->refreshTokenRevokedEventHandler) { |
2312
|
|
|
$this->refreshTokenRevokedEventHandler = new RefreshTokenRevokedEventHandler(); |
2313
|
|
|
} |
2314
|
|
|
|
2315
|
|
|
return $this->refreshTokenRevokedEventHandler; |
2316
|
|
|
} |
2317
|
|
|
|
2318
|
|
|
/** |
2319
|
|
|
* @var null|CreateRefreshTokenCommandHandler |
2320
|
|
|
*/ |
2321
|
|
|
private $createRefreshTokenCommandHandler = null; |
2322
|
|
|
|
2323
|
|
|
/** |
2324
|
|
|
* @return CreateRefreshTokenCommandHandler |
2325
|
|
|
*/ |
2326
|
|
|
public function getCreateRefreshTokenCommandHandler(): CreateRefreshTokenCommandHandler |
2327
|
|
|
{ |
2328
|
|
|
if (null === $this->createRefreshTokenCommandHandler) { |
2329
|
|
|
$this->createRefreshTokenCommandHandler = new CreateRefreshTokenCommandHandler( |
2330
|
|
|
$this->getRefreshTokenRepository() |
2331
|
|
|
); |
2332
|
|
|
} |
2333
|
|
|
|
2334
|
|
|
return $this->createRefreshTokenCommandHandler; |
2335
|
|
|
} |
2336
|
|
|
|
2337
|
|
|
/** |
2338
|
|
|
* @var null|RevokeRefreshTokenCommandHandler |
2339
|
|
|
*/ |
2340
|
|
|
private $revokeRefreshTokenCommandHandler = null; |
2341
|
|
|
|
2342
|
|
|
/** |
2343
|
|
|
* @return RevokeRefreshTokenCommandHandler |
2344
|
|
|
*/ |
2345
|
|
|
public function getRevokeRefreshTokenCommandHandler(): RevokeRefreshTokenCommandHandler |
2346
|
|
|
{ |
2347
|
|
|
if (null === $this->revokeRefreshTokenCommandHandler) { |
2348
|
|
|
$this->revokeRefreshTokenCommandHandler = new RevokeRefreshTokenCommandHandler( |
2349
|
|
|
$this->getRefreshTokenRepository() |
2350
|
|
|
); |
2351
|
|
|
} |
2352
|
|
|
|
2353
|
|
|
return $this->revokeRefreshTokenCommandHandler; |
2354
|
|
|
} |
2355
|
|
|
|
2356
|
|
|
/** |
2357
|
|
|
* @var null|CreateAuthCodeCommandHandler |
2358
|
|
|
*/ |
2359
|
|
|
private $createAuthCodeCommandHandler = null; |
2360
|
|
|
|
2361
|
|
|
/** |
2362
|
|
|
* @return CreateAuthCodeCommandHandler |
2363
|
|
|
*/ |
2364
|
|
|
public function getCreateAuthCodeCommandHandler(): CreateAuthCodeCommandHandler |
2365
|
|
|
{ |
2366
|
|
|
if (null === $this->createAuthCodeCommandHandler) { |
2367
|
|
|
$this->createAuthCodeCommandHandler = new CreateAuthCodeCommandHandler( |
2368
|
|
|
$this->getAuthorizationCodeRepository() |
2369
|
|
|
); |
2370
|
|
|
} |
2371
|
|
|
|
2372
|
|
|
return $this->createAuthCodeCommandHandler; |
2373
|
|
|
} |
2374
|
|
|
|
2375
|
|
|
/** |
2376
|
|
|
* @var null|MarkAuthCodeAsUsedCommandHandler |
2377
|
|
|
*/ |
2378
|
|
|
private $markAuthCodeAsUsedCommandHandler = null; |
2379
|
|
|
|
2380
|
|
|
/** |
2381
|
|
|
* @return MarkAuthCodeAsUsedCommandHandler |
2382
|
|
|
*/ |
2383
|
|
|
public function getMarkAuthCodeAsUsedCommandHandler(): MarkAuthCodeAsUsedCommandHandler |
2384
|
|
|
{ |
2385
|
|
|
if (null === $this->markAuthCodeAsUsedCommandHandler) { |
2386
|
|
|
$this->markAuthCodeAsUsedCommandHandler = new MarkAuthCodeAsUsedCommandHandler( |
2387
|
|
|
$this->getAuthorizationCodeRepository() |
2388
|
|
|
); |
2389
|
|
|
} |
2390
|
|
|
|
2391
|
|
|
return $this->markAuthCodeAsUsedCommandHandler; |
2392
|
|
|
} |
2393
|
|
|
|
2394
|
|
|
/** |
2395
|
|
|
* @var null|RevokeAuthCodeCommandHandler |
2396
|
|
|
*/ |
2397
|
|
|
private $revokeAuthCodeCommandHandler = null; |
2398
|
|
|
|
2399
|
|
|
/** |
2400
|
|
|
* @return RevokeAuthCodeCommandHandler |
2401
|
|
|
*/ |
2402
|
|
|
public function getRevokeAuthCodeCommandHandler(): RevokeAuthCodeCommandHandler |
2403
|
|
|
{ |
2404
|
|
|
if (null === $this->revokeAuthCodeCommandHandler) { |
2405
|
|
|
$this->revokeAuthCodeCommandHandler = new RevokeAuthCodeCommandHandler( |
2406
|
|
|
$this->getAuthorizationCodeRepository() |
2407
|
|
|
); |
2408
|
|
|
} |
2409
|
|
|
|
2410
|
|
|
return $this->revokeAuthCodeCommandHandler; |
2411
|
|
|
} |
2412
|
|
|
|
2413
|
|
|
/** |
2414
|
|
|
* @var null|CodeResponseType |
2415
|
|
|
*/ |
2416
|
|
|
private $grantCodeResponseType = null; |
2417
|
|
|
|
2418
|
|
|
/** |
2419
|
|
|
* @return CodeResponseType |
2420
|
|
|
*/ |
2421
|
|
|
public function getCodeResponseType(): CodeResponseType |
2422
|
|
|
{ |
2423
|
|
|
if (null === $this->grantCodeResponseType) { |
2424
|
|
|
$this->grantCodeResponseType = new CodeResponseType( |
2425
|
|
|
$this->getCommandBus(), |
2426
|
|
|
$this->getPKCEMethodManager(), |
2427
|
|
|
true |
2428
|
|
|
); |
2429
|
|
|
} |
2430
|
|
|
|
2431
|
|
|
return $this->grantCodeResponseType; |
2432
|
|
|
} |
2433
|
|
|
|
2434
|
|
|
/** |
2435
|
|
|
* @var null|TokenResponseType |
2436
|
|
|
*/ |
2437
|
|
|
private $tokenResponseType = null; |
2438
|
|
|
|
2439
|
|
|
/** |
2440
|
|
|
* @return TokenResponseType |
2441
|
|
|
*/ |
2442
|
|
|
public function getTokenResponseType(): TokenResponseType |
2443
|
|
|
{ |
2444
|
|
|
if (null === $this->tokenResponseType) { |
2445
|
|
|
$this->tokenResponseType = new TokenResponseType( |
2446
|
|
|
$this->getCommandBus() |
2447
|
|
|
); |
2448
|
|
|
} |
2449
|
|
|
|
2450
|
|
|
return $this->tokenResponseType; |
2451
|
|
|
} |
2452
|
|
|
|
2453
|
|
|
/** |
2454
|
|
|
* @var null|IdTokenResponseType |
2455
|
|
|
*/ |
2456
|
|
|
private $idTokenResponseType = null; |
2457
|
|
|
|
2458
|
|
|
/** |
2459
|
|
|
* @return IdTokenResponseType |
2460
|
|
|
*/ |
2461
|
|
|
public function getIdTokenResponseType(): IdTokenResponseType |
2462
|
|
|
{ |
2463
|
|
|
if (null === $this->idTokenResponseType) { |
2464
|
|
|
$this->idTokenResponseType = new IdTokenResponseType( |
2465
|
|
|
$this->getIdTokenBuilderFactory(), |
2466
|
|
|
'RS256' |
2467
|
|
|
); |
2468
|
|
|
} |
2469
|
|
|
|
2470
|
|
|
return $this->idTokenResponseType; |
2471
|
|
|
} |
2472
|
|
|
|
2473
|
|
|
/** |
2474
|
|
|
* @var null|NoneResponseType |
2475
|
|
|
*/ |
2476
|
|
|
private $noneResponseType = null; |
2477
|
|
|
|
2478
|
|
|
/** |
2479
|
|
|
* @return NoneResponseType |
2480
|
|
|
*/ |
2481
|
|
|
public function getNoneResponseType(): NoneResponseType |
2482
|
|
|
{ |
2483
|
|
|
if (null === $this->noneResponseType) { |
2484
|
|
|
$this->noneResponseType = new NoneResponseType( |
2485
|
|
|
$this->getCommandBus() |
2486
|
|
|
); |
2487
|
|
|
} |
2488
|
|
|
|
2489
|
|
|
return $this->noneResponseType; |
2490
|
|
|
} |
2491
|
|
|
|
2492
|
|
|
/** |
2493
|
|
|
* @var null|TokenEndpoint |
2494
|
|
|
*/ |
2495
|
|
|
private $tokenEndpoint = null; |
2496
|
|
|
|
2497
|
|
|
/** |
2498
|
|
|
* @return TokenEndpoint |
2499
|
|
|
*/ |
2500
|
|
|
public function getTokenEndpoint(): TokenEndpoint |
2501
|
|
|
{ |
2502
|
|
|
if (null === $this->tokenEndpoint) { |
2503
|
|
|
$this->tokenEndpoint = new TokenEndpoint( |
2504
|
|
|
$this->getProcessorManager(), |
2505
|
|
|
$this->getClientRepository(), |
2506
|
|
|
$this->getUserAccountRepository(), |
2507
|
|
|
$this->getTokenEndpointExtensionManager(), |
2508
|
|
|
$this->getResponseFactory(), |
2509
|
|
|
$this->getCommandBus() |
2510
|
|
|
); |
2511
|
|
|
} |
2512
|
|
|
|
2513
|
|
|
return $this->tokenEndpoint; |
2514
|
|
|
} |
2515
|
|
|
|
2516
|
|
|
/** |
2517
|
|
|
* @var null|ProcessorManager |
2518
|
|
|
*/ |
2519
|
|
|
private $processorManager = null; |
2520
|
|
|
|
2521
|
|
|
/** |
2522
|
|
|
* @return ProcessorManager |
2523
|
|
|
*/ |
2524
|
|
|
public function getProcessorManager(): ProcessorManager |
2525
|
|
|
{ |
2526
|
|
|
if (null === $this->processorManager) { |
2527
|
|
|
$this->processorManager = new ProcessorManager( |
2528
|
|
|
$this->getScopeRepository() |
2529
|
|
|
); |
2530
|
|
|
} |
2531
|
|
|
|
2532
|
|
|
return $this->processorManager; |
2533
|
|
|
} |
2534
|
|
|
|
2535
|
|
|
/** |
2536
|
|
|
* @var null|TokenTypeManager |
2537
|
|
|
*/ |
2538
|
|
|
private $tokenTypeManager = null; |
2539
|
|
|
|
2540
|
|
|
/** |
2541
|
|
|
* @return TokenTypeManager |
2542
|
|
|
*/ |
2543
|
|
|
public function getTokenTypeManager(): TokenTypeManager |
2544
|
|
|
{ |
2545
|
|
|
if (null === $this->tokenTypeManager) { |
2546
|
|
|
$this->tokenTypeManager = new TokenTypeManager(); |
2547
|
|
|
$this->tokenTypeManager->add($this->getBearerTokenType()); |
2548
|
|
|
$this->tokenTypeManager->add($this->getMacTokenType()); |
2549
|
|
|
} |
2550
|
|
|
|
2551
|
|
|
return $this->tokenTypeManager; |
2552
|
|
|
} |
2553
|
|
|
|
2554
|
|
|
/** |
2555
|
|
|
* @var null|GrantTypeMiddleware |
2556
|
|
|
*/ |
2557
|
|
|
private $grantTypeMiddleware = null; |
2558
|
|
|
|
2559
|
|
|
/** |
2560
|
|
|
* @return GrantTypeMiddleware |
2561
|
|
|
*/ |
2562
|
|
|
public function getGrantTypeMiddleware(): GrantTypeMiddleware |
2563
|
|
|
{ |
2564
|
|
|
if (null === $this->grantTypeMiddleware) { |
2565
|
|
|
$this->grantTypeMiddleware = new GrantTypeMiddleware( |
2566
|
|
|
$this->getGrantTypeManager() |
2567
|
|
|
); |
2568
|
|
|
} |
2569
|
|
|
|
2570
|
|
|
return $this->grantTypeMiddleware; |
2571
|
|
|
} |
2572
|
|
|
|
2573
|
|
|
/** |
2574
|
|
|
* @var null|Pipe |
2575
|
|
|
*/ |
2576
|
|
|
private $tokenEndpointPipe = null; |
2577
|
|
|
|
2578
|
|
|
/** |
2579
|
|
|
* @return Pipe |
2580
|
|
|
*/ |
2581
|
|
|
public function getTokenEndpointPipe(): Pipe |
2582
|
|
|
{ |
2583
|
|
|
if (null === $this->tokenEndpointPipe) { |
2584
|
|
|
$this->tokenEndpointPipe = new Pipe(); |
2585
|
|
|
$this->tokenEndpointPipe->appendMiddleware($this->getOAuth2ResponseMiddleware()); |
2586
|
|
|
$this->tokenEndpointPipe->appendMiddleware($this->getClientAuthenticationMiddleware()); |
2587
|
|
|
$this->tokenEndpointPipe->appendMiddleware($this->getGrantTypeMiddleware()); |
2588
|
|
|
$this->tokenEndpointPipe->appendMiddleware($this->getTokenTypeMiddleware()); |
2589
|
|
|
$this->tokenEndpointPipe->appendMiddleware($this->getTokenEndpoint()); |
2590
|
|
|
} |
2591
|
|
|
|
2592
|
|
|
return $this->tokenEndpointPipe; |
2593
|
|
|
} |
2594
|
|
|
|
2595
|
|
|
/** |
2596
|
|
|
* @var null|TokenTypeMiddleware |
2597
|
|
|
*/ |
2598
|
|
|
private $tokenTypeMiddleware = null; |
2599
|
|
|
|
2600
|
|
|
/** |
2601
|
|
|
* @return TokenTypeMiddleware |
2602
|
|
|
*/ |
2603
|
|
|
public function getTokenTypeMiddleware(): TokenTypeMiddleware |
2604
|
|
|
{ |
2605
|
|
|
if (null === $this->tokenTypeMiddleware) { |
2606
|
|
|
$this->tokenTypeMiddleware = new TokenTypeMiddleware( |
2607
|
|
|
$this->getTokenTypeManager(), |
2608
|
|
|
true |
2609
|
|
|
); |
2610
|
|
|
} |
2611
|
|
|
|
2612
|
|
|
return $this->tokenTypeMiddleware; |
2613
|
|
|
} |
2614
|
|
|
|
2615
|
|
|
/** |
2616
|
|
|
* @var null|CreateAccessTokenCommandHandler |
2617
|
|
|
*/ |
2618
|
|
|
private $createAccessTokenCommandHandler = null; |
2619
|
|
|
|
2620
|
|
|
/** |
2621
|
|
|
* @return CreateAccessTokenCommandHandler |
2622
|
|
|
*/ |
2623
|
|
|
public function getCreateAccessTokenCommandHandler(): CreateAccessTokenCommandHandler |
2624
|
|
|
{ |
2625
|
|
|
if (null === $this->createAccessTokenCommandHandler) { |
2626
|
|
|
$this->createAccessTokenCommandHandler = new CreateAccessTokenCommandHandler( |
2627
|
|
|
$this->getAccessTokenRepository() |
2628
|
|
|
); |
2629
|
|
|
} |
2630
|
|
|
|
2631
|
|
|
return $this->createAccessTokenCommandHandler; |
2632
|
|
|
} |
2633
|
|
|
|
2634
|
|
|
/** |
2635
|
|
|
* @var null|CreateAccessTokenWithRefreshTokenCommandHandler |
2636
|
|
|
*/ |
2637
|
|
|
private $createAccessTokenWithRefreshTokenCommandHandler = null; |
2638
|
|
|
|
2639
|
|
|
/** |
2640
|
|
|
* @return CreateAccessTokenWithRefreshTokenCommandHandler |
2641
|
|
|
*/ |
2642
|
|
|
public function getCreateAccessTokenWithRefreshTokenCommandHandler(): CreateAccessTokenWithRefreshTokenCommandHandler |
2643
|
|
|
{ |
2644
|
|
|
if (null === $this->createAccessTokenWithRefreshTokenCommandHandler) { |
2645
|
|
|
$this->createAccessTokenWithRefreshTokenCommandHandler = new CreateAccessTokenWithRefreshTokenCommandHandler( |
2646
|
|
|
$this->getAccessTokenRepository(), |
2647
|
|
|
$this->getRefreshTokenRepository() |
2648
|
|
|
); |
2649
|
|
|
} |
2650
|
|
|
|
2651
|
|
|
return $this->createAccessTokenWithRefreshTokenCommandHandler; |
2652
|
|
|
} |
2653
|
|
|
|
2654
|
|
|
/** |
2655
|
|
|
* @var null|UserInfoEndpoint |
2656
|
|
|
*/ |
2657
|
|
|
private $userInfoEndpoint = null; |
2658
|
|
|
|
2659
|
|
|
/** |
2660
|
|
|
* @return UserInfoEndpoint |
2661
|
|
|
*/ |
2662
|
|
|
public function getUserInfoEndpoint(): UserInfoEndpoint |
2663
|
|
|
{ |
2664
|
|
|
if (null === $this->userInfoEndpoint) { |
2665
|
|
|
$this->userInfoEndpoint = new UserInfoEndpoint( |
2666
|
|
|
$this->getIdTokenBuilderFactory(), |
2667
|
|
|
$this->getClientRepository(), |
2668
|
|
|
$this->getUserAccountRepository(), |
2669
|
|
|
$this->getResponseFactory() |
2670
|
|
|
); |
2671
|
|
|
} |
2672
|
|
|
|
2673
|
|
|
return $this->userInfoEndpoint; |
2674
|
|
|
} |
2675
|
|
|
|
2676
|
|
|
/** |
2677
|
|
|
* @var null|UserInfo |
2678
|
|
|
*/ |
2679
|
|
|
private $userInfo = null; |
2680
|
|
|
|
2681
|
|
|
/** |
2682
|
|
|
* @return UserInfo |
2683
|
|
|
*/ |
2684
|
|
|
public function getUserInfo(): UserInfo |
2685
|
|
|
{ |
2686
|
|
|
if (null === $this->userInfo) { |
2687
|
|
|
$this->userInfo = new UserInfo( |
2688
|
|
|
$this->getUserInfoScopeSupportManager(), |
2689
|
|
|
$this->getClaimSourceManager() |
2690
|
|
|
); |
2691
|
|
|
$this->userInfo->enablePairwiseSubject( |
2692
|
|
|
$this->getPairwiseSubjectIdentifierAlgorithm(), |
2693
|
|
|
true |
2694
|
|
|
); |
2695
|
|
|
} |
2696
|
|
|
|
2697
|
|
|
return $this->userInfo; |
2698
|
|
|
} |
2699
|
|
|
|
2700
|
|
|
/** |
2701
|
|
|
* @var null|PairwiseSubjectIdentifierAlgorithmInterface |
2702
|
|
|
*/ |
2703
|
|
|
private $pairwiseSubjectIdentifierAlgorithm = null; |
2704
|
|
|
|
2705
|
|
|
/** |
2706
|
|
|
* @return PairwiseSubjectIdentifierAlgorithmInterface |
2707
|
|
|
*/ |
2708
|
|
|
public function getPairwiseSubjectIdentifierAlgorithm(): PairwiseSubjectIdentifierAlgorithmInterface |
2709
|
|
|
{ |
2710
|
|
|
if (null === $this->pairwiseSubjectIdentifierAlgorithm) { |
2711
|
|
|
$this->pairwiseSubjectIdentifierAlgorithm = new EncryptedSubjectIdentifier( |
2712
|
|
|
$this->getPairwiseKey(), |
2713
|
|
|
'aes-128-cbc', |
2714
|
|
|
$this->getPairwiseAdditionalData(), |
2715
|
|
|
$this->getPairwiseAdditionalData() |
2716
|
|
|
); |
2717
|
|
|
} |
2718
|
|
|
|
2719
|
|
|
return $this->pairwiseSubjectIdentifierAlgorithm; |
2720
|
|
|
} |
2721
|
|
|
|
2722
|
|
|
/** |
2723
|
|
|
* @var null|UserInfoScopeSupportManager |
2724
|
|
|
*/ |
2725
|
|
|
private $userInfoScopeSupportManager = null; |
2726
|
|
|
|
2727
|
|
|
/** |
2728
|
|
|
* @return UserInfoScopeSupportManager |
2729
|
|
|
*/ |
2730
|
|
|
public function getUserInfoScopeSupportManager(): UserInfoScopeSupportManager |
2731
|
|
|
{ |
2732
|
|
|
if (null === $this->userInfoScopeSupportManager) { |
2733
|
|
|
$this->userInfoScopeSupportManager = new UserInfoScopeSupportManager(); |
2734
|
|
|
$this->userInfoScopeSupportManager->add(new AddressScopeSupport()); |
2735
|
|
|
$this->userInfoScopeSupportManager->add(new EmailScopeSupport()); |
2736
|
|
|
$this->userInfoScopeSupportManager->add(new PhoneScopeSupport()); |
2737
|
|
|
$this->userInfoScopeSupportManager->add(new ProfilScopeSupport()); |
2738
|
|
|
} |
2739
|
|
|
|
2740
|
|
|
return $this->userInfoScopeSupportManager; |
2741
|
|
|
} |
2742
|
|
|
|
2743
|
|
|
/** |
2744
|
|
|
* @var null|ClaimSourceManager |
2745
|
|
|
*/ |
2746
|
|
|
private $claimSourceManager = null; |
2747
|
|
|
|
2748
|
|
|
/** |
2749
|
|
|
* @return ClaimSourceManager |
2750
|
|
|
*/ |
2751
|
|
|
public function getClaimSourceManager(): ClaimSourceManager |
2752
|
|
|
{ |
2753
|
|
|
if (null === $this->claimSourceManager) { |
2754
|
|
|
$this->claimSourceManager = new ClaimSourceManager(); |
2755
|
|
|
$this->claimSourceManager->add(new DistributedClaimSource()); |
2756
|
|
|
} |
2757
|
|
|
|
2758
|
|
|
return $this->claimSourceManager; |
2759
|
|
|
} |
2760
|
|
|
|
2761
|
|
|
/** |
2762
|
|
|
* @var null|Pipe |
2763
|
|
|
*/ |
2764
|
|
|
private $userInfoEndpointPipe = null; |
2765
|
|
|
|
2766
|
|
|
/** |
2767
|
|
|
* @return Pipe |
2768
|
|
|
*/ |
2769
|
|
|
public function getUserInfoEndpointPipe(): Pipe |
2770
|
|
|
{ |
2771
|
|
|
if (null === $this->userInfoEndpointPipe) { |
2772
|
|
|
$this->userInfoEndpointPipe = new Pipe(); |
2773
|
|
|
$this->userInfoEndpointPipe->appendMiddleware($this->getOAuth2ResponseMiddleware()); |
2774
|
|
|
$this->userInfoEndpointPipe->appendMiddleware($this->getSecurityMiddleware()); |
2775
|
|
|
$this->userInfoEndpointPipe->appendMiddleware($this->getUserInfoEndpoint()); |
2776
|
|
|
} |
2777
|
|
|
|
2778
|
|
|
return $this->userInfoEndpointPipe; |
2779
|
|
|
} |
2780
|
|
|
|
2781
|
|
|
/** |
2782
|
|
|
* @var null|OAuth2SecurityMiddleware |
2783
|
|
|
*/ |
2784
|
|
|
private $securityMiddleware = null; |
2785
|
|
|
|
2786
|
|
|
/** |
2787
|
|
|
* @return OAuth2SecurityMiddleware |
2788
|
|
|
*/ |
2789
|
|
|
public function getSecurityMiddleware(): OAuth2SecurityMiddleware |
2790
|
|
|
{ |
2791
|
|
|
if (null === $this->securityMiddleware) { |
2792
|
|
|
$this->securityMiddleware = new OAuth2SecurityMiddleware( |
2793
|
|
|
$this->getTokenTypeManager(), |
2794
|
|
|
$this->getAccessTokenHandlerManager(), |
2795
|
|
|
'openid' |
2796
|
|
|
); |
2797
|
|
|
} |
2798
|
|
|
|
2799
|
|
|
return $this->securityMiddleware; |
2800
|
|
|
} |
2801
|
|
|
|
2802
|
|
|
/** |
2803
|
|
|
* @var null|AccessTokenHandlerManager |
2804
|
|
|
*/ |
2805
|
|
|
private $accessTokenHandlerManager = null; |
2806
|
|
|
|
2807
|
|
|
/** |
2808
|
|
|
* @return AccessTokenHandlerManager |
2809
|
|
|
*/ |
2810
|
|
|
public function getAccessTokenHandlerManager(): AccessTokenHandlerManager |
2811
|
|
|
{ |
2812
|
|
|
if (null === $this->accessTokenHandlerManager) { |
2813
|
|
|
$this->accessTokenHandlerManager = new AccessTokenHandlerManager(); |
2814
|
|
|
$this->accessTokenHandlerManager->add(new AccessTokenHandlerUsingRepository( |
2815
|
|
|
$this->getAccessTokenRepository() |
2816
|
|
|
)); |
2817
|
|
|
} |
2818
|
|
|
|
2819
|
|
|
return $this->accessTokenHandlerManager; |
2820
|
|
|
} |
2821
|
|
|
|
2822
|
|
|
/** |
2823
|
|
|
* @var null|IssuerDiscoveryEndpoint |
2824
|
|
|
*/ |
2825
|
|
|
private $issuerDiscoveryEndpoint = null; |
2826
|
|
|
|
2827
|
|
|
/** |
2828
|
|
|
* @return IssuerDiscoveryEndpoint |
2829
|
|
|
*/ |
2830
|
|
|
public function getIssuerDiscoveryEndpoint(): IssuerDiscoveryEndpoint |
2831
|
|
|
{ |
2832
|
|
|
if (null === $this->issuerDiscoveryEndpoint) { |
2833
|
|
|
$this->issuerDiscoveryEndpoint = new IssuerDiscoveryEndpoint( |
2834
|
|
|
$this->getResourceRepository(), |
2835
|
|
|
$this->getResponseFactory(), |
2836
|
|
|
$this->getUriFactory(), |
2837
|
|
|
'https://my-service.com:9000/' |
2838
|
|
|
); |
2839
|
|
|
} |
2840
|
|
|
|
2841
|
|
|
return $this->issuerDiscoveryEndpoint; |
2842
|
|
|
} |
2843
|
|
|
|
2844
|
|
|
/** |
2845
|
|
|
* @var null|ResourceRepository |
2846
|
|
|
*/ |
2847
|
|
|
private $resourceRepository = null; |
2848
|
|
|
|
2849
|
|
|
/** |
2850
|
|
|
* @return ResourceRepository |
2851
|
|
|
*/ |
2852
|
|
|
public function getResourceRepository(): ResourceRepository |
2853
|
|
|
{ |
2854
|
|
|
if (null === $this->resourceRepository) { |
2855
|
|
|
$this->resourceRepository = new ResourceRepository(); |
2856
|
|
|
} |
2857
|
|
|
|
2858
|
|
|
return $this->resourceRepository; |
2859
|
|
|
} |
2860
|
|
|
|
2861
|
|
|
/** |
2862
|
|
|
* @var null|Pipe |
2863
|
|
|
*/ |
2864
|
|
|
private $issuerDiscoveryPipe = null; |
2865
|
|
|
|
2866
|
|
|
/** |
2867
|
|
|
* @return Pipe |
2868
|
|
|
*/ |
2869
|
|
|
public function getIssuerDiscoveryPipe(): Pipe |
2870
|
|
|
{ |
2871
|
|
|
if (null === $this->issuerDiscoveryPipe) { |
2872
|
|
|
$this->issuerDiscoveryPipe = new Pipe(); |
2873
|
|
|
$this->issuerDiscoveryPipe->appendMiddleware($this->getOAuth2ResponseMiddleware()); |
2874
|
|
|
$this->issuerDiscoveryPipe->appendMiddleware($this->getIssuerDiscoveryEndpoint()); |
2875
|
|
|
} |
2876
|
|
|
|
2877
|
|
|
return $this->issuerDiscoveryPipe; |
2878
|
|
|
} |
2879
|
|
|
|
2880
|
|
|
/** |
2881
|
|
|
* @var null|Pipe |
2882
|
|
|
*/ |
2883
|
|
|
private $JWKSetEndpointPipe = null; |
2884
|
|
|
|
2885
|
|
|
/** |
2886
|
|
|
* @return Pipe |
2887
|
|
|
*/ |
2888
|
|
|
public function getJWKSetEndpointPipe(): Pipe |
2889
|
|
|
{ |
2890
|
|
|
if (null === $this->JWKSetEndpointPipe) { |
2891
|
|
|
$this->JWKSetEndpointPipe = new Pipe(); |
2892
|
|
|
$this->JWKSetEndpointPipe->appendMiddleware($this->getJWKSetEndpoint()); |
2893
|
|
|
} |
2894
|
|
|
|
2895
|
|
|
return $this->JWKSetEndpointPipe; |
2896
|
|
|
} |
2897
|
|
|
|
2898
|
|
|
/** |
2899
|
|
|
* @var null|JWKSetEndpoint |
2900
|
|
|
*/ |
2901
|
|
|
private $JWKSetEndpoint = null; |
2902
|
|
|
|
2903
|
|
|
/** |
2904
|
|
|
* @return JWKSetEndpoint |
2905
|
|
|
*/ |
2906
|
|
|
public function getJWKSetEndpoint(): JWKSetEndpoint |
2907
|
|
|
{ |
2908
|
|
|
if (null === $this->JWKSetEndpoint) { |
2909
|
|
|
$this->JWKSetEndpoint = new JWKSetEndpoint( |
2910
|
|
|
$this->getResponseFactory(), |
2911
|
|
|
$this->getPublicKeys() |
2912
|
|
|
); |
2913
|
|
|
} |
2914
|
|
|
|
2915
|
|
|
return $this->JWKSetEndpoint; |
2916
|
|
|
} |
2917
|
|
|
|
2918
|
|
|
/** |
2919
|
|
|
* @var null|Pipe |
2920
|
|
|
*/ |
2921
|
|
|
private $iFrameEndpointPipe = null; |
2922
|
|
|
|
2923
|
|
|
/** |
2924
|
|
|
* @return Pipe |
2925
|
|
|
*/ |
2926
|
|
|
public function getIFrameEndpointPipe(): Pipe |
2927
|
|
|
{ |
2928
|
|
|
if (null === $this->iFrameEndpointPipe) { |
2929
|
|
|
$this->iFrameEndpointPipe = new Pipe(); |
2930
|
|
|
$this->iFrameEndpointPipe->appendMiddleware($this->getIFrameEndpoint()); |
2931
|
|
|
} |
2932
|
|
|
|
2933
|
|
|
return $this->iFrameEndpointPipe; |
2934
|
|
|
} |
2935
|
|
|
|
2936
|
|
|
/** |
2937
|
|
|
* @var null|IFrameEndpoint |
2938
|
|
|
*/ |
2939
|
|
|
private $iFrameEndpoint = null; |
2940
|
|
|
|
2941
|
|
|
/** |
2942
|
|
|
* @return IFrameEndpoint |
2943
|
|
|
*/ |
2944
|
|
|
public function getIFrameEndpoint(): IFrameEndpoint |
2945
|
|
|
{ |
2946
|
|
|
if (null === $this->iFrameEndpoint) { |
2947
|
|
|
$this->iFrameEndpoint = new IFrameEndpoint( |
2948
|
|
|
$this->getResponseFactory()); |
2949
|
|
|
} |
2950
|
|
|
|
2951
|
|
|
return $this->iFrameEndpoint; |
2952
|
|
|
} |
2953
|
|
|
|
2954
|
|
|
/** |
2955
|
|
|
* @var null|Pipe |
2956
|
|
|
*/ |
2957
|
|
|
private $metadataEndpointPipe = null; |
2958
|
|
|
|
2959
|
|
|
/** |
2960
|
|
|
* @return Pipe |
2961
|
|
|
*/ |
2962
|
|
|
public function getMetadataEndpointPipe(): Pipe |
2963
|
|
|
{ |
2964
|
|
|
if (null === $this->metadataEndpointPipe) { |
2965
|
|
|
$this->metadataEndpointPipe = new Pipe(); |
2966
|
|
|
$this->metadataEndpointPipe->appendMiddleware($this->getMetadataEndpoint()); |
2967
|
|
|
} |
2968
|
|
|
|
2969
|
|
|
return $this->metadataEndpointPipe; |
2970
|
|
|
} |
2971
|
|
|
|
2972
|
|
|
/** |
2973
|
|
|
* @var null|MetadataEndpoint |
2974
|
|
|
*/ |
2975
|
|
|
private $metadataEndpoint = null; |
2976
|
|
|
|
2977
|
|
|
/** |
2978
|
|
|
* @return MetadataEndpoint |
2979
|
|
|
*/ |
2980
|
|
|
public function getMetadataEndpoint(): MetadataEndpoint |
2981
|
|
|
{ |
2982
|
|
|
if (null === $this->metadataEndpoint) { |
2983
|
|
|
$this->metadataEndpoint = new MetadataEndpoint( |
2984
|
|
|
$this->getResponseFactory(), |
2985
|
|
|
$this->getMetadata() |
2986
|
|
|
); |
2987
|
|
|
$this->metadataEndpoint->enableSignedMetadata( |
2988
|
|
|
$this->getJwtCreator(), |
2989
|
|
|
'RS256', |
2990
|
|
|
$this->getPrivateKeys() |
2991
|
|
|
); |
2992
|
|
|
} |
2993
|
|
|
|
2994
|
|
|
return $this->metadataEndpoint; |
2995
|
|
|
} |
2996
|
|
|
|
2997
|
|
|
/** |
2998
|
|
|
* @var null|Metadata |
2999
|
|
|
*/ |
3000
|
|
|
private $metadata = null; |
3001
|
|
|
|
3002
|
|
|
/** |
3003
|
|
|
* @return Metadata |
3004
|
|
|
*/ |
3005
|
|
|
public function getMetadata(): Metadata |
3006
|
|
|
{ |
3007
|
|
|
if (null === $this->metadata) { |
3008
|
|
|
$this->metadata = new Metadata(); |
3009
|
|
|
$this->metadata->set('issuer', 'https://my.server.com/'); |
3010
|
|
|
$this->metadata->set('authorization_endpoint', 'https://my.server.com/authorize'); |
3011
|
|
|
$this->metadata->set('token_endpoint', 'https://my.server.com/token'); |
3012
|
|
|
$this->metadata->set('userinfo_endpoint', 'https://my.server.com/user_info'); |
3013
|
|
|
$this->metadata->set('jwks_uri', 'https://my.server.com/jwks'); |
3014
|
|
|
$this->metadata->set('registration_endpoint', 'https://my.server.com/register'); |
3015
|
|
|
$this->metadata->set('scopes_supported', $this->getScopeRepository()->getSupportedScopes()); |
3016
|
|
|
$this->metadata->set('response_types_supported', $this->getResponseTypeManager()->all()); |
3017
|
|
|
if ($this->getResponseTypeAndResponseModeParameterChecker()->isResponseModeParameterInAuthorizationRequestAllowed()) { |
3018
|
|
|
$this->metadata->set('response_modes_supported', $this->getResponseModeManager()->getSupportedResponseModes()); |
3019
|
|
|
} |
3020
|
|
|
$this->metadata->set('grant_types_supported', $this->getGrantTypeManager()->getSupportedGrantTypes()); |
3021
|
|
|
$this->metadata->set('acr_values_supported', []); |
3022
|
|
|
$this->metadata->set('subject_types_supported', $this->getUserInfo()->isPairwiseSubjectIdentifierSupported() ? ['public', 'pairwise'] : ['public']); |
3023
|
|
|
$this->metadata->set('id_token_signing_alg_values_supported', $this->getJwtCreator()->getSupportedSignatureAlgorithms()); |
3024
|
|
|
$this->metadata->set('id_token_encryption_alg_values_supported', $this->getJwtCreator()->getSupportedKeyEncryptionAlgorithms()); |
3025
|
|
|
$this->metadata->set('id_token_encryption_enc_values_supported', $this->getJwtCreator()->getSupportedContentEncryptionAlgorithms()); |
3026
|
|
|
$this->metadata->set('userinfo_signing_alg_values_supported', $this->getJwtCreator()->getSupportedSignatureAlgorithms()); |
3027
|
|
|
$this->metadata->set('userinfo_encryption_alg_values_supported', $this->getJwtCreator()->getSupportedKeyEncryptionAlgorithms()); |
3028
|
|
|
$this->metadata->set('userinfo_encryption_enc_values_supported', $this->getJwtCreator()->getSupportedContentEncryptionAlgorithms()); |
3029
|
|
|
$this->metadata->set('request_object_signing_alg_values_supported', $this->getJWTLoader()->getSupportedSignatureAlgorithms()); |
3030
|
|
|
$this->metadata->set('request_object_encryption_alg_values_supported', $this->getJWTLoader()->getSupportedKeyEncryptionAlgorithms()); |
3031
|
|
|
$this->metadata->set('request_object_encryption_enc_values_supported', $this->getJWTLoader()->getSupportedContentEncryptionAlgorithms()); |
3032
|
|
|
$this->metadata->set('token_endpoint_auth_methods_supported', $this->getTokenEndpointAuthMethodManager()->getSupportedTokenEndpointAuthMethods()); |
3033
|
|
|
$this->metadata->set('token_endpoint_auth_signing_alg_values_supported', $this->getJWTLoader()->getSupportedSignatureAlgorithms()); |
3034
|
|
|
$this->metadata->set('token_endpoint_auth_encryption_alg_values_supported', $this->getJWTLoader()->getSupportedKeyEncryptionAlgorithms()); |
3035
|
|
|
$this->metadata->set('token_endpoint_auth_encryption_enc_values_supported', $this->getJWTLoader()->getSupportedContentEncryptionAlgorithms()); |
3036
|
|
|
$this->metadata->set('display_values_supported', ['page']); |
3037
|
|
|
$this->metadata->set('claim_types_supported', false); |
3038
|
|
|
$this->metadata->set('claims_supported', false); |
3039
|
|
|
$this->metadata->set('service_documentation', 'https://my.server.com/documentation'); |
3040
|
|
|
$this->metadata->set('claims_locales_supported', []); |
3041
|
|
|
$this->metadata->set('ui_locales_supported', ['en_US', 'fr_FR']); |
3042
|
|
|
$this->metadata->set('claims_parameter_supported', false); |
3043
|
|
|
$this->metadata->set('request_parameter_supported', $this->getAuthorizationRequestLoader()->isRequestObjectSupportEnabled()); |
3044
|
|
|
$this->metadata->set('request_uri_parameter_supported', $this->getAuthorizationRequestLoader()->isRequestObjectReferenceSupportEnabled()); |
3045
|
|
|
$this->metadata->set('require_request_uri_registration', true); |
3046
|
|
|
$this->metadata->set('op_policy_uri', 'https://my.server.com/policy.html'); |
3047
|
|
|
$this->metadata->set('op_tos_uri', 'https://my.server.com/tos.html'); |
3048
|
|
|
} |
3049
|
|
|
|
3050
|
|
|
return $this->metadata; |
3051
|
|
|
} |
3052
|
|
|
|
3053
|
|
|
/** |
3054
|
|
|
* @var null|TokenEndpointExtensionManager |
3055
|
|
|
*/ |
3056
|
|
|
private $accessTokenParameterExtensionManager = null; |
3057
|
|
|
|
3058
|
|
|
/** |
3059
|
|
|
* @return TokenEndpointExtensionManager |
3060
|
|
|
*/ |
3061
|
|
|
public function getTokenEndpointExtensionManager(): TokenEndpointExtensionManager |
3062
|
|
|
{ |
3063
|
|
|
if (null === $this->accessTokenParameterExtensionManager) { |
3064
|
|
|
$this->accessTokenParameterExtensionManager = new TokenEndpointExtensionManager(); |
3065
|
|
|
$this->accessTokenParameterExtensionManager->add($this->getOpenIdConnectExtension()); |
3066
|
|
|
} |
3067
|
|
|
|
3068
|
|
|
return $this->accessTokenParameterExtensionManager; |
3069
|
|
|
} |
3070
|
|
|
|
3071
|
|
|
/** |
3072
|
|
|
* @var null|OpenIdConnectExtension |
3073
|
|
|
*/ |
3074
|
|
|
private $openIdConnectExtension = null; |
3075
|
|
|
|
3076
|
|
|
/** |
3077
|
|
|
* @return OpenIdConnectExtension |
3078
|
|
|
*/ |
3079
|
|
|
public function getOpenIdConnectExtension(): OpenIdConnectExtension |
3080
|
|
|
{ |
3081
|
|
|
if (null === $this->openIdConnectExtension) { |
3082
|
|
|
$this->openIdConnectExtension = new OpenIdConnectExtension( |
3083
|
|
|
$this->getIdTokenBuilderFactory(), |
3084
|
|
|
'RS256' |
3085
|
|
|
); |
3086
|
|
|
} |
3087
|
|
|
|
3088
|
|
|
return $this->openIdConnectExtension; |
3089
|
|
|
} |
3090
|
|
|
|
3091
|
|
|
/** |
3092
|
|
|
* @var null|IdTokenBuilderFactory |
3093
|
|
|
*/ |
3094
|
|
|
private $idTokenBuilderFactory = null; |
3095
|
|
|
|
3096
|
|
|
/** |
3097
|
|
|
* @return IdTokenBuilderFactory |
3098
|
|
|
*/ |
3099
|
|
|
public function getIdTokenBuilderFactory(): IdTokenBuilderFactory |
3100
|
|
|
{ |
3101
|
|
|
if (null === $this->idTokenBuilderFactory) { |
3102
|
|
|
$this->idTokenBuilderFactory = new IdTokenBuilderFactory( |
3103
|
|
|
$this->getJwtCreator(), |
3104
|
|
|
'https://www.my-service.com', |
3105
|
|
|
$this->getUserInfo(), |
3106
|
|
|
$this->getPrivateKeys(), |
3107
|
|
|
600 |
3108
|
|
|
); |
3109
|
|
|
} |
3110
|
|
|
|
3111
|
|
|
return $this->idTokenBuilderFactory; |
3112
|
|
|
} |
3113
|
|
|
|
3114
|
|
|
/** |
3115
|
|
|
* @var null|IdTokenLoader |
3116
|
|
|
*/ |
3117
|
|
|
private $idTokenLoader = null; |
3118
|
|
|
|
3119
|
|
|
/** |
3120
|
|
|
* @return IdTokenLoader |
3121
|
|
|
*/ |
3122
|
|
|
public function getIdTokenLoader(): IdTokenLoader |
3123
|
|
|
{ |
3124
|
|
|
if (null === $this->idTokenLoader) { |
3125
|
|
|
$this->idTokenLoader = new IdTokenLoader( |
3126
|
|
|
$this->getJwtLoader(), |
3127
|
|
|
$this->getPrivateKeys(), |
3128
|
|
|
'RS256' |
3129
|
|
|
); |
3130
|
|
|
} |
3131
|
|
|
|
3132
|
|
|
return $this->idTokenLoader; |
3133
|
|
|
} |
3134
|
|
|
|
3135
|
|
|
/** |
3136
|
|
|
* @var null|ParameterCheckerManager |
3137
|
|
|
*/ |
3138
|
|
|
private $parameterCheckerManager = null; |
3139
|
|
|
|
3140
|
|
|
/** |
3141
|
|
|
* @return ParameterCheckerManager |
3142
|
|
|
*/ |
3143
|
|
|
public function getParameterCheckerManager(): ParameterCheckerManager |
3144
|
|
|
{ |
3145
|
|
|
if (null === $this->parameterCheckerManager) { |
3146
|
|
|
$this->parameterCheckerManager = new ParameterCheckerManager(); |
3147
|
|
|
$this->parameterCheckerManager->add($this->getResponseTypeAndResponseModeParameterChecker()); |
3148
|
|
|
$this->parameterCheckerManager->add(new RedirectUriParameterChecker(true, true)); |
3149
|
|
|
$this->parameterCheckerManager->add(new DisplayParameterChecker()); |
3150
|
|
|
$this->parameterCheckerManager->add(new NonceParameterChecker()); |
3151
|
|
|
$this->parameterCheckerManager->add(new PromptParameterChecker()); |
3152
|
|
|
$this->parameterCheckerManager->add(new ScopeParameterChecker($this->getScopeRepository())); |
3153
|
|
|
$this->parameterCheckerManager->add(new StateParameterChecker(true)); |
3154
|
|
|
$this->parameterCheckerManager->add(new TokenTypeParameterChecker($this->getTokenTypeManager(), true)); |
3155
|
|
|
} |
3156
|
|
|
|
3157
|
|
|
return $this->parameterCheckerManager; |
3158
|
|
|
} |
3159
|
|
|
|
3160
|
|
|
/** |
3161
|
|
|
* @var null|ResponseTypeAndResponseModeParameterChecker |
3162
|
|
|
*/ |
3163
|
|
|
private $responseTypeAndResponseModeParameterChecker = null; |
3164
|
|
|
|
3165
|
|
|
/** |
3166
|
|
|
* @return ResponseTypeAndResponseModeParameterChecker |
3167
|
|
|
*/ |
3168
|
|
|
public function getResponseTypeAndResponseModeParameterChecker(): ResponseTypeAndResponseModeParameterChecker |
3169
|
|
|
{ |
3170
|
|
|
if (null === $this->responseTypeAndResponseModeParameterChecker) { |
3171
|
|
|
$this->responseTypeAndResponseModeParameterChecker = new ResponseTypeAndResponseModeParameterChecker( |
3172
|
|
|
$this->getResponseTypeManager(), |
3173
|
|
|
$this->getResponseModeManager(), |
3174
|
|
|
true |
3175
|
|
|
); |
3176
|
|
|
} |
3177
|
|
|
|
3178
|
|
|
return $this->responseTypeAndResponseModeParameterChecker; |
3179
|
|
|
} |
3180
|
|
|
|
3181
|
|
|
/** |
3182
|
|
|
* @var null|ResponseModeManager |
3183
|
|
|
*/ |
3184
|
|
|
private $responseModeManager = null; |
3185
|
|
|
|
3186
|
|
|
/** |
3187
|
|
|
* @return ResponseModeManager |
3188
|
|
|
*/ |
3189
|
|
|
public function getResponseModeManager(): ResponseModeManager |
3190
|
|
|
{ |
3191
|
|
|
if (null === $this->responseModeManager) { |
3192
|
|
|
$this->responseModeManager = new ResponseModeManager(); |
3193
|
|
|
$this->responseModeManager->add(new FragmentResponseMode( |
3194
|
|
|
$this->getUriFactory(), |
3195
|
|
|
$this->getResponseFactory()) |
3196
|
|
|
); |
3197
|
|
|
$this->responseModeManager->add(new QueryResponseMode( |
3198
|
|
|
$this->getUriFactory(), |
3199
|
|
|
$this->getResponseFactory()) |
3200
|
|
|
); |
3201
|
|
|
$this->responseModeManager->add(new FormPostResponseMode( |
3202
|
|
|
new FormPostResponseRenderer(), |
3203
|
|
|
$this->getResponseFactory()) |
3204
|
|
|
); |
3205
|
|
|
} |
3206
|
|
|
|
3207
|
|
|
return $this->responseModeManager; |
3208
|
|
|
} |
3209
|
|
|
|
3210
|
|
|
/** |
3211
|
|
|
* @var null|HttpClient |
3212
|
|
|
*/ |
3213
|
|
|
private $httpClient = null; |
3214
|
|
|
|
3215
|
|
|
/** |
3216
|
|
|
* @return HttpClient |
3217
|
|
|
*/ |
3218
|
|
|
public function getHttpClient(): HttpClient |
3219
|
|
|
{ |
3220
|
|
|
if (null === $this->httpClient) { |
3221
|
|
|
$this->httpClient = new Client(); |
3222
|
|
|
} |
3223
|
|
|
|
3224
|
|
|
return $this->httpClient; |
3225
|
|
|
} |
3226
|
|
|
|
3227
|
|
|
/** |
3228
|
|
|
* @var null|AuthorizationRequestLoader |
3229
|
|
|
*/ |
3230
|
|
|
private $authorizationRequestLoader = null; |
3231
|
|
|
|
3232
|
|
|
/** |
3233
|
|
|
* @return AuthorizationRequestLoader |
3234
|
|
|
*/ |
3235
|
|
|
public function getAuthorizationRequestLoader(): AuthorizationRequestLoader |
3236
|
|
|
{ |
3237
|
|
|
if (null === $this->authorizationRequestLoader) { |
3238
|
|
|
$this->authorizationRequestLoader = new AuthorizationRequestLoader($this->getClientRepository()); |
3239
|
|
|
$this->authorizationRequestLoader->enableRequestObjectSupport($this->getJwtLoader()); |
3240
|
|
|
$this->authorizationRequestLoader->enableEncryptedRequestObjectSupport($this->getPrivateKeys(), false); |
3241
|
|
|
$this->authorizationRequestLoader->enableRequestObjectReferenceSupport($this->getHttpClient(), true); |
3242
|
|
|
} |
3243
|
|
|
|
3244
|
|
|
return $this->authorizationRequestLoader; |
3245
|
|
|
} |
3246
|
|
|
|
3247
|
|
|
/** |
3248
|
|
|
* @var null|AuthorizationFactory |
3249
|
|
|
*/ |
3250
|
|
|
private $authorizationFactory = null; |
3251
|
|
|
|
3252
|
|
|
/** |
3253
|
|
|
* @return AuthorizationFactory |
3254
|
|
|
*/ |
3255
|
|
|
public function getAuthorizationFactory(): AuthorizationFactory |
3256
|
|
|
{ |
3257
|
|
|
if (null === $this->authorizationFactory) { |
3258
|
|
|
$this->authorizationFactory = new AuthorizationFactory($this->getAuthorizationRequestLoader(), $this->getParameterCheckerManager()); |
3259
|
|
|
} |
3260
|
|
|
|
3261
|
|
|
return $this->authorizationFactory; |
3262
|
|
|
} |
3263
|
|
|
|
3264
|
|
|
/** |
3265
|
|
|
* @var null|AuthorizationEndpoint |
3266
|
|
|
*/ |
3267
|
|
|
private $authorizationEndpoint = null; |
3268
|
|
|
|
3269
|
|
|
/** |
3270
|
|
|
* @return AuthorizationEndpoint |
3271
|
|
|
*/ |
3272
|
|
|
public function getAuthorizationEndpoint(): AuthorizationEndpoint |
3273
|
|
|
{ |
3274
|
|
|
if (null === $this->authorizationEndpoint) { |
3275
|
|
|
$this->authorizationEndpoint = new AuthorizationEndpoint( |
3276
|
|
|
$this->getResponseFactory(), |
3277
|
|
|
$this->getAuthorizationFactory(), |
3278
|
|
|
$this->getUserAccountDiscoveryManager(), |
3279
|
|
|
$this->getBeforeConsentScreenManager(), |
3280
|
|
|
$this->getAfterConsentScreenManager() |
3281
|
|
|
); |
3282
|
|
|
} |
3283
|
|
|
|
3284
|
|
|
return $this->authorizationEndpoint; |
3285
|
|
|
} |
3286
|
|
|
|
3287
|
|
|
/** |
3288
|
|
|
* @var null|Pipe |
3289
|
|
|
*/ |
3290
|
|
|
private $authorizationEndpointPipe = null; |
3291
|
|
|
|
3292
|
|
|
/** |
3293
|
|
|
* @return Pipe |
3294
|
|
|
*/ |
3295
|
|
|
public function getAuthorizationEndpointPipe(): Pipe |
3296
|
|
|
{ |
3297
|
|
|
if (null === $this->authorizationEndpointPipe) { |
3298
|
|
|
$this->authorizationEndpointPipe = new Pipe(); |
3299
|
|
|
$this->authorizationEndpointPipe->appendMiddleware($this->getOAuth2ResponseMiddleware()); |
3300
|
|
|
$this->authorizationEndpointPipe->appendMiddleware($this->getTokenTypeMiddleware()); |
3301
|
|
|
$this->authorizationEndpointPipe->appendMiddleware($this->getAuthorizationEndpoint()); |
3302
|
|
|
} |
3303
|
|
|
|
3304
|
|
|
return $this->authorizationEndpointPipe; |
3305
|
|
|
} |
3306
|
|
|
|
3307
|
|
|
/** |
3308
|
|
|
* @var null|UserAccountDiscoveryManager |
3309
|
|
|
*/ |
3310
|
|
|
private $userAccountDiscoveryManager = null; |
3311
|
|
|
|
3312
|
|
|
/** |
3313
|
|
|
* @return UserAccountDiscoveryManager |
3314
|
|
|
*/ |
3315
|
|
|
public function getUserAccountDiscoveryManager(): UserAccountDiscoveryManager |
3316
|
|
|
{ |
3317
|
|
|
if (null === $this->userAccountDiscoveryManager) { |
3318
|
|
|
$this->userAccountDiscoveryManager = new UserAccountDiscoveryManager(); |
3319
|
|
|
$this->userAccountDiscoveryManager->add($this->getIdTokenHintDiscovery()); |
3320
|
|
|
$this->userAccountDiscoveryManager->add($this->getSecurityLayer()); |
3321
|
|
|
$this->userAccountDiscoveryManager->add(new LoginParameterChecker()); |
3322
|
|
|
$this->userAccountDiscoveryManager->add(new MaxAgeParameterChecker()); |
3323
|
|
|
$this->userAccountDiscoveryManager->add(new PromptNoneParameterChecker()); |
3324
|
|
|
} |
3325
|
|
|
|
3326
|
|
|
return $this->userAccountDiscoveryManager; |
3327
|
|
|
} |
3328
|
|
|
|
3329
|
|
|
/** |
3330
|
|
|
* @var null|IdTokenHintDiscovery |
3331
|
|
|
*/ |
3332
|
|
|
private $idTokenHintDiscovery = null; |
3333
|
|
|
|
3334
|
|
|
/** |
3335
|
|
|
* @return IdTokenHintDiscovery |
3336
|
|
|
*/ |
3337
|
|
|
public function getIdTokenHintDiscovery(): IdTokenHintDiscovery |
3338
|
|
|
{ |
3339
|
|
|
if (null === $this->idTokenHintDiscovery) { |
3340
|
|
|
$this->idTokenHintDiscovery = new IdTokenHintDiscovery( |
3341
|
|
|
$this->getIdTokenLoader(), |
3342
|
|
|
$this->getUserAccountRepository() |
3343
|
|
|
); |
3344
|
|
|
$this->idTokenHintDiscovery->enablePairwiseSubject($this->getPairwiseSubjectIdentifierAlgorithm()); |
3345
|
|
|
} |
3346
|
|
|
|
3347
|
|
|
return $this->idTokenHintDiscovery; |
3348
|
|
|
} |
3349
|
|
|
|
3350
|
|
|
/** |
3351
|
|
|
* @var null|SecurityLayer |
3352
|
|
|
*/ |
3353
|
|
|
private $securityLayer = null; |
3354
|
|
|
|
3355
|
|
|
/** |
3356
|
|
|
* @return SecurityLayer |
3357
|
|
|
*/ |
3358
|
|
|
public function getSecurityLayer(): SecurityLayer |
3359
|
|
|
{ |
3360
|
|
|
if (null === $this->securityLayer) { |
3361
|
|
|
$this->securityLayer = new SecurityLayer(); |
3362
|
|
|
} |
3363
|
|
|
|
3364
|
|
|
return $this->securityLayer; |
3365
|
|
|
} |
3366
|
|
|
|
3367
|
|
|
/** |
3368
|
|
|
* @var null|BeforeConsentScreenManager |
3369
|
|
|
*/ |
3370
|
|
|
private $beforeConsentScreenManager = null; |
3371
|
|
|
|
3372
|
|
|
/** |
3373
|
|
|
* @return BeforeConsentScreenManager |
3374
|
|
|
*/ |
3375
|
|
|
public function getBeforeConsentScreenManager(): BeforeConsentScreenManager |
3376
|
|
|
{ |
3377
|
|
|
if (null === $this->beforeConsentScreenManager) { |
3378
|
|
|
$this->beforeConsentScreenManager = new BeforeConsentScreenManager(); |
3379
|
|
|
$this->beforeConsentScreenManager->add(new PreConfiguredAuthorizationExtension( |
3380
|
|
|
$this->getPreConfiguredAuthorizationRepository() |
3381
|
|
|
)); |
3382
|
|
|
} |
3383
|
|
|
|
3384
|
|
|
return $this->beforeConsentScreenManager; |
3385
|
|
|
} |
3386
|
|
|
|
3387
|
|
|
/** |
3388
|
|
|
* @var null|AfterConsentScreenManager |
3389
|
|
|
*/ |
3390
|
|
|
private $afterConsentScreenManager = null; |
3391
|
|
|
|
3392
|
|
|
/** |
3393
|
|
|
* @return AfterConsentScreenManager |
3394
|
|
|
*/ |
3395
|
|
|
public function getAfterConsentScreenManager(): AfterConsentScreenManager |
3396
|
|
|
{ |
3397
|
|
|
if (null === $this->afterConsentScreenManager) { |
3398
|
|
|
$this->afterConsentScreenManager = new AfterConsentScreenManager(); |
3399
|
|
|
$this->afterConsentScreenManager->add(new SessionStateParameterExtension('DefaultStorage')); |
3400
|
|
|
} |
3401
|
|
|
|
3402
|
|
|
return $this->afterConsentScreenManager; |
3403
|
|
|
} |
3404
|
|
|
|
3405
|
|
|
/** |
3406
|
|
|
* @var null|PreConfiguredAuthorizationRepository |
3407
|
|
|
*/ |
3408
|
|
|
private $preConfiguredAuthorizationRepository = null; |
3409
|
|
|
|
3410
|
|
|
/** |
3411
|
|
|
* @return PreConfiguredAuthorizationRepository |
3412
|
|
|
*/ |
3413
|
|
|
public function getPreConfiguredAuthorizationRepository(): PreConfiguredAuthorizationRepository |
3414
|
|
|
{ |
3415
|
|
|
if (null === $this->preConfiguredAuthorizationRepository) { |
3416
|
|
|
$this->preConfiguredAuthorizationRepository = new PreConfiguredAuthorizationRepository( |
3417
|
|
|
$this->getPreConfiguredAuthorizationEventStore(), |
3418
|
|
|
$this->getPublicMessageRecorder() |
3419
|
|
|
); |
3420
|
|
|
} |
3421
|
|
|
|
3422
|
|
|
return $this->preConfiguredAuthorizationRepository; |
3423
|
|
|
} |
3424
|
|
|
|
3425
|
|
|
/** |
3426
|
|
|
* @var null|DomainConverter |
3427
|
|
|
*/ |
3428
|
|
|
private $eventConverter = null; |
3429
|
|
|
|
3430
|
|
|
/** |
3431
|
|
|
* @return DomainConverter |
3432
|
|
|
*/ |
3433
|
|
|
public function getDomainConverter(): DomainConverter |
3434
|
|
|
{ |
3435
|
|
|
if (null === $this->eventConverter) { |
3436
|
|
|
$this->eventConverter = new DomainConverter(); |
3437
|
|
|
} |
3438
|
|
|
|
3439
|
|
|
return $this->eventConverter; |
3440
|
|
|
} |
3441
|
|
|
} |
3442
|
|
|
|