forked from simplesamlphp/simplesamlphp-module-oidc
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRequestRulesManagerFactory.php
More file actions
153 lines (147 loc) · 7.53 KB
/
RequestRulesManagerFactory.php
File metadata and controls
153 lines (147 loc) · 7.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
<?php
declare(strict_types=1);
namespace SimpleSAML\Module\oidc\Factories;
use SimpleSAML\Module\oidc\Bridges\SspBridge;
use SimpleSAML\Module\oidc\Factories\Entities\ClientEntityFactory;
use SimpleSAML\Module\oidc\Helpers;
use SimpleSAML\Module\oidc\ModuleConfig;
use SimpleSAML\Module\oidc\Repositories\ClientRepository;
use SimpleSAML\Module\oidc\Repositories\CodeChallengeVerifiersRepository;
use SimpleSAML\Module\oidc\Repositories\ScopeRepository;
use SimpleSAML\Module\oidc\Server\RequestRules\RequestRulesManager;
use SimpleSAML\Module\oidc\Server\RequestRules\Rules\AcrValuesRule;
use SimpleSAML\Module\oidc\Server\RequestRules\Rules\AddClaimsToIdTokenRule;
use SimpleSAML\Module\oidc\Server\RequestRules\Rules\AuthorizationDetailsRule;
use SimpleSAML\Module\oidc\Server\RequestRules\Rules\ClientAuthenticationRule;
use SimpleSAML\Module\oidc\Server\RequestRules\Rules\ClientIdRule;
use SimpleSAML\Module\oidc\Server\RequestRules\Rules\ClientRedirectUriRule;
use SimpleSAML\Module\oidc\Server\RequestRules\Rules\ClientRule;
use SimpleSAML\Module\oidc\Server\RequestRules\Rules\CodeChallengeMethodRule;
use SimpleSAML\Module\oidc\Server\RequestRules\Rules\CodeChallengeRule;
use SimpleSAML\Module\oidc\Server\RequestRules\Rules\CodeVerifierRule;
use SimpleSAML\Module\oidc\Server\RequestRules\Rules\IdTokenHintRule;
use SimpleSAML\Module\oidc\Server\RequestRules\Rules\IssuerStateRule;
use SimpleSAML\Module\oidc\Server\RequestRules\Rules\MaxAgeRule;
use SimpleSAML\Module\oidc\Server\RequestRules\Rules\PostLogoutRedirectUriRule;
use SimpleSAML\Module\oidc\Server\RequestRules\Rules\PromptRule;
use SimpleSAML\Module\oidc\Server\RequestRules\Rules\RequestedClaimsRule;
use SimpleSAML\Module\oidc\Server\RequestRules\Rules\RequestObjectRule;
use SimpleSAML\Module\oidc\Server\RequestRules\Rules\RequiredNonceRule;
use SimpleSAML\Module\oidc\Server\RequestRules\Rules\RequiredOpenIdScopeRule;
use SimpleSAML\Module\oidc\Server\RequestRules\Rules\ResponseTypeRule;
use SimpleSAML\Module\oidc\Server\RequestRules\Rules\ScopeOfflineAccessRule;
use SimpleSAML\Module\oidc\Server\RequestRules\Rules\ScopeRule;
use SimpleSAML\Module\oidc\Server\RequestRules\Rules\StateRule;
use SimpleSAML\Module\oidc\Server\RequestRules\Rules\UiLocalesRule;
use SimpleSAML\Module\oidc\Services\AuthenticationService;
use SimpleSAML\Module\oidc\Services\LoggerService;
use SimpleSAML\Module\oidc\Utils\ClaimTranslatorExtractor;
use SimpleSAML\Module\oidc\Utils\FederationCache;
use SimpleSAML\Module\oidc\Utils\FederationParticipationValidator;
use SimpleSAML\Module\oidc\Utils\JwksResolver;
use SimpleSAML\Module\oidc\Utils\ProtocolCache;
use SimpleSAML\Module\oidc\Utils\RequestParamsResolver;
use SimpleSAML\OpenID\Federation;
class RequestRulesManagerFactory
{
public function __construct(
private readonly ModuleConfig $moduleConfig,
private readonly LoggerService $logger,
private readonly ClientRepository $clientRepository,
private readonly AuthSimpleFactory $authSimpleFactory,
private readonly AuthenticationService $authenticationService,
private readonly ScopeRepository $scopeRepository,
private readonly CodeChallengeVerifiersRepository $codeChallengeVerifiersRepository,
private readonly ClaimTranslatorExtractor $claimTranslatorExtractor,
private readonly CryptKeyFactory $cryptKeyFactory,
private readonly RequestParamsResolver $requestParamsResolver,
private readonly ClientEntityFactory $clientEntityFactory,
private readonly Federation $federation,
private readonly Helpers $helpers,
private readonly JwksResolver $jwksResolver,
private readonly FederationParticipationValidator $federationParticipationValidator,
private readonly SspBridge $sspBridge,
private readonly ?FederationCache $federationCache = null,
private readonly ?ProtocolCache $protocolCache = null,
) {
}
/**
* @param \SimpleSAML\Module\oidc\Server\RequestRules\Interfaces\RequestRuleInterface[]|null $rules
* @return \SimpleSAML\Module\oidc\Server\RequestRules\RequestRulesManager
*/
public function build(?array $rules = null): RequestRulesManager
{
$rules = $rules ?? $this->getDefaultRules();
return new RequestRulesManager($rules, $this->logger);
}
/**
* @return \SimpleSAML\Module\oidc\Server\RequestRules\Interfaces\RequestRuleInterface[]
*/
private function getDefaultRules(): array
{
return [
new StateRule($this->requestParamsResolver, $this->helpers),
new IssuerStateRule($this->requestParamsResolver, $this->helpers),
new ClientRule(
$this->requestParamsResolver,
$this->helpers,
$this->clientRepository,
$this->moduleConfig,
$this->clientEntityFactory,
$this->federation,
$this->jwksResolver,
$this->federationParticipationValidator,
$this->logger,
$this->federationCache,
),
new ClientRedirectUriRule($this->requestParamsResolver, $this->helpers, $this->moduleConfig),
new RequestObjectRule($this->requestParamsResolver, $this->helpers, $this->jwksResolver),
new PromptRule(
$this->requestParamsResolver,
$this->helpers,
$this->authSimpleFactory,
$this->authenticationService,
$this->sspBridge,
),
new MaxAgeRule(
$this->requestParamsResolver,
$this->helpers,
$this->authSimpleFactory,
$this->authenticationService,
$this->sspBridge,
),
new ScopeRule($this->requestParamsResolver, $this->helpers, $this->scopeRepository),
new RequiredOpenIdScopeRule($this->requestParamsResolver, $this->helpers),
new CodeChallengeRule($this->requestParamsResolver, $this->helpers),
new CodeChallengeMethodRule(
$this->requestParamsResolver,
$this->helpers,
$this->codeChallengeVerifiersRepository,
),
new RequestedClaimsRule($this->requestParamsResolver, $this->helpers, $this->claimTranslatorExtractor),
new AddClaimsToIdTokenRule($this->requestParamsResolver, $this->helpers),
new RequiredNonceRule($this->requestParamsResolver, $this->helpers),
new ResponseTypeRule($this->requestParamsResolver, $this->helpers),
new IdTokenHintRule(
$this->requestParamsResolver,
$this->helpers,
$this->moduleConfig,
$this->cryptKeyFactory,
),
new PostLogoutRedirectUriRule($this->requestParamsResolver, $this->helpers, $this->clientRepository),
new UiLocalesRule($this->requestParamsResolver, $this->helpers),
new AcrValuesRule($this->requestParamsResolver, $this->helpers),
new ScopeOfflineAccessRule($this->requestParamsResolver, $this->helpers),
new ClientAuthenticationRule(
$this->requestParamsResolver,
$this->helpers,
$this->moduleConfig,
$this->jwksResolver,
$this->protocolCache,
),
new CodeVerifierRule($this->requestParamsResolver, $this->helpers),
new AuthorizationDetailsRule($this->requestParamsResolver, $this->helpers, $this->moduleConfig),
new ClientIdRule($this->requestParamsResolver, $this->helpers),
];
}
}