Skip to content

Commit

Permalink
Fix login flow form actions
Browse files Browse the repository at this point in the history
So fun fact. Chrome considers a redirect after submitting a form part of
the form actions. Since we redirect to a new protocol (nc://login/).
Causing the form submission to work but the redirect failing hard.

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
  • Loading branch information
rullzer committed Aug 11, 2019
1 parent 11cf253 commit 6dc179e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
16 changes: 14 additions & 2 deletions core/Controller/ClientFlowLoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,10 @@ public function showAuthPickerPage($clientIdentifier = '') {
);
$this->session->set(self::stateName, $stateToken);

return new StandaloneTemplateResponse(
$csp = new Http\ContentSecurityPolicy();
$csp->addAllowedFormActionDomain('nc://*');

$response = new StandaloneTemplateResponse(
$this->appName,
'loginflow/authpicker',
[
Expand All @@ -209,6 +212,9 @@ public function showAuthPickerPage($clientIdentifier = '') {
],
'guest'
);

$response->setContentSecurityPolicy($csp);
return $response;
}

/**
Expand All @@ -234,7 +240,10 @@ public function grantPage($stateToken = '',
$clientName = $client->getName();
}

return new StandaloneTemplateResponse(
$csp = new Http\ContentSecurityPolicy();
$csp->addAllowedFormActionDomain('nc://*');

$response = new StandaloneTemplateResponse(
$this->appName,
'loginflow/grant',
[
Expand All @@ -248,6 +257,9 @@ public function grantPage($stateToken = '',
],
'guest'
);

$response->setContentSecurityPolicy($csp);
return $response;
}

/**
Expand Down
6 changes: 6 additions & 0 deletions tests/Core/Controller/ClientFlowLoginControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,9 @@ public function testShowAuthPickerPageWithOcsHeader() {
],
'guest'
);
$csp = new Http\ContentSecurityPolicy();
$csp->addAllowedFormActionDomain('nc://*');
$expected->setContentSecurityPolicy($csp);
$this->assertEquals($expected, $this->clientFlowLoginController->showAuthPickerPage());
}

Expand Down Expand Up @@ -245,6 +248,9 @@ public function testShowAuthPickerPageWithOauth() {
],
'guest'
);
$csp = new Http\ContentSecurityPolicy();
$csp->addAllowedFormActionDomain('nc://*');
$expected->setContentSecurityPolicy($csp);
$this->assertEquals($expected, $this->clientFlowLoginController->showAuthPickerPage('MyClientIdentifier'));
}

Expand Down

0 comments on commit 6dc179e

Please sign in to comment.