This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | require_once __DIR__.'/../../vendor/autoload.php'; |
||
4 | |||
5 | class IdpConfig |
||
6 | { |
||
7 | const OWN_ENTITY_ID = 'https://localhost/lightSAML/lightSAML-IDP'; |
||
8 | |||
9 | /** @var \SpConfig */ |
||
10 | private static $instance; |
||
11 | |||
12 | public $debug = true; |
||
13 | |||
14 | /** |
||
15 | * @return \IdpConfig |
||
16 | */ |
||
17 | public static function current() |
||
18 | { |
||
19 | if (null == self::$instance) { |
||
20 | self::$instance = new static(); |
||
0 ignored issues
–
show
|
|||
21 | } |
||
22 | |||
23 | return self::$instance; |
||
0 ignored issues
–
show
|
|||
24 | } |
||
25 | |||
26 | /** |
||
27 | * @return \LightSaml\Build\Container\BuildContainerInterface |
||
28 | */ |
||
29 | public function getBuildContainer() |
||
30 | { |
||
31 | $pimple = new \Pimple\Container(); |
||
32 | $result = new \LightSaml\Bridge\Pimple\Container\BuildContainer($pimple); |
||
33 | $this->buildOwnContext($result); |
||
34 | $this->buildSystemContext($result); |
||
35 | $this->buildPartyContext($result); |
||
36 | $this->buildStoreContext($result); |
||
37 | $this->buildProviderContext($result); |
||
38 | $this->buildCredentialContext($result); |
||
39 | $this->buildServiceContext($result); |
||
40 | |||
41 | return $result; |
||
42 | } |
||
43 | |||
44 | /** |
||
45 | * @param \LightSaml\Bridge\Pimple\Container\BuildContainer $buildContainer |
||
46 | */ |
||
47 | private function buildOwnContext(\LightSaml\Bridge\Pimple\Container\BuildContainer $buildContainer) |
||
48 | { |
||
49 | $ownCredential = $this->buildOwnCredential(); |
||
50 | $ownEntityDescriptorProvider = $this->buildOwnEntityDescriptorProvider($ownCredential->getCertificate()); |
||
51 | |||
52 | $buildContainer->getPimple()->register( |
||
53 | new \LightSaml\Bridge\Pimple\Container\Factory\OwnContainerProvider( |
||
54 | $ownEntityDescriptorProvider, |
||
55 | [$ownCredential] |
||
56 | ) |
||
57 | ); |
||
58 | } |
||
59 | |||
60 | /** |
||
61 | * @param \LightSaml\Bridge\Pimple\Container\BuildContainer $buildContainer |
||
62 | */ |
||
63 | private function buildSystemContext(\LightSaml\Bridge\Pimple\Container\BuildContainer $buildContainer) |
||
64 | { |
||
65 | $buildContainer->getPimple()->register(new \LightSaml\Bridge\Pimple\Container\Factory\SystemContainerProvider()); |
||
66 | |||
67 | $pimple = $buildContainer->getPimple(); |
||
68 | $pimple[\LightSaml\Bridge\Pimple\Container\SystemContainer::LOGGER] = function () { |
||
69 | return $this->buildLogger(); |
||
70 | |||
71 | }; |
||
72 | $pimple[\LightSaml\Bridge\Pimple\Container\SystemContainer::SESSION] = function () { |
||
73 | return $this->buildSession(); |
||
74 | |||
75 | }; |
||
76 | } |
||
77 | |||
78 | /** |
||
79 | * @param \LightSaml\Bridge\Pimple\Container\BuildContainer $buildContainer |
||
80 | */ |
||
81 | private function buildPartyContext(\LightSaml\Bridge\Pimple\Container\BuildContainer $buildContainer) |
||
82 | { |
||
83 | $buildContainer->getPimple()->register(new \LightSaml\Bridge\Pimple\Container\Factory\PartyContainerProvider()); |
||
84 | |||
85 | $pimple = $buildContainer->getPimple(); |
||
86 | $pimple[\LightSaml\Bridge\Pimple\Container\PartyContainer::SP_ENTITY_DESCRIPTOR] = function () { |
||
87 | return $this->buildSpEntityStore(); |
||
88 | }; |
||
89 | $pimple[\LightSaml\Bridge\Pimple\Container\PartyContainer::TRUST_OPTIONS_STORE] = function () { |
||
90 | $trustOptions = new \LightSaml\Meta\TrustOptions\TrustOptions(); |
||
91 | |||
92 | return new \LightSaml\Store\TrustOptions\FixedTrustOptionsStore($trustOptions); |
||
93 | }; |
||
94 | } |
||
95 | |||
96 | /** |
||
97 | * @param \LightSaml\Bridge\Pimple\Container\BuildContainer $buildContainer |
||
98 | */ |
||
99 | private function buildStoreContext(\LightSaml\Bridge\Pimple\Container\BuildContainer $buildContainer) |
||
100 | { |
||
101 | $buildContainer->getPimple()->register( |
||
102 | new \LightSaml\Bridge\Pimple\Container\Factory\StoreContainerProvider( |
||
103 | $buildContainer->getSystemContainer() |
||
104 | ) |
||
105 | ); |
||
106 | } |
||
107 | |||
108 | /** |
||
109 | * @param \LightSaml\Bridge\Pimple\Container\BuildContainer $buildContainer |
||
110 | */ |
||
111 | private function buildProviderContext(\LightSaml\Bridge\Pimple\Container\BuildContainer $buildContainer) |
||
112 | { |
||
113 | $buildContainer->getPimple()->register( |
||
114 | new \LightSaml\Bridge\Pimple\Container\Factory\ProviderContainerProvider() |
||
115 | ); |
||
116 | |||
117 | $pimple = $buildContainer->getPimple(); |
||
118 | $pimple[\LightSaml\Bridge\Pimple\Container\ProviderContainer::ATTRIBUTE_VALUE_PROVIDER] = function () { |
||
119 | return (new \LightSaml\Provider\Attribute\FixedAttributeValueProvider()) |
||
120 | ->add(new \LightSaml\Model\Assertion\Attribute( |
||
121 | \LightSaml\ClaimTypes::COMMON_NAME, |
||
122 | 'common-name' |
||
123 | )) |
||
124 | ->add(new \LightSaml\Model\Assertion\Attribute( |
||
125 | \LightSaml\ClaimTypes::GIVEN_NAME, |
||
126 | 'first' |
||
127 | )) |
||
128 | ->add(new \LightSaml\Model\Assertion\Attribute( |
||
129 | \LightSaml\ClaimTypes::SURNAME, |
||
130 | 'last' |
||
131 | )) |
||
132 | ->add(new \LightSaml\Model\Assertion\Attribute( |
||
133 | \LightSaml\ClaimTypes::EMAIL_ADDRESS, |
||
134 | '[email protected]' |
||
135 | )); |
||
136 | |||
137 | }; |
||
138 | |||
139 | $pimple[\LightSaml\Bridge\Pimple\Container\ProviderContainer::SESSION_INFO_PROVIDER] = function () { |
||
140 | return new \LightSaml\Provider\Session\FixedSessionInfoProvider( |
||
141 | time() - 600, |
||
142 | 'session-index', |
||
143 | \LightSaml\SamlConstants::AUTHN_CONTEXT_PASSWORD_PROTECTED_TRANSPORT |
||
144 | ); |
||
145 | }; |
||
146 | |||
147 | $pimple[\LightSaml\Bridge\Pimple\Container\ProviderContainer::NAME_ID_PROVIDER] = function () use ($buildContainer) { |
||
148 | $nameId = new \LightSaml\Model\Assertion\NameID('[email protected]'); |
||
149 | $nameId |
||
150 | ->setFormat(\LightSaml\SamlConstants::NAME_ID_FORMAT_EMAIL) |
||
151 | ->setNameQualifier($buildContainer->getOwnContainer()->getOwnEntityDescriptorProvider()->get()->getEntityID()) |
||
152 | ; |
||
153 | |||
154 | return new \LightSaml\Provider\NameID\FixedNameIdProvider($nameId); |
||
155 | }; |
||
156 | } |
||
157 | |||
158 | /** |
||
159 | * @param \LightSaml\Bridge\Pimple\Container\BuildContainer $buildContainer |
||
160 | */ |
||
161 | private function buildCredentialContext(\LightSaml\Bridge\Pimple\Container\BuildContainer $buildContainer) |
||
162 | { |
||
163 | $buildContainer->getPimple()->register( |
||
164 | new \LightSaml\Bridge\Pimple\Container\Factory\CredentialContainerProvider( |
||
165 | $buildContainer->getPartyContainer(), |
||
166 | $buildContainer->getOwnContainer() |
||
167 | ) |
||
168 | ); |
||
169 | } |
||
170 | |||
171 | /** |
||
172 | * @param \LightSaml\Bridge\Pimple\Container\BuildContainer $buildContainer |
||
173 | */ |
||
174 | private function buildServiceContext(\LightSaml\Bridge\Pimple\Container\BuildContainer $buildContainer) |
||
175 | { |
||
176 | $buildContainer->getPimple()->register( |
||
177 | new \LightSaml\Bridge\Pimple\Container\Factory\ServiceContainerProvider( |
||
178 | $buildContainer->getCredentialContainer(), |
||
179 | $buildContainer->getStoreContainer(), |
||
180 | $buildContainer->getSystemContainer() |
||
181 | ) |
||
182 | ); |
||
183 | } |
||
184 | |||
185 | /** |
||
186 | * @return \Symfony\Component\HttpFoundation\Session\Session |
||
187 | */ |
||
188 | private function buildSession() |
||
189 | { |
||
190 | $session = new \Symfony\Component\HttpFoundation\Session\Session(); |
||
191 | $session->setName('PHPSIDIDP'); |
||
192 | $session->start(); |
||
193 | |||
194 | return $session; |
||
195 | } |
||
196 | |||
197 | /** |
||
198 | * @return \LightSaml\Credential\X509Credential |
||
199 | */ |
||
200 | private function buildOwnCredential() |
||
201 | { |
||
202 | $ownCredential = new \LightSaml\Credential\X509Credential( |
||
203 | (new \LightSaml\Credential\X509Certificate()) |
||
204 | ->loadPem(file_get_contents(__DIR__.'/saml.crt')), |
||
205 | \LightSaml\Credential\KeyHelper::createPrivateKey(__DIR__.'/saml.key', null, true) |
||
206 | ); |
||
207 | $ownCredential |
||
208 | ->setEntityId(self::OWN_ENTITY_ID) |
||
209 | ; |
||
210 | |||
211 | return $ownCredential; |
||
212 | } |
||
213 | |||
214 | /** |
||
215 | * @param \LightSaml\Credential\X509Certificate $certificate |
||
216 | * |
||
217 | * @return \LightSaml\Provider\EntityDescriptor\EntityDescriptorProviderInterface |
||
218 | */ |
||
219 | private function buildOwnEntityDescriptorProvider(\LightSaml\Credential\X509Certificate $certificate) |
||
220 | { |
||
221 | return new \LightSaml\Builder\EntityDescriptor\SimpleEntityDescriptorBuilder( |
||
222 | self::OWN_ENTITY_ID, |
||
223 | null, |
||
224 | 'https://localhost/lightsaml/lightSAML-IDP/web/idp/login.php', |
||
225 | $certificate |
||
226 | ); |
||
227 | } |
||
228 | |||
229 | /** |
||
230 | * @return \LightSaml\Store\EntityDescriptor\FixedEntityDescriptorStore |
||
231 | */ |
||
232 | private function buildSpEntityStore() |
||
233 | { |
||
234 | $idpProvider = new \LightSaml\Store\EntityDescriptor\FixedEntityDescriptorStore(); |
||
235 | $idpProvider->add( |
||
236 | \LightSaml\Model\Metadata\EntityDescriptor::load(__DIR__.'/localhost-lightsaml-demosp.xml') |
||
237 | ); |
||
238 | $idpProvider->add( |
||
239 | \LightSaml\Model\Metadata\EntityDescriptor::load(__DIR__.'/localhost-lightsaml-lightsaml.xml') |
||
240 | ); |
||
241 | |||
242 | return $idpProvider; |
||
243 | } |
||
244 | |||
245 | /** |
||
246 | * @return \Monolog\Logger |
||
247 | */ |
||
248 | private function buildLogger() |
||
249 | { |
||
250 | $logger = new \Monolog\Logger('lightsaml', array(new \Monolog\Handler\StreamHandler(__DIR__.'/idp.log'))); |
||
251 | |||
252 | return $logger; |
||
253 | } |
||
254 | } |
||
255 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..