|
19 | 19 | use SimpleSAML\SAML2\Exception\ArrayValidationException; |
20 | 20 | use SimpleSAML\SAML2\XML\md\ContactPerson; |
21 | 21 | use SimpleSAML\SAML2\XML\saml\{AttributeValue, Issuer, NameID, SubjectConfirmation, SubjectConfirmationData}; |
| 22 | +use SimpleSAML\SAML2\XML\saml\{AuthenticatingAuthority, AuthnContext, AuthnContextClassRef}; // AuthnContext |
22 | 23 | use SimpleSAML\SAML2\XML\samlp\{Status, StatusCode, StatusMessage}; // Status |
23 | 24 | use SimpleSAML\XML\DOMDocumentFactory; |
24 | 25 | use SimpleSAML\XMLSecurity\XML\ds\{X509Certificate, X509Data, KeyInfo}; |
@@ -86,10 +87,6 @@ public static function sendResponse(array $state): Response |
86 | 87 |
|
87 | 88 | $assertion = self::buildAssertion($idpMetadata, $spMetadata, $state); |
88 | 89 |
|
89 | | - if (isset($state['saml:AuthenticatingAuthority'])) { |
90 | | - $assertion->setAuthenticatingAuthority($state['saml:AuthenticatingAuthority']); |
91 | | - } |
92 | | - |
93 | 90 | // create the session association (for logout) |
94 | 91 | $association = [ |
95 | 92 | 'id' => 'saml:' . $spEntityId, |
@@ -1184,16 +1181,28 @@ private static function buildAssertion( |
1184 | 1181 |
|
1185 | 1182 | $passAuthnContextClassRef = $config->getOptionalBoolean('proxymode.passAuthnContextClassRef', false); |
1186 | 1183 | if (isset($state['saml:AuthnContextClassRef'])) { |
1187 | | - $a->setAuthnContextClassRef($state['saml:AuthnContextClassRef']); |
| 1184 | + $classRef = $state['saml:AuthnContextClassRef']; |
1188 | 1185 | } elseif ($passAuthnContextClassRef && isset($state['saml:sp:AuthnContext'])) { |
1189 | 1186 | // AuthnContext has been set by the upper IdP in front of the proxy, pass it back to the SP behind the proxy |
1190 | | - $a->setAuthnContextClassRef($state['saml:sp:AuthnContext']); |
1191 | | - } elseif ($httpUtils->isHTTPS()) { |
1192 | | - $a->setAuthnContextClassRef(C::AC_PASSWORD_PROTECTED_TRANSPORT); |
| 1187 | + $classRef = $state['saml:sp:AuthnContext']; |
1193 | 1188 | } else { |
1194 | | - $a->setAuthnContextClassRef(C::AC_PASSWORD); |
| 1189 | + $classRef = $httpUtils->isHTTPS() ? C::AC_PASSWORD_PROTECTED_TRANSPORT : C::AC_PASSWORD; |
| 1190 | + } |
| 1191 | + |
| 1192 | + $authorities = []; |
| 1193 | + if (isset($state['saml:AuthenticatingAuthority'])) { |
| 1194 | + $authorities[] = new AuthenticatingAuthority($state['saml:AuthenticatingAuthority']); |
1195 | 1195 | } |
1196 | 1196 |
|
| 1197 | + $a->setAuthnContext( |
| 1198 | + new AuthnContext( |
| 1199 | + authnContextClassRef: new AuthnContextClassRef($classRef), |
| 1200 | + authnContextDecl: null, |
| 1201 | + authnContextDeclRef: null, |
| 1202 | + authenticatingAuthorities: $authorities, |
| 1203 | + ) |
| 1204 | + ); |
| 1205 | + |
1197 | 1206 | $sessionStart = $now; |
1198 | 1207 | if (isset($state['AuthnInstant'])) { |
1199 | 1208 | $a->setAuthnInstant($state['AuthnInstant']); |
|
0 commit comments