|RedirectResponse * * 200: Client not found * 303: Redirect to login URL */ #[PublicPage] #[NoCSRFRequired] #[UseSession] public function authorize($client_id, $state, $response_type): TemplateResponse|RedirectResponse { try { $client = $this->clientMapper->getByIdentifier($client_id); } catch (ClientNotFoundException $e) { $params = [ 'content' => $this->l->t('Your client is not authorized to connect. Please inform the administrator of your client.'), ]; return new TemplateResponse('core', '404', $params, 'guest'); } if ($response_type !== 'code') { //Fail $url = $client->getRedirectUri() . '?error=unsupported_response_type&state=' . $state; return new RedirectResponse($url); } $this->session->set('oauth.state', $state); if (in_array($client->getName(), $this->appConfig->getValueArray('oauth2', 'skipAuthPickerApplications', []))) { /** @see ClientFlowLoginController::showAuthPickerPage **/ $stateToken = $this->random->generate( 64, ISecureRandom::CHAR_LOWER . ISecureRandom::CHAR_UPPER . ISecureRandom::CHAR_DIGITS ); $this->session->set(ClientFlowLoginController::STATE_NAME, $stateToken); $targetUrl = $this->urlGenerator->linkToRouteAbsolute( 'core.ClientFlowLogin.grantPage', [ 'stateToken' => $stateToken, 'clientIdentifier' => $client->getClientIdentifier(), ] ); } else { $targetUrl = $this->urlGenerator->linkToRouteAbsolute( 'core.ClientFlowLogin.showAuthPickerPage', [ 'clientIdentifier' => $client->getClientIdentifier(), ] ); } return new RedirectResponse($targetUrl); } }