|
|
|
|
@ -104,7 +104,7 @@ class ClientFlowLoginController extends Controller { |
|
|
|
|
$client = null; |
|
|
|
|
if ($clientIdentifier !== '') { |
|
|
|
|
$client = $this->clientMapper->getByIdentifier($clientIdentifier); |
|
|
|
|
$clientName = $client->getName(); |
|
|
|
|
$clientName = $client->name; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// No valid clientIdentifier given and no valid API Request (APIRequest header not set) |
|
|
|
|
@ -134,7 +134,7 @@ class ClientFlowLoginController extends Controller { |
|
|
|
|
|
|
|
|
|
$csp = new ContentSecurityPolicy(); |
|
|
|
|
if ($client) { |
|
|
|
|
$csp->addAllowedFormActionDomain($client->getRedirectUri()); |
|
|
|
|
$csp->addAllowedFormActionDomain($client->redirectUri); |
|
|
|
|
} else { |
|
|
|
|
$csp->addAllowedFormActionDomain('nc://*'); |
|
|
|
|
} |
|
|
|
|
@ -191,12 +191,12 @@ class ClientFlowLoginController extends Controller { |
|
|
|
|
$client = null; |
|
|
|
|
if ($clientIdentifier !== '') { |
|
|
|
|
$client = $this->clientMapper->getByIdentifier($clientIdentifier); |
|
|
|
|
$clientName = $client->getName(); |
|
|
|
|
$clientName = $client->name; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$csp = new ContentSecurityPolicy(); |
|
|
|
|
if ($client) { |
|
|
|
|
$csp->addAllowedFormActionDomain($client->getRedirectUri()); |
|
|
|
|
$csp->addAllowedFormActionDomain($client->redirectUri); |
|
|
|
|
} else { |
|
|
|
|
$csp->addAllowedFormActionDomain('nc://*'); |
|
|
|
|
} |
|
|
|
|
@ -274,7 +274,7 @@ class ClientFlowLoginController extends Controller { |
|
|
|
|
$client = false; |
|
|
|
|
if ($clientIdentifier !== '') { |
|
|
|
|
$client = $this->clientMapper->getByIdentifier($clientIdentifier); |
|
|
|
|
$clientName = $client->getName(); |
|
|
|
|
$clientName = $client->name; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$token = $this->random->generate(72, ISecureRandom::CHAR_UPPER . ISecureRandom::CHAR_LOWER . ISecureRandom::CHAR_DIGITS); |
|
|
|
|
@ -292,16 +292,16 @@ class ClientFlowLoginController extends Controller { |
|
|
|
|
if ($client) { |
|
|
|
|
$code = $this->random->generate(128, ISecureRandom::CHAR_UPPER . ISecureRandom::CHAR_LOWER . ISecureRandom::CHAR_DIGITS); |
|
|
|
|
$accessToken = new AccessToken(); |
|
|
|
|
$accessToken->setClientId($client->getId()); |
|
|
|
|
$accessToken->setEncryptedToken($this->crypto->encrypt($token, $code)); |
|
|
|
|
$accessToken->setHashedCode(hash('sha512', $code)); |
|
|
|
|
$accessToken->setTokenId($generatedToken->getId()); |
|
|
|
|
$accessToken->setCodeCreatedAt($this->timeFactory->now()->getTimestamp()); |
|
|
|
|
$accessToken->clientId = $client->id; |
|
|
|
|
$accessToken->encryptedToken = $this->crypto->encrypt($token, $code); |
|
|
|
|
$accessToken->hashedCode = hash('sha512', $code); |
|
|
|
|
$accessToken->tokenId = $generatedToken->getId(); |
|
|
|
|
$accessToken->codeCreatedAt = $this->timeFactory->now()->getTimestamp(); |
|
|
|
|
$this->accessTokenMapper->insert($accessToken); |
|
|
|
|
|
|
|
|
|
$enableOcClients = $this->config->getSystemValueBool('oauth2.enable_oc_clients', false); |
|
|
|
|
|
|
|
|
|
$redirectUri = $client->getRedirectUri(); |
|
|
|
|
$redirectUri = $client->redirectUri; |
|
|
|
|
if ($enableOcClients && $redirectUri === 'http://localhost:*') { |
|
|
|
|
// Sanity check untrusted redirect URI provided by the client first |
|
|
|
|
if (!preg_match('/^http:\/\/localhost:[0-9]+$/', $providedRedirectUri)) { |
|
|
|
|
|