@@ -39,72 +39,72 @@ |
||
| 39 | 39 | use OCP\IURLGenerator; |
| 40 | 40 | |
| 41 | 41 | class LoginRedirectorController extends Controller { |
| 42 | - /** @var IURLGenerator */ |
|
| 43 | - private $urlGenerator; |
|
| 44 | - /** @var ClientMapper */ |
|
| 45 | - private $clientMapper; |
|
| 46 | - /** @var ISession */ |
|
| 47 | - private $session; |
|
| 48 | - /** @var IL10N */ |
|
| 49 | - private $l; |
|
| 42 | + /** @var IURLGenerator */ |
|
| 43 | + private $urlGenerator; |
|
| 44 | + /** @var ClientMapper */ |
|
| 45 | + private $clientMapper; |
|
| 46 | + /** @var ISession */ |
|
| 47 | + private $session; |
|
| 48 | + /** @var IL10N */ |
|
| 49 | + private $l; |
|
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * @param string $appName |
|
| 53 | - * @param IRequest $request |
|
| 54 | - * @param IURLGenerator $urlGenerator |
|
| 55 | - * @param ClientMapper $clientMapper |
|
| 56 | - * @param ISession $session |
|
| 57 | - * @param IL10N $l |
|
| 58 | - */ |
|
| 59 | - public function __construct(string $appName, |
|
| 60 | - IRequest $request, |
|
| 61 | - IURLGenerator $urlGenerator, |
|
| 62 | - ClientMapper $clientMapper, |
|
| 63 | - ISession $session, |
|
| 64 | - IL10N $l) { |
|
| 65 | - parent::__construct($appName, $request); |
|
| 66 | - $this->urlGenerator = $urlGenerator; |
|
| 67 | - $this->clientMapper = $clientMapper; |
|
| 68 | - $this->session = $session; |
|
| 69 | - $this->l = $l; |
|
| 70 | - } |
|
| 51 | + /** |
|
| 52 | + * @param string $appName |
|
| 53 | + * @param IRequest $request |
|
| 54 | + * @param IURLGenerator $urlGenerator |
|
| 55 | + * @param ClientMapper $clientMapper |
|
| 56 | + * @param ISession $session |
|
| 57 | + * @param IL10N $l |
|
| 58 | + */ |
|
| 59 | + public function __construct(string $appName, |
|
| 60 | + IRequest $request, |
|
| 61 | + IURLGenerator $urlGenerator, |
|
| 62 | + ClientMapper $clientMapper, |
|
| 63 | + ISession $session, |
|
| 64 | + IL10N $l) { |
|
| 65 | + parent::__construct($appName, $request); |
|
| 66 | + $this->urlGenerator = $urlGenerator; |
|
| 67 | + $this->clientMapper = $clientMapper; |
|
| 68 | + $this->session = $session; |
|
| 69 | + $this->l = $l; |
|
| 70 | + } |
|
| 71 | 71 | |
| 72 | - /** |
|
| 73 | - * @PublicPage |
|
| 74 | - * @NoCSRFRequired |
|
| 75 | - * @UseSession |
|
| 76 | - * |
|
| 77 | - * @param string $client_id |
|
| 78 | - * @param string $state |
|
| 79 | - * @param string $response_type |
|
| 80 | - * @return Response |
|
| 81 | - */ |
|
| 82 | - public function authorize($client_id, |
|
| 83 | - $state, |
|
| 84 | - $response_type): Response { |
|
| 85 | - try { |
|
| 86 | - $client = $this->clientMapper->getByIdentifier($client_id); |
|
| 87 | - } catch (ClientNotFoundException $e) { |
|
| 88 | - $params = [ |
|
| 89 | - 'content' => $this->l->t('Your client is not authorized to connect. Please inform the administrator of your client.'), |
|
| 90 | - ]; |
|
| 91 | - return new TemplateResponse('core', '404', $params, 'guest'); |
|
| 92 | - } |
|
| 72 | + /** |
|
| 73 | + * @PublicPage |
|
| 74 | + * @NoCSRFRequired |
|
| 75 | + * @UseSession |
|
| 76 | + * |
|
| 77 | + * @param string $client_id |
|
| 78 | + * @param string $state |
|
| 79 | + * @param string $response_type |
|
| 80 | + * @return Response |
|
| 81 | + */ |
|
| 82 | + public function authorize($client_id, |
|
| 83 | + $state, |
|
| 84 | + $response_type): Response { |
|
| 85 | + try { |
|
| 86 | + $client = $this->clientMapper->getByIdentifier($client_id); |
|
| 87 | + } catch (ClientNotFoundException $e) { |
|
| 88 | + $params = [ |
|
| 89 | + 'content' => $this->l->t('Your client is not authorized to connect. Please inform the administrator of your client.'), |
|
| 90 | + ]; |
|
| 91 | + return new TemplateResponse('core', '404', $params, 'guest'); |
|
| 92 | + } |
|
| 93 | 93 | |
| 94 | - if ($response_type !== 'code') { |
|
| 95 | - //Fail |
|
| 96 | - $url = $client->getRedirectUri() . '?error=unsupported_response_type&state=' . $state; |
|
| 97 | - return new RedirectResponse($url); |
|
| 98 | - } |
|
| 94 | + if ($response_type !== 'code') { |
|
| 95 | + //Fail |
|
| 96 | + $url = $client->getRedirectUri() . '?error=unsupported_response_type&state=' . $state; |
|
| 97 | + return new RedirectResponse($url); |
|
| 98 | + } |
|
| 99 | 99 | |
| 100 | - $this->session->set('oauth.state', $state); |
|
| 100 | + $this->session->set('oauth.state', $state); |
|
| 101 | 101 | |
| 102 | - $targetUrl = $this->urlGenerator->linkToRouteAbsolute( |
|
| 103 | - 'core.ClientFlowLogin.showAuthPickerPage', |
|
| 104 | - [ |
|
| 105 | - 'clientIdentifier' => $client->getClientIdentifier(), |
|
| 106 | - ] |
|
| 107 | - ); |
|
| 108 | - return new RedirectResponse($targetUrl); |
|
| 109 | - } |
|
| 102 | + $targetUrl = $this->urlGenerator->linkToRouteAbsolute( |
|
| 103 | + 'core.ClientFlowLogin.showAuthPickerPage', |
|
| 104 | + [ |
|
| 105 | + 'clientIdentifier' => $client->getClientIdentifier(), |
|
| 106 | + ] |
|
| 107 | + ); |
|
| 108 | + return new RedirectResponse($targetUrl); |
|
| 109 | + } |
|
| 110 | 110 | } |