2727use SimpleSAML \Store \StoreFactory ;
2828use SimpleSAML \Utils ;
2929
30- class SP extends \ SimpleSAML \ Auth \Source
30+ class SP extends Auth \Source
3131{
3232 /**
3333 * The entity ID of this SP.
@@ -699,12 +699,11 @@ private function startSSO2(Configuration $idpMetadata, array $state): void
699699 * This function does not return.
700700 *
701701 * @param \SAML2\Binding $binding The binding.
702- * @param \SAML2\AuthnRequest $ar The authentication request.
702+ * @param \SAML2\AuthnRequest $ar The authentication request.
703703 */
704- public function sendSAML2AuthnRequest (Binding $ binding , AuthnRequest $ ar ): void
704+ public function sendSAML2AuthnRequest (Binding $ binding , AuthnRequest $ ar ): never
705705 {
706706 $ binding ->send ($ ar );
707- Assert::true (false );
708707 }
709708
710709
@@ -714,12 +713,11 @@ public function sendSAML2AuthnRequest(Binding $binding, AuthnRequest $ar): void
714713 * This function does not return.
715714 *
716715 * @param \SAML2\Binding $binding The binding.
717- * @param \SAML2\LogoutRequest $ar The logout request.
716+ * @param \SAML2\LogoutRequest $ar The logout request.
718717 */
719- public function sendSAML2LogoutRequest (Binding $ binding , LogoutRequest $ lr ): void
718+ public function sendSAML2LogoutRequest (Binding $ binding , LogoutRequest $ lr ): never
720719 {
721720 $ binding ->send ($ lr );
722- Assert::true (false );
723721 }
724722
725723
@@ -729,15 +727,14 @@ public function sendSAML2LogoutRequest(Binding $binding, LogoutRequest $lr): voi
729727 * @param string $idp The entity ID of the IdP.
730728 * @param array $state The state array for the current authentication.
731729 */
732- public function startSSO (string $ idp , array $ state ): void
730+ public function startSSO (string $ idp , array $ state ): never
733731 {
734732 $ idpMetadata = $ this ->getIdPMetadata ($ idp );
735733
736734 $ type = $ idpMetadata ->getString ('metadata-set ' );
737735 Assert::oneOf ($ type , ['saml20-idp-remote ' ]);
738736
739737 $ this ->startSSO2 ($ idpMetadata , $ state );
740- Assert::true (false ); // Should not return
741738 }
742739
743740
@@ -746,7 +743,7 @@ public function startSSO(string $idp, array $state): void
746743 *
747744 * @param array $state The state array.
748745 */
749- private function startDisco (array $ state ): void
746+ private function startDisco (array $ state ): never
750747 {
751748 $ id = Auth \State::saveState ($ state , 'saml:sp:sso ' );
752749
@@ -784,7 +781,7 @@ private function startDisco(array $state): void
784781 *
785782 * @param array &$state Information about the current authentication.
786783 */
787- public function authenticate (array &$ state ): void
784+ public function authenticate (array &$ state ): never
788785 {
789786 // We are going to need the authId in order to retrieve this authentication source later
790787 $ state ['saml:sp:AuthId ' ] = $ this ->authId ;
@@ -822,11 +819,9 @@ public function authenticate(array &$state): void
822819
823820 if ($ idp === null ) {
824821 $ this ->startDisco ($ state );
825- Assert::true (false );
822+ } else {
823+ $ this ->startSSO ($ idp , $ state );
826824 }
827-
828- $ this ->startSSO ($ idp , $ state );
829- Assert::true (false );
830825 }
831826
832827
@@ -949,7 +944,7 @@ public function reauthenticate(array &$state): void
949944 *
950945 * @throws \SAML2\Exception\Protocol\NoPassiveException In case the authentication request was passive.
951946 */
952- public static function askForIdPChange (array &$ state ): void
947+ public static function askForIdPChange (array &$ state ): never
953948 {
954949 Assert::keyExists ($ state , 'saml:sp:IdPMetadata ' );
955950 Assert::keyExists ($ state , 'saml:sp:AuthId ' );
@@ -969,7 +964,6 @@ public static function askForIdPChange(array &$state): void
969964
970965 $ httpUtils = new Utils \HTTP ();
971966 $ httpUtils ->redirectTrustedURL ($ url , ['AuthState ' => $ id ]);
972- Assert::true (false );
973967 }
974968
975969
@@ -985,7 +979,7 @@ public static function askForIdPChange(array &$state): void
985979 * - 'saml:sp:AuthId': the identifier of the current authentication source.
986980 * @throws \SAML2\Exception\Protocol\NoPassiveException In case the authentication request was passive.
987981 */
988- public static function tryStepUpAuth (array &$ state ): void
982+ public static function tryStepUpAuth (array &$ state ): never
989983 {
990984 Assert::keyExists ($ state , 'saml:idp ' );
991985 Assert::keyExists ($ state , 'saml:sp:AuthId ' );
@@ -1000,7 +994,6 @@ public static function tryStepUpAuth(array &$state): void
1000994 /** @var \SimpleSAML\Module\saml\Auth\Source\SP $as */
1001995 $ as = new Auth \Simple ($ state ['saml:sp:AuthId ' ]);
1002996 $ as ->login ($ state );
1003- Assert::true (false );
1004997 }
1005998
1006999
@@ -1011,7 +1004,7 @@ public static function tryStepUpAuth(array &$state): void
10111004 *
10121005 * @param array $state The state array.
10131006 */
1014- public static function reauthLogout (array $ state ): void
1007+ public static function reauthLogout (array $ state ): never
10151008 {
10161009 Logger::debug ('Proxy: logging the user out before re-authentication. ' );
10171010
@@ -1022,7 +1015,6 @@ public static function reauthLogout(array $state): void
10221015
10231016 $ idp = IdP::getByState ($ state );
10241017 $ idp ->handleLogoutRequest ($ state , null );
1025- Assert::true (false );
10261018 }
10271019
10281020
@@ -1031,7 +1023,7 @@ public static function reauthLogout(array $state): void
10311023 *
10321024 * @param array $state The authentication state.
10331025 */
1034- public static function reauthPostLogin (array $ state ): void
1026+ public static function reauthPostLogin (array $ state ): never
10351027 {
10361028 Assert::keyExists ($ state , 'ReturnCallback ' );
10371029
@@ -1042,7 +1034,6 @@ public static function reauthPostLogin(array $state): void
10421034
10431035 // resume the login process
10441036 call_user_func ($ state ['ReturnCallback ' ], $ state );
1045- Assert::true (false );
10461037 }
10471038
10481039
@@ -1054,7 +1045,7 @@ public static function reauthPostLogin(array $state): void
10541045 * @param \SimpleSAML\IdP $idp The IdP we are logging out from.
10551046 * @param array &$state The state array with the state during logout.
10561047 */
1057- public static function reauthPostLogout (IdP $ idp , array $ state ): void
1048+ public static function reauthPostLogout (IdP $ idp , array $ state ): never
10581049 {
10591050 Assert::keyExists ($ state , 'saml:sp:AuthId ' );
10601051
@@ -1069,7 +1060,6 @@ public static function reauthPostLogout(IdP $idp, array $state): void
10691060
10701061 Logger::debug ('Proxy: logging in again. ' );
10711062 $ sp ->authenticate ($ state );
1072- Assert::true (false );
10731063 }
10741064
10751065
@@ -1160,7 +1150,7 @@ public function logout(array &$state): void
11601150 * @param string $idp The entity id of the IdP.
11611151 * @param array $attributes The attributes.
11621152 */
1163- public function handleResponse (array $ state , string $ idp , array $ attributes ): void
1153+ public function handleResponse (array $ state , string $ idp , array $ attributes ): never
11641154 {
11651155 Assert::keyExists ($ state , 'LogoutState ' );
11661156 Assert::keyExists ($ state ['LogoutState ' ], 'saml:logout:Type ' );
@@ -1187,6 +1177,7 @@ public function handleResponse(array $state, string $idp, array $attributes): vo
11871177 if (isset ($ state ['saml:sp:NameID ' ])) {
11881178 $ authProcState ['saml:sp:NameID ' ] = $ state ['saml:sp:NameID ' ];
11891179 }
1180+
11901181 if (isset ($ state ['saml:sp:SessionIndex ' ])) {
11911182 $ authProcState ['saml:sp:SessionIndex ' ] = $ state ['saml:sp:SessionIndex ' ];
11921183 }
@@ -1203,7 +1194,7 @@ public function handleResponse(array $state, string $idp, array $attributes): vo
12031194 *
12041195 * @param string $idpEntityId The entity ID of the IdP.
12051196 */
1206- public function handleLogout (string $ idpEntityId ): void
1197+ public function handleLogout (string $ idpEntityId ): never
12071198 {
12081199 /* Call the logout callback we registered in onProcessingCompleted(). */
12091200 $ this ->callLogoutCallback ($ idpEntityId );
@@ -1224,7 +1215,7 @@ public function handleLogout(string $idpEntityId): void
12241215 * manually check the URL on beforehand. Please refer to the 'trusted.url.domains'
12251216 * configuration directive for more information about allowing (or disallowing) URLs.
12261217 */
1227- public static function handleUnsolicitedAuth (string $ authId , array $ state , string $ redirectTo ): void
1218+ public static function handleUnsolicitedAuth (string $ authId , array $ state , string $ redirectTo ): never
12281219 {
12291220 $ session = Session::getSessionFromRequest ();
12301221 $ session ->doLogin ($ authId , Auth \State::getPersistentAuthData ($ state ));
@@ -1239,7 +1230,7 @@ public static function handleUnsolicitedAuth(string $authId, array $state, strin
12391230 *
12401231 * @param array $authProcState The processing chain state.
12411232 */
1242- public static function onProcessingCompleted (array $ authProcState ): void
1233+ public static function onProcessingCompleted (array $ authProcState ): never
12431234 {
12441235 Assert::keyExists ($ authProcState , 'saml:sp:IdP ' );
12451236 Assert::keyExists ($ authProcState , 'saml:sp:State ' );
0 commit comments