lightsaml2 /
lightSAML
| 1 | <?php |
||
| 2 | |||
| 3 | require_once __DIR__.'/../../vendor/autoload.php'; |
||
| 4 | |||
| 5 | class SpConfig |
||
| 6 | { |
||
| 7 | const OWN_ENTITY_ID = 'https://localhost/lightSAML/lightSAML'; |
||
| 8 | |||
| 9 | /** @var \SpConfig */ |
||
| 10 | private static $instance; |
||
| 11 | |||
| 12 | public $debug = true; |
||
| 13 | |||
| 14 | /** |
||
| 15 | * @return \SpConfig |
||
| 16 | */ |
||
| 17 | public static function current() |
||
| 18 | { |
||
| 19 | if (null == self::$instance) { |
||
| 20 | self::$instance = new static(); |
||
| 21 | } |
||
| 22 | |||
| 23 | return self::$instance; |
||
| 24 | } |
||
| 25 | |||
| 26 | /** |
||
| 27 | * @return \LightSaml\Build\Container\BuildContainerInterface |
||
| 28 | */ |
||
| 29 | public function getBuildContainer() |
||
| 30 | { |
||
| 31 | $result = new \LightSaml\Bridge\Pimple\Container\BuildContainer(new \Pimple\Container()); |
||
| 32 | $this->buildOwnContext($result); |
||
| 33 | $this->buildSystemContext($result); |
||
| 34 | $this->buildPartyContext($result); |
||
| 35 | $this->buildStoreContext($result); |
||
| 36 | $this->buildProviderContext($result); |
||
| 37 | $this->buildCredentialContext($result); |
||
| 38 | $this->buildServiceContext($result); |
||
| 39 | |||
| 40 | return $result; |
||
| 41 | } |
||
| 42 | |||
| 43 | private function buildOwnContext(\LightSaml\Bridge\Pimple\Container\BuildContainer $buildContainer) |
||
| 44 | { |
||
| 45 | $ownCredential = $this->buildOwnCredential(); |
||
| 46 | $ownEntityDescriptorProvider = $this->buildOwnEntityDescriptorProvider($ownCredential->getCertificate()); |
||
| 47 | |||
| 48 | $buildContainer->getPimple()->register( |
||
| 49 | new \LightSaml\Bridge\Pimple\Container\Factory\OwnContainerProvider( |
||
| 50 | $ownEntityDescriptorProvider, |
||
| 51 | [$ownCredential] |
||
| 52 | ) |
||
| 53 | ); |
||
| 54 | } |
||
| 55 | |||
| 56 | private function buildSystemContext(\LightSaml\Bridge\Pimple\Container\BuildContainer $buildContainer) |
||
| 57 | { |
||
| 58 | $buildContainer->getPimple()->register(new \LightSaml\Bridge\Pimple\Container\Factory\SystemContainerProvider()); |
||
| 59 | |||
| 60 | $pimple = $buildContainer->getPimple(); |
||
| 61 | $pimple[\LightSaml\Bridge\Pimple\Container\SystemContainer::LOGGER] = function () { |
||
| 62 | return $this->buildLogger(); |
||
| 63 | |||
| 64 | }; |
||
| 65 | $pimple[\LightSaml\Bridge\Pimple\Container\SystemContainer::SESSION] = function () { |
||
| 66 | return $this->buildSession(); |
||
| 67 | |||
| 68 | }; |
||
| 69 | } |
||
| 70 | |||
| 71 | private function buildPartyContext(\LightSaml\Bridge\Pimple\Container\BuildContainer $buildContainer) |
||
| 72 | { |
||
| 73 | $buildContainer->getPimple()->register(new \LightSaml\Bridge\Pimple\Container\Factory\PartyContainerProvider()); |
||
| 74 | |||
| 75 | $pimple = $buildContainer->getPimple(); |
||
| 76 | $pimple[\LightSaml\Bridge\Pimple\Container\PartyContainer::IDP_ENTITY_DESCRIPTOR] = function () { |
||
| 77 | return $this->buildIdpEntityStore(); |
||
| 78 | }; |
||
| 79 | $pimple[\LightSaml\Bridge\Pimple\Container\PartyContainer::TRUST_OPTIONS_STORE] = function () { |
||
| 80 | $trustOptions = new \LightSaml\Meta\TrustOptions\TrustOptions(); |
||
| 81 | $trustOptions->setSignAuthnRequest(true); |
||
| 82 | |||
| 83 | return new \LightSaml\Store\TrustOptions\FixedTrustOptionsStore($trustOptions); |
||
| 84 | }; |
||
| 85 | } |
||
| 86 | |||
| 87 | private function buildStoreContext(\LightSaml\Bridge\Pimple\Container\BuildContainer $buildContainer) |
||
| 88 | { |
||
| 89 | $buildContainer->getPimple()->register( |
||
| 90 | new \LightSaml\Bridge\Pimple\Container\Factory\StoreContainerProvider( |
||
| 91 | $buildContainer->getSystemContainer() |
||
| 92 | ) |
||
| 93 | ); |
||
| 94 | } |
||
| 95 | |||
| 96 | private function buildProviderContext(\LightSaml\Bridge\Pimple\Container\BuildContainer $buildContainer) |
||
| 97 | { |
||
| 98 | $buildContainer->getPimple()->register( |
||
| 99 | new \LightSaml\Bridge\Pimple\Container\Factory\ProviderContainerProvider() |
||
| 100 | ); |
||
| 101 | } |
||
| 102 | |||
| 103 | private function buildCredentialContext(\LightSaml\Bridge\Pimple\Container\BuildContainer $buildContainer) |
||
| 104 | { |
||
| 105 | $buildContainer->getPimple()->register( |
||
| 106 | new \LightSaml\Bridge\Pimple\Container\Factory\CredentialContainerProvider( |
||
| 107 | $buildContainer->getPartyContainer(), |
||
| 108 | $buildContainer->getOwnContainer() |
||
| 109 | ) |
||
| 110 | ); |
||
| 111 | } |
||
| 112 | |||
| 113 | private function buildServiceContext(\LightSaml\Bridge\Pimple\Container\BuildContainer $buildContainer) |
||
| 114 | { |
||
| 115 | $buildContainer->getPimple()->register( |
||
| 116 | new \LightSaml\Bridge\Pimple\Container\Factory\ServiceContainerProvider( |
||
| 117 | $buildContainer->getCredentialContainer(), |
||
| 118 | $buildContainer->getStoreContainer(), |
||
| 119 | $buildContainer->getSystemContainer() |
||
| 120 | ) |
||
| 121 | ); |
||
| 122 | } |
||
| 123 | |||
| 124 | /** |
||
| 125 | * @return \Symfony\Component\HttpFoundation\Session\Session |
||
| 126 | */ |
||
| 127 | private function buildSession() |
||
| 128 | { |
||
| 129 | $session = new \Symfony\Component\HttpFoundation\Session\Session(); |
||
| 130 | $session->setName('PHPSIDSP'); |
||
| 131 | $session->start(); |
||
| 132 | |||
| 133 | return $session; |
||
| 134 | } |
||
| 135 | |||
| 136 | /** |
||
| 137 | * @return \LightSaml\Credential\X509Credential |
||
| 138 | */ |
||
| 139 | private function buildOwnCredential() |
||
| 140 | { |
||
| 141 | $ownCredential = new \LightSaml\Credential\X509Credential( |
||
| 142 | (new \LightSaml\Credential\X509Certificate()) |
||
| 143 | ->loadPem(file_get_contents(__DIR__.'/saml.crt')), |
||
| 144 | \LightSaml\Credential\KeyHelper::createPrivateKey(__DIR__.'/saml.key', null, true) |
||
| 145 | ); |
||
| 146 | $ownCredential |
||
| 147 | ->setEntityId(self::OWN_ENTITY_ID) |
||
| 148 | ; |
||
| 149 | |||
| 150 | return $ownCredential; |
||
| 151 | } |
||
| 152 | |||
| 153 | /** |
||
| 154 | * @param \LightSaml\Credential\X509Certificate $certificate |
||
| 155 | * |
||
| 156 | * @return \LightSaml\Provider\EntityDescriptor\EntityDescriptorProviderInterface |
||
| 157 | */ |
||
| 158 | private function buildOwnEntityDescriptorProvider(\LightSaml\Credential\X509Certificate $certificate) |
||
| 159 | { |
||
| 160 | return new \LightSaml\Builder\EntityDescriptor\SimpleEntityDescriptorBuilder( |
||
| 161 | self::OWN_ENTITY_ID, |
||
| 162 | 'https://localhost/lightsaml/lightSAML/web/sp/acs.php', |
||
| 163 | null, |
||
| 164 | $certificate |
||
| 165 | ); |
||
| 166 | } |
||
| 167 | |||
| 168 | /** |
||
| 169 | * @return \LightSaml\Store\EntityDescriptor\FixedEntityDescriptorStore |
||
| 170 | */ |
||
| 171 | private function buildIdpEntityStore() |
||
| 172 | { |
||
| 173 | $idpProvider = new \LightSaml\Store\EntityDescriptor\FixedEntityDescriptorStore(); |
||
| 174 | $idpProvider->add( |
||
| 175 | \LightSaml\Model\Metadata\EntitiesDescriptor::load(__DIR__.'/testshib-providers.xml') |
||
| 176 | ); |
||
| 177 | $idpProvider->add( |
||
| 178 | \LightSaml\Model\Metadata\EntityDescriptor::load(__DIR__.'/localhost-lightsaml-lightsaml-idp.xml') |
||
| 179 | ); |
||
| 180 | $idpProvider->add( |
||
| 181 | \LightSaml\Model\Metadata\EntityDescriptor::load(__DIR__.'/openidp.feide.no.xml') |
||
| 182 | ); |
||
| 183 | $idpProvider->add( |
||
| 184 | \LightSaml\Model\Metadata\EntityDescriptor::load(__DIR__.'/FederationMetadata.xml') |
||
| 185 | ); |
||
| 186 | |||
| 187 | return $idpProvider; |
||
| 188 | } |
||
| 189 | |||
| 190 | /** |
||
| 191 | * @return \Monolog\Logger |
||
| 192 | */ |
||
| 193 | private function buildLogger() |
||
| 194 | { |
||
| 195 | $logger = new \Monolog\Logger('lightsaml', array(new \Monolog\Handler\StreamHandler(__DIR__.'/sp.log'))); |
||
|
0 ignored issues
–
show
The type
Monolog\Logger was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 196 | |||
| 197 | return $logger; |
||
| 198 | } |
||
| 199 | } |
||
| 200 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths