Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'core/Controller/ClientFlowLoginV2Controller.php')
-rw-r--r--core/Controller/ClientFlowLoginV2Controller.php34
1 files changed, 17 insertions, 17 deletions
diff --git a/core/Controller/ClientFlowLoginV2Controller.php b/core/Controller/ClientFlowLoginV2Controller.php
index 836606d301b..205c1ff8a1c 100644
--- a/core/Controller/ClientFlowLoginV2Controller.php
+++ b/core/Controller/ClientFlowLoginV2Controller.php
@@ -5,6 +5,8 @@ declare(strict_types=1);
/**
* @copyright Copyright (c) 2019, Roeland Jago Douma <roeland@famdouma.nl>
*
+ * @author Christoph Wurst <christoph@winzerhof-wurst.at>
+ * @author Joas Schilling <coding@schilljs.com>
* @author Roeland Jago Douma <roeland@famdouma.nl>
*
* @license GNU AGPL version 3 or any later version
@@ -16,14 +18,13 @@ declare(strict_types=1);
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
-
namespace OC\Core\Controller;
use OC\Core\Db\LoginFlowV2;
@@ -43,9 +44,8 @@ use OCP\IURLGenerator;
use OCP\Security\ISecureRandom;
class ClientFlowLoginV2Controller extends Controller {
-
- private const tokenName = 'client.flow.v2.login.token';
- private const stateName = 'client.flow.v2.state.token';
+ public const TOKEN_NAME = 'client.flow.v2.login.token';
+ public const STATE_NAME = 'client.flow.v2.state.token';
/** @var LoginFlowV2Service */
private $loginFlowV2Service;
@@ -105,7 +105,7 @@ class ClientFlowLoginV2Controller extends Controller {
return $this->loginTokenForbiddenResponse();
}
- $this->session->set(self::tokenName, $token);
+ $this->session->set(self::TOKEN_NAME, $token);
return new RedirectResponse(
$this->urlGenerator->linkToRouteAbsolute('core.ClientFlowLoginV2.showAuthPickerPage')
@@ -128,7 +128,7 @@ class ClientFlowLoginV2Controller extends Controller {
64,
ISecureRandom::CHAR_LOWER.ISecureRandom::CHAR_UPPER.ISecureRandom::CHAR_DIGITS
);
- $this->session->set(self::stateName, $stateToken);
+ $this->session->set(self::STATE_NAME, $stateToken);
return new StandaloneTemplateResponse(
$this->appName,
@@ -150,7 +150,7 @@ class ClientFlowLoginV2Controller extends Controller {
* @NoSameSiteCookieRequired
*/
public function grantPage(string $stateToken): StandaloneTemplateResponse {
- if(!$this->isValidStateToken($stateToken)) {
+ if (!$this->isValidStateToken($stateToken)) {
return $this->stateTokenForbiddenResponse();
}
@@ -178,7 +178,7 @@ class ClientFlowLoginV2Controller extends Controller {
* @UseSession
*/
public function generateAppPassword(string $stateToken): Response {
- if(!$this->isValidStateToken($stateToken)) {
+ if (!$this->isValidStateToken($stateToken)) {
return $this->stateTokenForbiddenResponse();
}
@@ -188,11 +188,11 @@ class ClientFlowLoginV2Controller extends Controller {
return $this->loginTokenForbiddenResponse();
}
- $loginToken = $this->session->get(self::tokenName);
+ $loginToken = $this->session->get(self::TOKEN_NAME);
// Clear session variables
- $this->session->remove(self::tokenName);
- $this->session->remove(self::stateName);
+ $this->session->remove(self::TOKEN_NAME);
+ $this->session->remove(self::STATE_NAME);
$sessionId = $this->session->getId();
$result = $this->loginFlowV2Service->flowDone($loginToken, $sessionId, $this->getServerPath(), $this->userId);
@@ -240,8 +240,8 @@ class ClientFlowLoginV2Controller extends Controller {
}
private function isValidStateToken(string $stateToken): bool {
- $currentToken = $this->session->get(self::stateName);
- if(!is_string($stateToken) || !is_string($currentToken)) {
+ $currentToken = $this->session->get(self::STATE_NAME);
+ if (!is_string($stateToken) || !is_string($currentToken)) {
return false;
}
return hash_equals($currentToken, $stateToken);
@@ -265,8 +265,8 @@ class ClientFlowLoginV2Controller extends Controller {
* @throws LoginFlowV2NotFoundException
*/
private function getFlowByLoginToken(): LoginFlowV2 {
- $currentToken = $this->session->get(self::tokenName);
- if(!is_string($currentToken)) {
+ $currentToken = $this->session->get(self::TOKEN_NAME);
+ if (!is_string($currentToken)) {
throw new LoginFlowV2NotFoundException('Login token not set in session');
}
@@ -291,7 +291,7 @@ class ClientFlowLoginV2Controller extends Controller {
if (strpos($this->request->getRequestUri(), '/index.php') !== false) {
$serverPostfix = substr($this->request->getRequestUri(), 0, strpos($this->request->getRequestUri(), '/index.php'));
- } else if (strpos($this->request->getRequestUri(), '/login/v2') !== false) {
+ } elseif (strpos($this->request->getRequestUri(), '/login/v2') !== false) {
$serverPostfix = substr($this->request->getRequestUri(), 0, strpos($this->request->getRequestUri(), '/login/v2'));
}