Merge pull request #17411 from kinolaev/fix-oauth2-redirect

Fix oauth client redirect
This commit is contained in:
Roeland Jago Douma 2019-10-07 12:03:52 +02:00 committed by GitHub
commit a02a626606
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 3 deletions

View File

@ -196,7 +196,11 @@ class ClientFlowLoginController extends Controller {
$this->session->set(self::stateName, $stateToken);
$csp = new Http\ContentSecurityPolicy();
$csp->addAllowedFormActionDomain('nc://*');
if ($client) {
$csp->addAllowedFormActionDomain($client->getRedirectUri());
} else {
$csp->addAllowedFormActionDomain('nc://*');
}
$response = new StandaloneTemplateResponse(
$this->appName,
@ -241,7 +245,11 @@ class ClientFlowLoginController extends Controller {
}
$csp = new Http\ContentSecurityPolicy();
$csp->addAllowedFormActionDomain('nc://*');
if ($client) {
$csp->addAllowedFormActionDomain($client->getRedirectUri());
} else {
$csp->addAllowedFormActionDomain('nc://*');
}
$response = new StandaloneTemplateResponse(
$this->appName,

View File

@ -200,6 +200,7 @@ class ClientFlowLoginControllerTest extends TestCase {
->willReturn('Mac OS X Sync Client');
$client = new Client();
$client->setName('My external service');
$client->setRedirectUri('https://example.com/redirect.php');
$this->clientMapper
->expects($this->once())
->method('getByIdentifier')
@ -249,7 +250,7 @@ class ClientFlowLoginControllerTest extends TestCase {
'guest'
);
$csp = new Http\ContentSecurityPolicy();
$csp->addAllowedFormActionDomain('nc://*');
$csp->addAllowedFormActionDomain('https://example.com/redirect.php');
$expected->setContentSecurityPolicy($csp);
$this->assertEquals($expected, $this->clientFlowLoginController->showAuthPickerPage('MyClientIdentifier'));
}