Total Complexity | 7 |
Total Lines | 45 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
9 | class ConfigResolver implements ResolvesIdpConfig |
||
10 | { |
||
11 | /** |
||
12 | * Adjust SAML configuration for the given identity provider. |
||
13 | * |
||
14 | * @param IdentityProvidable $idp |
||
15 | * @param array $config |
||
16 | * |
||
17 | * @return array |
||
18 | */ |
||
19 | public function resolve(IdentityProvidable $idp, array $config): array |
||
20 | { |
||
21 | if ($idp->idpX509cert() === null) { |
||
22 | throw new ConfigurationException('Identity Provider certificate is missing'); |
||
23 | } |
||
24 | |||
25 | $config['idp'] = [ |
||
26 | 'entityId' => $idp->idpEntityId(), |
||
27 | 'singleSignOnService' => ['url' => $idp->idpLoginUrl()], |
||
28 | 'singleLogoutService' => ['url' => $idp->idpLogoutUrl()], |
||
29 | 'x509cert' => $idp->idpX509cert() |
||
30 | ]; |
||
31 | |||
32 | $config['sp']['NameIDFormat'] = $this->resolveNameIdFormatPrefix($idp->idpNameIdFormat()); |
||
33 | |||
34 | return $config; |
||
35 | } |
||
36 | |||
37 | /** |
||
38 | * Resolve the Name ID Format prefix. |
||
39 | * |
||
40 | * @param string $format |
||
41 | * |
||
42 | * @return string |
||
43 | */ |
||
44 | protected function resolveNameIdFormatPrefix(string $format): string |
||
54 | } |
||
55 | } |
||
57 |