@@ -104,10 +104,10 @@ public function handleLoginRequest(
104104 $ userDiscoveryModule = $ this ->config ->getSystemValueString ('gss.user.discovery.module ' , '' );
105105 $ this ->logger ->debug ('handleLoginRequest: discovery module is: ' . $ userDiscoveryModule );
106106
107- $ isSaml = false ;
107+ $ isSamlOrOidc = false ;
108108 if (class_exists ('\OCA\User_SAML\UserBackend ' )
109109 && $ backend instanceof \OCA \User_SAML \UserBackend) {
110- $ isSaml = true ;
110+ $ isSamlOrOidc = true ;
111111 $ this ->logger ->debug ('handleLoginRequest: backend is SAML ' );
112112
113113 $ options ['backend ' ] = 'saml ' ;
@@ -122,8 +122,29 @@ public function handleLoginRequest(
122122 ];
123123
124124 $ this ->logger ->debug ('handleLoginRequest: backend is SAML. ' , ['options ' => $ options ]);
125+ } elseif (class_exists ('\OCA\UserOIDC\Controller\LoginController ' )
126+ && class_exists ('\OCA\UserOIDC\User\Backend ' )
127+ && $ backend instanceof \OCA \UserOIDC \User \Backend
128+ && method_exists ($ backend , 'getUserData ' )
129+ ) {
130+ // TODO double check if we need to behave the same when saml or oidc is used
131+ $ isSamlOrOidc = true ;
132+ $ this ->logger ->debug ('handleLoginRequest: backend is OIDC ' );
133+
134+ $ options ['backend ' ] = 'oidc ' ;
135+ $ options ['userData ' ] = $ backend ->getUserData ();
136+ $ uid = $ options ['userData ' ]['formatted ' ]['uid ' ];
137+ $ password = '' ;
138+ $ discoveryData ['oidc ' ] = $ options ['userData ' ]['raw ' ];
139+ // we only send the formatted user data to the slave
140+ $ options ['userData ' ] = $ options ['userData ' ]['formatted ' ];
141+ $ options ['oidc ' ] = [
142+ 'providerId ' => $ this ->session ->get (\OCA \UserOIDC \Controller \LoginController::PROVIDERID )
143+ ];
144+
145+ $ this ->logger ->debug ('handleLoginRequest: backend is OIDC. ' , ['options ' => $ options ]);
125146 } else {
126- $ this ->logger ->debug ('handleLoginRequest: backend is not SAML ' );
147+ $ this ->logger ->debug ('handleLoginRequest: backend is not SAML or OIDC ' );
127148 }
128149
129150 $ this ->logger ->debug ('handleLoginRequest: uid is: ' . $ uid );
@@ -141,8 +162,8 @@ public function handleLoginRequest(
141162 }
142163
143164 // first ask the lookup server if we already know the user
144- // is from SAML, only search on userId, ignore email.
145- $ location = $ this ->queryLookupServer ($ uid , $ isSaml );
165+ // is from SAML or OIDC , only search on userId, ignore email.
166+ $ location = $ this ->queryLookupServer ($ uid , $ isSamlOrOidc );
146167 $ this ->logger ->debug ('handleLoginRequest: location according to lookup server: ' . $ location );
147168
148169 // if not we fall-back to a initial user deployment method, if configured
0 commit comments