Skip to content

Commit

Permalink
show error page if no valid client identifier is given and if it is n…
Browse files Browse the repository at this point in the history
…ot a API request

Signed-off-by: Bjoern Schiessle <bjoern@schiessle.org>
  • Loading branch information
schiessle authored and LukasReschke committed May 17, 2017
1 parent 1854429 commit 63593f9
Showing 1 changed file with 24 additions and 5 deletions.
29 changes: 24 additions & 5 deletions core/Controller/ClientFlowLoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,18 +151,37 @@ private function stateTokenForbiddenResponse() {
*/
public function showAuthPickerPage($clientIdentifier = '',
$oauthState = '') {
$stateToken = $this->random->generate(
64,
ISecureRandom::CHAR_LOWER.ISecureRandom::CHAR_UPPER.ISecureRandom::CHAR_DIGITS
);
$this->session->set(self::stateName, $stateToken);


$clientName = $this->getClientName();
$client = null;
if($clientIdentifier !== '') {
$client = $this->clientMapper->getByIdentifier($clientIdentifier);
$clientName = $client->getName();
}

$validClient = $client !== null && $client->getClientIdentifier() !== null;
$cookieCheckSuccessful = $this->request->passesStrictCookieCheck();

// no valid clientIdentifier given and no valid API Request (APIRequest header not set)
if ($cookieCheckSuccessful === false && $validClient === false) {
return new TemplateResponse(
$this->appName,
'error',
['errors' =>
[
['error' => 'Access Forbidden', 'hint' => 'Invalid request']
]
]
);
}

$stateToken = $this->random->generate(
64,
ISecureRandom::CHAR_LOWER.ISecureRandom::CHAR_UPPER.ISecureRandom::CHAR_DIGITS
);
$this->session->set(self::stateName, $stateToken);

return new TemplateResponse(
$this->appName,
'loginflow/authpicker',
Expand Down

0 comments on commit 63593f9

Please sign in to comment.