|
|
|
|
@ -150,7 +150,10 @@ class ClientFlowLoginV2Controller extends Controller { |
|
|
|
|
* @NoSameSiteCookieRequired |
|
|
|
|
*/ |
|
|
|
|
#[UseSession] |
|
|
|
|
public function grantPage(string $stateToken): StandaloneTemplateResponse { |
|
|
|
|
public function grantPage(?string $stateToken): StandaloneTemplateResponse { |
|
|
|
|
if ($stateToken === null) { |
|
|
|
|
return $this->stateTokenMissingResponse(); |
|
|
|
|
} |
|
|
|
|
if (!$this->isValidStateToken($stateToken)) { |
|
|
|
|
return $this->stateTokenForbiddenResponse(); |
|
|
|
|
} |
|
|
|
|
@ -182,7 +185,11 @@ class ClientFlowLoginV2Controller extends Controller { |
|
|
|
|
/** |
|
|
|
|
* @PublicPage |
|
|
|
|
*/ |
|
|
|
|
public function apptokenRedirect(string $stateToken, string $user, string $password) { |
|
|
|
|
public function apptokenRedirect(?string $stateToken, string $user, string $password) { |
|
|
|
|
if ($stateToken === null) { |
|
|
|
|
return $this->loginTokenForbiddenResponse(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!$this->isValidStateToken($stateToken)) { |
|
|
|
|
return $this->stateTokenForbiddenResponse(); |
|
|
|
|
} |
|
|
|
|
@ -225,7 +232,10 @@ class ClientFlowLoginV2Controller extends Controller { |
|
|
|
|
* @NoAdminRequired |
|
|
|
|
*/ |
|
|
|
|
#[UseSession] |
|
|
|
|
public function generateAppPassword(string $stateToken): Response { |
|
|
|
|
public function generateAppPassword(?string $stateToken): Response { |
|
|
|
|
if ($stateToken === null) { |
|
|
|
|
return $this->stateTokenMissingResponse(); |
|
|
|
|
} |
|
|
|
|
if (!$this->isValidStateToken($stateToken)) { |
|
|
|
|
return $this->stateTokenForbiddenResponse(); |
|
|
|
|
} |
|
|
|
|
@ -298,6 +308,19 @@ class ClientFlowLoginV2Controller extends Controller { |
|
|
|
|
return hash_equals($currentToken, $stateToken); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private function stateTokenMissingResponse(): StandaloneTemplateResponse { |
|
|
|
|
$response = new StandaloneTemplateResponse( |
|
|
|
|
$this->appName, |
|
|
|
|
'403', |
|
|
|
|
[ |
|
|
|
|
'message' => $this->l10n->t('State token missing'), |
|
|
|
|
], |
|
|
|
|
'guest' |
|
|
|
|
); |
|
|
|
|
$response->setStatus(Http::STATUS_FORBIDDEN); |
|
|
|
|
return $response; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private function stateTokenForbiddenResponse(): StandaloneTemplateResponse { |
|
|
|
|
$response = new StandaloneTemplateResponse( |
|
|
|
|
$this->appName, |
|
|
|
|
|