Skip to content

Commit

Permalink
Merge pull request #16711 from nextcloud/fix/csp/form_actions/loginflow
Browse files Browse the repository at this point in the history
Fix login flow form actions
  • Loading branch information
rullzer authored Aug 12, 2019
2 parents ec03059 + 6dc179e commit fced73a
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 fced73a

Please sign in to comment.