Passed
Push — master ( 873501...d2df81 )
by Maxence
14:59 queued 12s
created
core/Command/TwoFactorAuth/State.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -99,9 +99,9 @@
 block discarded – undo
99 99
 			return;
100 100
 		}
101 101
 
102
-		$output->writeln($title . ":");
102
+		$output->writeln($title.":");
103 103
 		foreach ($providers as $provider) {
104
-			$output->writeln("- " . $provider);
104
+			$output->writeln("- ".$provider);
105 105
 		}
106 106
 	}
107 107
 }
Please login to merge, or discard this patch.
Indentation   +69 added lines, -69 removed lines patch added patch discarded remove patch
@@ -33,73 +33,73 @@
 block discarded – undo
33 33
 use Symfony\Component\Console\Output\OutputInterface;
34 34
 
35 35
 class State extends Base {
36
-	private IRegistry $registry;
37
-
38
-	public function __construct(IRegistry $registry, IUserManager $userManager) {
39
-		parent::__construct('twofactorauth:state');
40
-
41
-		$this->registry = $registry;
42
-		$this->userManager = $userManager;
43
-	}
44
-
45
-	protected function configure() {
46
-		parent::configure();
47
-
48
-		$this->setName('twofactorauth:state');
49
-		$this->setDescription('Get the two-factor authentication (2FA) state of a user');
50
-		$this->addArgument('uid', InputArgument::REQUIRED);
51
-	}
52
-
53
-	protected function execute(InputInterface $input, OutputInterface $output): int {
54
-		$uid = $input->getArgument('uid');
55
-		$user = $this->userManager->get($uid);
56
-		if (is_null($user)) {
57
-			$output->writeln("<error>Invalid UID</error>");
58
-			return 1;
59
-		}
60
-
61
-		$providerStates = $this->registry->getProviderStates($user);
62
-		$filtered = $this->filterEnabledDisabledUnknownProviders($providerStates);
63
-		[$enabled, $disabled] = $filtered;
64
-
65
-		if (!empty($enabled)) {
66
-			$output->writeln("Two-factor authentication is enabled for user $uid");
67
-		} else {
68
-			$output->writeln("Two-factor authentication is not enabled for user $uid");
69
-		}
70
-
71
-		$output->writeln("");
72
-		$this->printProviders("Enabled providers", $enabled, $output);
73
-		$this->printProviders("Disabled providers", $disabled, $output);
74
-
75
-		return 0;
76
-	}
77
-
78
-	private function filterEnabledDisabledUnknownProviders(array $providerStates): array {
79
-		$enabled = [];
80
-		$disabled = [];
81
-
82
-		foreach ($providerStates as $providerId => $isEnabled) {
83
-			if ($isEnabled) {
84
-				$enabled[] = $providerId;
85
-			} else {
86
-				$disabled[] = $providerId;
87
-			}
88
-		}
89
-
90
-		return [$enabled, $disabled];
91
-	}
92
-
93
-	private function printProviders(string $title, array $providers,
94
-									OutputInterface $output) {
95
-		if (empty($providers)) {
96
-			// Ignore and don't print anything
97
-			return;
98
-		}
99
-
100
-		$output->writeln($title . ":");
101
-		foreach ($providers as $provider) {
102
-			$output->writeln("- " . $provider);
103
-		}
104
-	}
36
+    private IRegistry $registry;
37
+
38
+    public function __construct(IRegistry $registry, IUserManager $userManager) {
39
+        parent::__construct('twofactorauth:state');
40
+
41
+        $this->registry = $registry;
42
+        $this->userManager = $userManager;
43
+    }
44
+
45
+    protected function configure() {
46
+        parent::configure();
47
+
48
+        $this->setName('twofactorauth:state');
49
+        $this->setDescription('Get the two-factor authentication (2FA) state of a user');
50
+        $this->addArgument('uid', InputArgument::REQUIRED);
51
+    }
52
+
53
+    protected function execute(InputInterface $input, OutputInterface $output): int {
54
+        $uid = $input->getArgument('uid');
55
+        $user = $this->userManager->get($uid);
56
+        if (is_null($user)) {
57
+            $output->writeln("<error>Invalid UID</error>");
58
+            return 1;
59
+        }
60
+
61
+        $providerStates = $this->registry->getProviderStates($user);
62
+        $filtered = $this->filterEnabledDisabledUnknownProviders($providerStates);
63
+        [$enabled, $disabled] = $filtered;
64
+
65
+        if (!empty($enabled)) {
66
+            $output->writeln("Two-factor authentication is enabled for user $uid");
67
+        } else {
68
+            $output->writeln("Two-factor authentication is not enabled for user $uid");
69
+        }
70
+
71
+        $output->writeln("");
72
+        $this->printProviders("Enabled providers", $enabled, $output);
73
+        $this->printProviders("Disabled providers", $disabled, $output);
74
+
75
+        return 0;
76
+    }
77
+
78
+    private function filterEnabledDisabledUnknownProviders(array $providerStates): array {
79
+        $enabled = [];
80
+        $disabled = [];
81
+
82
+        foreach ($providerStates as $providerId => $isEnabled) {
83
+            if ($isEnabled) {
84
+                $enabled[] = $providerId;
85
+            } else {
86
+                $disabled[] = $providerId;
87
+            }
88
+        }
89
+
90
+        return [$enabled, $disabled];
91
+    }
92
+
93
+    private function printProviders(string $title, array $providers,
94
+                                    OutputInterface $output) {
95
+        if (empty($providers)) {
96
+            // Ignore and don't print anything
97
+            return;
98
+        }
99
+
100
+        $output->writeln($title . ":");
101
+        foreach ($providers as $provider) {
102
+            $output->writeln("- " . $provider);
103
+        }
104
+    }
105 105
 }
Please login to merge, or discard this patch.
core/Command/Config/System/DeleteConfig.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 
68 68
 		if (count($configNames) > 1) {
69 69
 			if ($input->hasParameterOption('--error-if-not-exists') && !in_array($configName, $this->systemConfig->getKeys())) {
70
-				$output->writeln('<error>System config ' . implode(' => ', $configNames) . ' could not be deleted because it did not exist</error>');
70
+				$output->writeln('<error>System config '.implode(' => ', $configNames).' could not be deleted because it did not exist</error>');
71 71
 				return 1;
72 72
 			}
73 73
 
@@ -76,21 +76,21 @@  discard block
 block discarded – undo
76 76
 			try {
77 77
 				$value = $this->removeSubValue(array_slice($configNames, 1), $value, $input->hasParameterOption('--error-if-not-exists'));
78 78
 			} catch (\UnexpectedValueException $e) {
79
-				$output->writeln('<error>System config ' . implode(' => ', $configNames) . ' could not be deleted because it did not exist</error>');
79
+				$output->writeln('<error>System config '.implode(' => ', $configNames).' could not be deleted because it did not exist</error>');
80 80
 				return 1;
81 81
 			}
82 82
 
83 83
 			$this->systemConfig->setValue($configName, $value);
84
-			$output->writeln('<info>System config value ' . implode(' => ', $configNames) . ' deleted</info>');
84
+			$output->writeln('<info>System config value '.implode(' => ', $configNames).' deleted</info>');
85 85
 			return 0;
86 86
 		} else {
87 87
 			if ($input->hasParameterOption('--error-if-not-exists') && !in_array($configName, $this->systemConfig->getKeys())) {
88
-				$output->writeln('<error>System config ' . $configName . ' could not be deleted because it did not exist</error>');
88
+				$output->writeln('<error>System config '.$configName.' could not be deleted because it did not exist</error>');
89 89
 				return 1;
90 90
 			}
91 91
 
92 92
 			$this->systemConfig->deleteValue($configName);
93
-			$output->writeln('<info>System config value ' . $configName . ' deleted</info>');
93
+			$output->writeln('<info>System config value '.$configName.' deleted</info>');
94 94
 			return 0;
95 95
 		}
96 96
 	}
Please login to merge, or discard this patch.
Indentation   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -30,81 +30,81 @@
 block discarded – undo
30 30
 use Symfony\Component\Console\Output\OutputInterface;
31 31
 
32 32
 class DeleteConfig extends Base {
33
-	public function __construct(SystemConfig $systemConfig) {
34
-		parent::__construct($systemConfig);
35
-	}
33
+    public function __construct(SystemConfig $systemConfig) {
34
+        parent::__construct($systemConfig);
35
+    }
36 36
 
37
-	protected function configure() {
38
-		parent::configure();
37
+    protected function configure() {
38
+        parent::configure();
39 39
 
40
-		$this
41
-			->setName('config:system:delete')
42
-			->setDescription('Delete a system config value')
43
-			->addArgument(
44
-				'name',
45
-				InputArgument::REQUIRED | InputArgument::IS_ARRAY,
46
-				'Name of the config to delete, specify multiple for array parameter'
47
-			)
48
-			->addOption(
49
-				'error-if-not-exists',
50
-				null,
51
-				InputOption::VALUE_NONE,
52
-				'Checks whether the config exists before deleting it'
53
-			)
54
-		;
55
-	}
40
+        $this
41
+            ->setName('config:system:delete')
42
+            ->setDescription('Delete a system config value')
43
+            ->addArgument(
44
+                'name',
45
+                InputArgument::REQUIRED | InputArgument::IS_ARRAY,
46
+                'Name of the config to delete, specify multiple for array parameter'
47
+            )
48
+            ->addOption(
49
+                'error-if-not-exists',
50
+                null,
51
+                InputOption::VALUE_NONE,
52
+                'Checks whether the config exists before deleting it'
53
+            )
54
+        ;
55
+    }
56 56
 
57
-	protected function execute(InputInterface $input, OutputInterface $output): int {
58
-		$configNames = $input->getArgument('name');
59
-		$configName = $configNames[0];
57
+    protected function execute(InputInterface $input, OutputInterface $output): int {
58
+        $configNames = $input->getArgument('name');
59
+        $configName = $configNames[0];
60 60
 
61
-		if (count($configNames) > 1) {
62
-			if ($input->hasParameterOption('--error-if-not-exists') && !in_array($configName, $this->systemConfig->getKeys())) {
63
-				$output->writeln('<error>System config ' . implode(' => ', $configNames) . ' could not be deleted because it did not exist</error>');
64
-				return 1;
65
-			}
61
+        if (count($configNames) > 1) {
62
+            if ($input->hasParameterOption('--error-if-not-exists') && !in_array($configName, $this->systemConfig->getKeys())) {
63
+                $output->writeln('<error>System config ' . implode(' => ', $configNames) . ' could not be deleted because it did not exist</error>');
64
+                return 1;
65
+            }
66 66
 
67
-			$value = $this->systemConfig->getValue($configName);
67
+            $value = $this->systemConfig->getValue($configName);
68 68
 
69
-			try {
70
-				$value = $this->removeSubValue(array_slice($configNames, 1), $value, $input->hasParameterOption('--error-if-not-exists'));
71
-			} catch (\UnexpectedValueException $e) {
72
-				$output->writeln('<error>System config ' . implode(' => ', $configNames) . ' could not be deleted because it did not exist</error>');
73
-				return 1;
74
-			}
69
+            try {
70
+                $value = $this->removeSubValue(array_slice($configNames, 1), $value, $input->hasParameterOption('--error-if-not-exists'));
71
+            } catch (\UnexpectedValueException $e) {
72
+                $output->writeln('<error>System config ' . implode(' => ', $configNames) . ' could not be deleted because it did not exist</error>');
73
+                return 1;
74
+            }
75 75
 
76
-			$this->systemConfig->setValue($configName, $value);
77
-			$output->writeln('<info>System config value ' . implode(' => ', $configNames) . ' deleted</info>');
78
-			return 0;
79
-		} else {
80
-			if ($input->hasParameterOption('--error-if-not-exists') && !in_array($configName, $this->systemConfig->getKeys())) {
81
-				$output->writeln('<error>System config ' . $configName . ' could not be deleted because it did not exist</error>');
82
-				return 1;
83
-			}
76
+            $this->systemConfig->setValue($configName, $value);
77
+            $output->writeln('<info>System config value ' . implode(' => ', $configNames) . ' deleted</info>');
78
+            return 0;
79
+        } else {
80
+            if ($input->hasParameterOption('--error-if-not-exists') && !in_array($configName, $this->systemConfig->getKeys())) {
81
+                $output->writeln('<error>System config ' . $configName . ' could not be deleted because it did not exist</error>');
82
+                return 1;
83
+            }
84 84
 
85
-			$this->systemConfig->deleteValue($configName);
86
-			$output->writeln('<info>System config value ' . $configName . ' deleted</info>');
87
-			return 0;
88
-		}
89
-	}
85
+            $this->systemConfig->deleteValue($configName);
86
+            $output->writeln('<info>System config value ' . $configName . ' deleted</info>');
87
+            return 0;
88
+        }
89
+    }
90 90
 
91
-	protected function removeSubValue($keys, $currentValue, $throwError) {
92
-		$nextKey = array_shift($keys);
91
+    protected function removeSubValue($keys, $currentValue, $throwError) {
92
+        $nextKey = array_shift($keys);
93 93
 
94
-		if (is_array($currentValue)) {
95
-			if (isset($currentValue[$nextKey])) {
96
-				if (empty($keys)) {
97
-					unset($currentValue[$nextKey]);
98
-				} else {
99
-					$currentValue[$nextKey] = $this->removeSubValue($keys, $currentValue[$nextKey], $throwError);
100
-				}
101
-			} elseif ($throwError) {
102
-				throw new \UnexpectedValueException('Config parameter does not exist');
103
-			}
104
-		} elseif ($throwError) {
105
-			throw new \UnexpectedValueException('Config parameter does not exist');
106
-		}
94
+        if (is_array($currentValue)) {
95
+            if (isset($currentValue[$nextKey])) {
96
+                if (empty($keys)) {
97
+                    unset($currentValue[$nextKey]);
98
+                } else {
99
+                    $currentValue[$nextKey] = $this->removeSubValue($keys, $currentValue[$nextKey], $throwError);
100
+                }
101
+            } elseif ($throwError) {
102
+                throw new \UnexpectedValueException('Config parameter does not exist');
103
+            }
104
+        } elseif ($throwError) {
105
+            throw new \UnexpectedValueException('Config parameter does not exist');
106
+        }
107 107
 
108
-		return $currentValue;
109
-	}
108
+        return $currentValue;
109
+    }
110 110
 }
Please login to merge, or discard this patch.
core/Controller/CssController.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -108,7 +108,7 @@
 block discarded – undo
108 108
 		if (strpos($encoding, 'gzip') !== false) {
109 109
 			try {
110 110
 				$gzip = true;
111
-				return $folder->getFile($fileName . '.gzip'); # Safari doesn't like .gz
111
+				return $folder->getFile($fileName.'.gzip'); # Safari doesn't like .gz
112 112
 			} catch (NotFoundException $e) {
113 113
 				// continue
114 114
 			}
Please login to merge, or discard this patch.
Indentation   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -44,73 +44,73 @@
 block discarded – undo
44 44
 use OCP\IRequest;
45 45
 
46 46
 class CssController extends Controller {
47
-	protected IAppData $appData;
48
-	protected ITimeFactory $timeFactory;
47
+    protected IAppData $appData;
48
+    protected ITimeFactory $timeFactory;
49 49
 
50
-	public function __construct(string $appName,
51
-								IRequest $request,
52
-								Factory $appDataFactory,
53
-								ITimeFactory $timeFactory) {
54
-		parent::__construct($appName, $request);
50
+    public function __construct(string $appName,
51
+                                IRequest $request,
52
+                                Factory $appDataFactory,
53
+                                ITimeFactory $timeFactory) {
54
+        parent::__construct($appName, $request);
55 55
 
56
-		$this->appData = $appDataFactory->get('css');
57
-		$this->timeFactory = $timeFactory;
58
-	}
56
+        $this->appData = $appDataFactory->get('css');
57
+        $this->timeFactory = $timeFactory;
58
+    }
59 59
 
60
-	/**
61
-	 * @PublicPage
62
-	 * @NoCSRFRequired
63
-	 * @NoSameSiteCookieRequired
64
-	 *
65
-	 * @param string $fileName css filename with extension
66
-	 * @param string $appName css folder name
67
-	 * @return FileDisplayResponse|NotFoundResponse
68
-	 */
69
-	public function getCss(string $fileName, string $appName): Response {
70
-		try {
71
-			$folder = $this->appData->getFolder($appName);
72
-			$gzip = false;
73
-			$file = $this->getFile($folder, $fileName, $gzip);
74
-		} catch (NotFoundException $e) {
75
-			return new NotFoundResponse();
76
-		}
60
+    /**
61
+     * @PublicPage
62
+     * @NoCSRFRequired
63
+     * @NoSameSiteCookieRequired
64
+     *
65
+     * @param string $fileName css filename with extension
66
+     * @param string $appName css folder name
67
+     * @return FileDisplayResponse|NotFoundResponse
68
+     */
69
+    public function getCss(string $fileName, string $appName): Response {
70
+        try {
71
+            $folder = $this->appData->getFolder($appName);
72
+            $gzip = false;
73
+            $file = $this->getFile($folder, $fileName, $gzip);
74
+        } catch (NotFoundException $e) {
75
+            return new NotFoundResponse();
76
+        }
77 77
 
78
-		$response = new FileDisplayResponse($file, Http::STATUS_OK, ['Content-Type' => 'text/css']);
79
-		if ($gzip) {
80
-			$response->addHeader('Content-Encoding', 'gzip');
81
-		}
78
+        $response = new FileDisplayResponse($file, Http::STATUS_OK, ['Content-Type' => 'text/css']);
79
+        if ($gzip) {
80
+            $response->addHeader('Content-Encoding', 'gzip');
81
+        }
82 82
 
83
-		$ttl = 31536000;
84
-		$response->addHeader('Cache-Control', 'max-age='.$ttl.', immutable');
83
+        $ttl = 31536000;
84
+        $response->addHeader('Cache-Control', 'max-age='.$ttl.', immutable');
85 85
 
86
-		$expires = new \DateTime();
87
-		$expires->setTimestamp($this->timeFactory->getTime());
88
-		$expires->add(new \DateInterval('PT'.$ttl.'S'));
89
-		$response->addHeader('Expires', $expires->format(\DateTime::RFC1123));
90
-		$response->addHeader('Pragma', 'cache');
91
-		return $response;
92
-	}
86
+        $expires = new \DateTime();
87
+        $expires->setTimestamp($this->timeFactory->getTime());
88
+        $expires->add(new \DateInterval('PT'.$ttl.'S'));
89
+        $response->addHeader('Expires', $expires->format(\DateTime::RFC1123));
90
+        $response->addHeader('Pragma', 'cache');
91
+        return $response;
92
+    }
93 93
 
94
-	/**
95
-	 * @param ISimpleFolder $folder
96
-	 * @param string $fileName
97
-	 * @param bool $gzip is set to true if we use the gzip file
98
-	 * @return ISimpleFile
99
-	 * @throws NotFoundException
100
-	 */
101
-	private function getFile(ISimpleFolder $folder, string $fileName, bool &$gzip): ISimpleFile {
102
-		$encoding = $this->request->getHeader('Accept-Encoding');
94
+    /**
95
+     * @param ISimpleFolder $folder
96
+     * @param string $fileName
97
+     * @param bool $gzip is set to true if we use the gzip file
98
+     * @return ISimpleFile
99
+     * @throws NotFoundException
100
+     */
101
+    private function getFile(ISimpleFolder $folder, string $fileName, bool &$gzip): ISimpleFile {
102
+        $encoding = $this->request->getHeader('Accept-Encoding');
103 103
 
104
-		if (strpos($encoding, 'gzip') !== false) {
105
-			try {
106
-				$gzip = true;
107
-				return $folder->getFile($fileName . '.gzip'); # Safari doesn't like .gz
108
-			} catch (NotFoundException $e) {
109
-				// continue
110
-			}
111
-		}
104
+        if (strpos($encoding, 'gzip') !== false) {
105
+            try {
106
+                $gzip = true;
107
+                return $folder->getFile($fileName . '.gzip'); # Safari doesn't like .gz
108
+            } catch (NotFoundException $e) {
109
+                // continue
110
+            }
111
+        }
112 112
 
113
-		$gzip = false;
114
-		return $folder->getFile($fileName);
115
-	}
113
+        $gzip = false;
114
+        return $folder->getFile($fileName);
115
+    }
116 116
 }
Please login to merge, or discard this patch.
core/Controller/ClientFlowLoginV2Controller.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -295,6 +295,6 @@
 block discarded – undo
295 295
 		}
296 296
 
297 297
 		$protocol = $this->request->getServerProtocol();
298
-		return $protocol . '://' . $this->request->getServerHost() . $serverPostfix;
298
+		return $protocol.'://'.$this->request->getServerHost().$serverPostfix;
299 299
 	}
300 300
 }
Please login to merge, or discard this patch.
Indentation   +301 added lines, -301 removed lines patch added patch discarded remove patch
@@ -48,305 +48,305 @@
 block discarded – undo
48 48
 use OCP\Security\ISecureRandom;
49 49
 
50 50
 class ClientFlowLoginV2Controller extends Controller {
51
-	public const TOKEN_NAME = 'client.flow.v2.login.token';
52
-	public const STATE_NAME = 'client.flow.v2.state.token';
53
-
54
-	private LoginFlowV2Service $loginFlowV2Service;
55
-	private IURLGenerator $urlGenerator;
56
-	private IUserSession $userSession;
57
-	private ISession $session;
58
-	private ISecureRandom $random;
59
-	private Defaults $defaults;
60
-	private ?string $userId;
61
-	private IL10N $l10n;
62
-
63
-	public function __construct(string $appName,
64
-								IRequest $request,
65
-								LoginFlowV2Service $loginFlowV2Service,
66
-								IURLGenerator $urlGenerator,
67
-								ISession $session,
68
-								IUserSession $userSession,
69
-								ISecureRandom $random,
70
-								Defaults $defaults,
71
-								?string $userId,
72
-								IL10N $l10n) {
73
-		parent::__construct($appName, $request);
74
-		$this->loginFlowV2Service = $loginFlowV2Service;
75
-		$this->urlGenerator = $urlGenerator;
76
-		$this->session = $session;
77
-		$this->userSession = $userSession;
78
-		$this->random = $random;
79
-		$this->defaults = $defaults;
80
-		$this->userId = $userId;
81
-		$this->l10n = $l10n;
82
-	}
83
-
84
-	/**
85
-	 * @NoCSRFRequired
86
-	 * @PublicPage
87
-	 */
88
-	public function poll(string $token): JSONResponse {
89
-		try {
90
-			$creds = $this->loginFlowV2Service->poll($token);
91
-		} catch (LoginFlowV2NotFoundException $e) {
92
-			return new JSONResponse([], Http::STATUS_NOT_FOUND);
93
-		}
94
-
95
-		return new JSONResponse($creds);
96
-	}
97
-
98
-	/**
99
-	 * @NoCSRFRequired
100
-	 * @PublicPage
101
-	 */
102
-	#[UseSession]
103
-	public function landing(string $token, $user = ''): Response {
104
-		if (!$this->loginFlowV2Service->startLoginFlow($token)) {
105
-			return $this->loginTokenForbiddenResponse();
106
-		}
107
-
108
-		$this->session->set(self::TOKEN_NAME, $token);
109
-
110
-		return new RedirectResponse(
111
-			$this->urlGenerator->linkToRouteAbsolute('core.ClientFlowLoginV2.showAuthPickerPage', ['user' => $user])
112
-		);
113
-	}
114
-
115
-	/**
116
-	 * @NoCSRFRequired
117
-	 * @PublicPage
118
-	 */
119
-	#[UseSession]
120
-	public function showAuthPickerPage($user = ''): StandaloneTemplateResponse {
121
-		try {
122
-			$flow = $this->getFlowByLoginToken();
123
-		} catch (LoginFlowV2NotFoundException $e) {
124
-			return $this->loginTokenForbiddenResponse();
125
-		}
126
-
127
-		$stateToken = $this->random->generate(
128
-			64,
129
-			ISecureRandom::CHAR_LOWER.ISecureRandom::CHAR_UPPER.ISecureRandom::CHAR_DIGITS
130
-		);
131
-		$this->session->set(self::STATE_NAME, $stateToken);
132
-
133
-		return new StandaloneTemplateResponse(
134
-			$this->appName,
135
-			'loginflowv2/authpicker',
136
-			[
137
-				'client' => $flow->getClientName(),
138
-				'instanceName' => $this->defaults->getName(),
139
-				'urlGenerator' => $this->urlGenerator,
140
-				'stateToken' => $stateToken,
141
-				'user' => $user,
142
-			],
143
-			'guest'
144
-		);
145
-	}
146
-
147
-	/**
148
-	 * @NoAdminRequired
149
-	 * @NoCSRFRequired
150
-	 * @NoSameSiteCookieRequired
151
-	 */
152
-	#[UseSession]
153
-	public function grantPage(string $stateToken): StandaloneTemplateResponse {
154
-		if (!$this->isValidStateToken($stateToken)) {
155
-			return $this->stateTokenForbiddenResponse();
156
-		}
157
-
158
-		try {
159
-			$flow = $this->getFlowByLoginToken();
160
-		} catch (LoginFlowV2NotFoundException $e) {
161
-			return $this->loginTokenForbiddenResponse();
162
-		}
163
-
164
-		/** @var IUser $user */
165
-		$user = $this->userSession->getUser();
166
-
167
-		return new StandaloneTemplateResponse(
168
-			$this->appName,
169
-			'loginflowv2/grant',
170
-			[
171
-				'userId' => $user->getUID(),
172
-				'userDisplayName' => $user->getDisplayName(),
173
-				'client' => $flow->getClientName(),
174
-				'instanceName' => $this->defaults->getName(),
175
-				'urlGenerator' => $this->urlGenerator,
176
-				'stateToken' => $stateToken,
177
-			],
178
-			'guest'
179
-		);
180
-	}
181
-
182
-	/**
183
-	 * @PublicPage
184
-	 */
185
-	public function apptokenRedirect(string $stateToken, string $user, string $password) {
186
-		if (!$this->isValidStateToken($stateToken)) {
187
-			return $this->stateTokenForbiddenResponse();
188
-		}
189
-
190
-		try {
191
-			$this->getFlowByLoginToken();
192
-		} catch (LoginFlowV2NotFoundException $e) {
193
-			return $this->loginTokenForbiddenResponse();
194
-		}
195
-
196
-		$loginToken = $this->session->get(self::TOKEN_NAME);
197
-
198
-		// Clear session variables
199
-		$this->session->remove(self::TOKEN_NAME);
200
-		$this->session->remove(self::STATE_NAME);
201
-
202
-		try {
203
-			$token = \OC::$server->get(\OC\Authentication\Token\IProvider::class)->getToken($password);
204
-			if ($token->getLoginName() !== $user) {
205
-				throw new InvalidTokenException('login name does not match');
206
-			}
207
-		} catch (InvalidTokenException $e) {
208
-			$response = new StandaloneTemplateResponse(
209
-				$this->appName,
210
-				'403',
211
-				[
212
-					'message' => $this->l10n->t('Invalid app password'),
213
-				],
214
-				'guest'
215
-			);
216
-			$response->setStatus(Http::STATUS_FORBIDDEN);
217
-			return $response;
218
-		}
219
-
220
-		$result = $this->loginFlowV2Service->flowDoneWithAppPassword($loginToken, $this->getServerPath(), $token->getLoginName(), $password);
221
-		return $this->handleFlowDone($result);
222
-	}
223
-
224
-	/**
225
-	 * @NoAdminRequired
226
-	 */
227
-	#[UseSession]
228
-	public function generateAppPassword(string $stateToken): Response {
229
-		if (!$this->isValidStateToken($stateToken)) {
230
-			return $this->stateTokenForbiddenResponse();
231
-		}
232
-
233
-		try {
234
-			$this->getFlowByLoginToken();
235
-		} catch (LoginFlowV2NotFoundException $e) {
236
-			return $this->loginTokenForbiddenResponse();
237
-		}
238
-
239
-		$loginToken = $this->session->get(self::TOKEN_NAME);
240
-
241
-		// Clear session variables
242
-		$this->session->remove(self::TOKEN_NAME);
243
-		$this->session->remove(self::STATE_NAME);
244
-		$sessionId = $this->session->getId();
245
-
246
-		$result = $this->loginFlowV2Service->flowDone($loginToken, $sessionId, $this->getServerPath(), $this->userId);
247
-		return $this->handleFlowDone($result);
248
-	}
249
-
250
-	private function handleFlowDone(bool $result): StandaloneTemplateResponse {
251
-		if ($result) {
252
-			return new StandaloneTemplateResponse(
253
-				$this->appName,
254
-				'loginflowv2/done',
255
-				[],
256
-				'guest'
257
-			);
258
-		}
259
-
260
-		$response = new StandaloneTemplateResponse(
261
-			$this->appName,
262
-			'403',
263
-			[
264
-				'message' => $this->l10n->t('Could not complete login'),
265
-			],
266
-			'guest'
267
-		);
268
-		$response->setStatus(Http::STATUS_FORBIDDEN);
269
-		return $response;
270
-	}
271
-
272
-	/**
273
-	 * @NoCSRFRequired
274
-	 * @PublicPage
275
-	 */
276
-	public function init(): JSONResponse {
277
-		// Get client user agent
278
-		$userAgent = $this->request->getHeader('USER_AGENT');
279
-
280
-		$tokens = $this->loginFlowV2Service->createTokens($userAgent);
281
-
282
-		$data = [
283
-			'poll' => [
284
-				'token' => $tokens->getPollToken(),
285
-				'endpoint' => $this->urlGenerator->linkToRouteAbsolute('core.ClientFlowLoginV2.poll')
286
-			],
287
-			'login' => $this->urlGenerator->linkToRouteAbsolute('core.ClientFlowLoginV2.landing', ['token' => $tokens->getLoginToken()]),
288
-		];
289
-
290
-		return new JSONResponse($data);
291
-	}
292
-
293
-	private function isValidStateToken(string $stateToken): bool {
294
-		$currentToken = $this->session->get(self::STATE_NAME);
295
-		if (!is_string($stateToken) || !is_string($currentToken)) {
296
-			return false;
297
-		}
298
-		return hash_equals($currentToken, $stateToken);
299
-	}
300
-
301
-	private function stateTokenForbiddenResponse(): StandaloneTemplateResponse {
302
-		$response = new StandaloneTemplateResponse(
303
-			$this->appName,
304
-			'403',
305
-			[
306
-				'message' => $this->l10n->t('State token does not match'),
307
-			],
308
-			'guest'
309
-		);
310
-		$response->setStatus(Http::STATUS_FORBIDDEN);
311
-		return $response;
312
-	}
313
-
314
-	/**
315
-	 * @return LoginFlowV2
316
-	 * @throws LoginFlowV2NotFoundException
317
-	 */
318
-	private function getFlowByLoginToken(): LoginFlowV2 {
319
-		$currentToken = $this->session->get(self::TOKEN_NAME);
320
-		if (!is_string($currentToken)) {
321
-			throw new LoginFlowV2NotFoundException('Login token not set in session');
322
-		}
323
-
324
-		return $this->loginFlowV2Service->getByLoginToken($currentToken);
325
-	}
326
-
327
-	private function loginTokenForbiddenResponse(): StandaloneTemplateResponse {
328
-		$response = new StandaloneTemplateResponse(
329
-			$this->appName,
330
-			'403',
331
-			[
332
-				'message' => $this->l10n->t('Your login token is invalid or has expired'),
333
-			],
334
-			'guest'
335
-		);
336
-		$response->setStatus(Http::STATUS_FORBIDDEN);
337
-		return $response;
338
-	}
339
-
340
-	private function getServerPath(): string {
341
-		$serverPostfix = '';
342
-
343
-		if (strpos($this->request->getRequestUri(), '/index.php') !== false) {
344
-			$serverPostfix = substr($this->request->getRequestUri(), 0, strpos($this->request->getRequestUri(), '/index.php'));
345
-		} elseif (strpos($this->request->getRequestUri(), '/login/v2') !== false) {
346
-			$serverPostfix = substr($this->request->getRequestUri(), 0, strpos($this->request->getRequestUri(), '/login/v2'));
347
-		}
348
-
349
-		$protocol = $this->request->getServerProtocol();
350
-		return $protocol . '://' . $this->request->getServerHost() . $serverPostfix;
351
-	}
51
+    public const TOKEN_NAME = 'client.flow.v2.login.token';
52
+    public const STATE_NAME = 'client.flow.v2.state.token';
53
+
54
+    private LoginFlowV2Service $loginFlowV2Service;
55
+    private IURLGenerator $urlGenerator;
56
+    private IUserSession $userSession;
57
+    private ISession $session;
58
+    private ISecureRandom $random;
59
+    private Defaults $defaults;
60
+    private ?string $userId;
61
+    private IL10N $l10n;
62
+
63
+    public function __construct(string $appName,
64
+                                IRequest $request,
65
+                                LoginFlowV2Service $loginFlowV2Service,
66
+                                IURLGenerator $urlGenerator,
67
+                                ISession $session,
68
+                                IUserSession $userSession,
69
+                                ISecureRandom $random,
70
+                                Defaults $defaults,
71
+                                ?string $userId,
72
+                                IL10N $l10n) {
73
+        parent::__construct($appName, $request);
74
+        $this->loginFlowV2Service = $loginFlowV2Service;
75
+        $this->urlGenerator = $urlGenerator;
76
+        $this->session = $session;
77
+        $this->userSession = $userSession;
78
+        $this->random = $random;
79
+        $this->defaults = $defaults;
80
+        $this->userId = $userId;
81
+        $this->l10n = $l10n;
82
+    }
83
+
84
+    /**
85
+     * @NoCSRFRequired
86
+     * @PublicPage
87
+     */
88
+    public function poll(string $token): JSONResponse {
89
+        try {
90
+            $creds = $this->loginFlowV2Service->poll($token);
91
+        } catch (LoginFlowV2NotFoundException $e) {
92
+            return new JSONResponse([], Http::STATUS_NOT_FOUND);
93
+        }
94
+
95
+        return new JSONResponse($creds);
96
+    }
97
+
98
+    /**
99
+     * @NoCSRFRequired
100
+     * @PublicPage
101
+     */
102
+    #[UseSession]
103
+    public function landing(string $token, $user = ''): Response {
104
+        if (!$this->loginFlowV2Service->startLoginFlow($token)) {
105
+            return $this->loginTokenForbiddenResponse();
106
+        }
107
+
108
+        $this->session->set(self::TOKEN_NAME, $token);
109
+
110
+        return new RedirectResponse(
111
+            $this->urlGenerator->linkToRouteAbsolute('core.ClientFlowLoginV2.showAuthPickerPage', ['user' => $user])
112
+        );
113
+    }
114
+
115
+    /**
116
+     * @NoCSRFRequired
117
+     * @PublicPage
118
+     */
119
+    #[UseSession]
120
+    public function showAuthPickerPage($user = ''): StandaloneTemplateResponse {
121
+        try {
122
+            $flow = $this->getFlowByLoginToken();
123
+        } catch (LoginFlowV2NotFoundException $e) {
124
+            return $this->loginTokenForbiddenResponse();
125
+        }
126
+
127
+        $stateToken = $this->random->generate(
128
+            64,
129
+            ISecureRandom::CHAR_LOWER.ISecureRandom::CHAR_UPPER.ISecureRandom::CHAR_DIGITS
130
+        );
131
+        $this->session->set(self::STATE_NAME, $stateToken);
132
+
133
+        return new StandaloneTemplateResponse(
134
+            $this->appName,
135
+            'loginflowv2/authpicker',
136
+            [
137
+                'client' => $flow->getClientName(),
138
+                'instanceName' => $this->defaults->getName(),
139
+                'urlGenerator' => $this->urlGenerator,
140
+                'stateToken' => $stateToken,
141
+                'user' => $user,
142
+            ],
143
+            'guest'
144
+        );
145
+    }
146
+
147
+    /**
148
+     * @NoAdminRequired
149
+     * @NoCSRFRequired
150
+     * @NoSameSiteCookieRequired
151
+     */
152
+    #[UseSession]
153
+    public function grantPage(string $stateToken): StandaloneTemplateResponse {
154
+        if (!$this->isValidStateToken($stateToken)) {
155
+            return $this->stateTokenForbiddenResponse();
156
+        }
157
+
158
+        try {
159
+            $flow = $this->getFlowByLoginToken();
160
+        } catch (LoginFlowV2NotFoundException $e) {
161
+            return $this->loginTokenForbiddenResponse();
162
+        }
163
+
164
+        /** @var IUser $user */
165
+        $user = $this->userSession->getUser();
166
+
167
+        return new StandaloneTemplateResponse(
168
+            $this->appName,
169
+            'loginflowv2/grant',
170
+            [
171
+                'userId' => $user->getUID(),
172
+                'userDisplayName' => $user->getDisplayName(),
173
+                'client' => $flow->getClientName(),
174
+                'instanceName' => $this->defaults->getName(),
175
+                'urlGenerator' => $this->urlGenerator,
176
+                'stateToken' => $stateToken,
177
+            ],
178
+            'guest'
179
+        );
180
+    }
181
+
182
+    /**
183
+     * @PublicPage
184
+     */
185
+    public function apptokenRedirect(string $stateToken, string $user, string $password) {
186
+        if (!$this->isValidStateToken($stateToken)) {
187
+            return $this->stateTokenForbiddenResponse();
188
+        }
189
+
190
+        try {
191
+            $this->getFlowByLoginToken();
192
+        } catch (LoginFlowV2NotFoundException $e) {
193
+            return $this->loginTokenForbiddenResponse();
194
+        }
195
+
196
+        $loginToken = $this->session->get(self::TOKEN_NAME);
197
+
198
+        // Clear session variables
199
+        $this->session->remove(self::TOKEN_NAME);
200
+        $this->session->remove(self::STATE_NAME);
201
+
202
+        try {
203
+            $token = \OC::$server->get(\OC\Authentication\Token\IProvider::class)->getToken($password);
204
+            if ($token->getLoginName() !== $user) {
205
+                throw new InvalidTokenException('login name does not match');
206
+            }
207
+        } catch (InvalidTokenException $e) {
208
+            $response = new StandaloneTemplateResponse(
209
+                $this->appName,
210
+                '403',
211
+                [
212
+                    'message' => $this->l10n->t('Invalid app password'),
213
+                ],
214
+                'guest'
215
+            );
216
+            $response->setStatus(Http::STATUS_FORBIDDEN);
217
+            return $response;
218
+        }
219
+
220
+        $result = $this->loginFlowV2Service->flowDoneWithAppPassword($loginToken, $this->getServerPath(), $token->getLoginName(), $password);
221
+        return $this->handleFlowDone($result);
222
+    }
223
+
224
+    /**
225
+     * @NoAdminRequired
226
+     */
227
+    #[UseSession]
228
+    public function generateAppPassword(string $stateToken): Response {
229
+        if (!$this->isValidStateToken($stateToken)) {
230
+            return $this->stateTokenForbiddenResponse();
231
+        }
232
+
233
+        try {
234
+            $this->getFlowByLoginToken();
235
+        } catch (LoginFlowV2NotFoundException $e) {
236
+            return $this->loginTokenForbiddenResponse();
237
+        }
238
+
239
+        $loginToken = $this->session->get(self::TOKEN_NAME);
240
+
241
+        // Clear session variables
242
+        $this->session->remove(self::TOKEN_NAME);
243
+        $this->session->remove(self::STATE_NAME);
244
+        $sessionId = $this->session->getId();
245
+
246
+        $result = $this->loginFlowV2Service->flowDone($loginToken, $sessionId, $this->getServerPath(), $this->userId);
247
+        return $this->handleFlowDone($result);
248
+    }
249
+
250
+    private function handleFlowDone(bool $result): StandaloneTemplateResponse {
251
+        if ($result) {
252
+            return new StandaloneTemplateResponse(
253
+                $this->appName,
254
+                'loginflowv2/done',
255
+                [],
256
+                'guest'
257
+            );
258
+        }
259
+
260
+        $response = new StandaloneTemplateResponse(
261
+            $this->appName,
262
+            '403',
263
+            [
264
+                'message' => $this->l10n->t('Could not complete login'),
265
+            ],
266
+            'guest'
267
+        );
268
+        $response->setStatus(Http::STATUS_FORBIDDEN);
269
+        return $response;
270
+    }
271
+
272
+    /**
273
+     * @NoCSRFRequired
274
+     * @PublicPage
275
+     */
276
+    public function init(): JSONResponse {
277
+        // Get client user agent
278
+        $userAgent = $this->request->getHeader('USER_AGENT');
279
+
280
+        $tokens = $this->loginFlowV2Service->createTokens($userAgent);
281
+
282
+        $data = [
283
+            'poll' => [
284
+                'token' => $tokens->getPollToken(),
285
+                'endpoint' => $this->urlGenerator->linkToRouteAbsolute('core.ClientFlowLoginV2.poll')
286
+            ],
287
+            'login' => $this->urlGenerator->linkToRouteAbsolute('core.ClientFlowLoginV2.landing', ['token' => $tokens->getLoginToken()]),
288
+        ];
289
+
290
+        return new JSONResponse($data);
291
+    }
292
+
293
+    private function isValidStateToken(string $stateToken): bool {
294
+        $currentToken = $this->session->get(self::STATE_NAME);
295
+        if (!is_string($stateToken) || !is_string($currentToken)) {
296
+            return false;
297
+        }
298
+        return hash_equals($currentToken, $stateToken);
299
+    }
300
+
301
+    private function stateTokenForbiddenResponse(): StandaloneTemplateResponse {
302
+        $response = new StandaloneTemplateResponse(
303
+            $this->appName,
304
+            '403',
305
+            [
306
+                'message' => $this->l10n->t('State token does not match'),
307
+            ],
308
+            'guest'
309
+        );
310
+        $response->setStatus(Http::STATUS_FORBIDDEN);
311
+        return $response;
312
+    }
313
+
314
+    /**
315
+     * @return LoginFlowV2
316
+     * @throws LoginFlowV2NotFoundException
317
+     */
318
+    private function getFlowByLoginToken(): LoginFlowV2 {
319
+        $currentToken = $this->session->get(self::TOKEN_NAME);
320
+        if (!is_string($currentToken)) {
321
+            throw new LoginFlowV2NotFoundException('Login token not set in session');
322
+        }
323
+
324
+        return $this->loginFlowV2Service->getByLoginToken($currentToken);
325
+    }
326
+
327
+    private function loginTokenForbiddenResponse(): StandaloneTemplateResponse {
328
+        $response = new StandaloneTemplateResponse(
329
+            $this->appName,
330
+            '403',
331
+            [
332
+                'message' => $this->l10n->t('Your login token is invalid or has expired'),
333
+            ],
334
+            'guest'
335
+        );
336
+        $response->setStatus(Http::STATUS_FORBIDDEN);
337
+        return $response;
338
+    }
339
+
340
+    private function getServerPath(): string {
341
+        $serverPostfix = '';
342
+
343
+        if (strpos($this->request->getRequestUri(), '/index.php') !== false) {
344
+            $serverPostfix = substr($this->request->getRequestUri(), 0, strpos($this->request->getRequestUri(), '/index.php'));
345
+        } elseif (strpos($this->request->getRequestUri(), '/login/v2') !== false) {
346
+            $serverPostfix = substr($this->request->getRequestUri(), 0, strpos($this->request->getRequestUri(), '/login/v2'));
347
+        }
348
+
349
+        $protocol = $this->request->getServerProtocol();
350
+        return $protocol . '://' . $this->request->getServerHost() . $serverPostfix;
351
+    }
352 352
 }
Please login to merge, or discard this patch.
core/Migrations/Version14000Date20180626223656.php 1 patch
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -28,42 +28,42 @@
 block discarded – undo
28 28
 use OCP\Migration\SimpleMigrationStep;
29 29
 
30 30
 class Version14000Date20180626223656 extends SimpleMigrationStep {
31
-	public function changeSchema(\OCP\Migration\IOutput $output, \Closure $schemaClosure, array $options) {
32
-		/** @var ISchemaWrapper $schema */
33
-		$schema = $schemaClosure();
34
-		if (!$schema->hasTable('whats_new')) {
35
-			$table = $schema->createTable('whats_new');
36
-			$table->addColumn('id', 'integer', [
37
-				'autoincrement' => true,
38
-				'notnull' => true,
39
-				'length' => 4,
40
-				'unsigned' => true,
41
-			]);
42
-			$table->addColumn('version', 'string', [
43
-				'notnull' => true,
44
-				'length' => 64,
45
-				'default' => '11',
46
-			]);
47
-			$table->addColumn('etag', 'string', [
48
-				'notnull' => true,
49
-				'length' => 64,
50
-				'default' => '',
51
-			]);
52
-			$table->addColumn('last_check', 'integer', [
53
-				'notnull' => true,
54
-				'length' => 4,
55
-				'unsigned' => true,
56
-				'default' => 0,
57
-			]);
58
-			$table->addColumn('data', 'text', [
59
-				'notnull' => true,
60
-				'default' => '',
61
-			]);
62
-			$table->setPrimaryKey(['id']);
63
-			$table->addUniqueIndex(['version'], 'version');
64
-			$table->addIndex(['version', 'etag'], 'version_etag_idx');
65
-		}
31
+    public function changeSchema(\OCP\Migration\IOutput $output, \Closure $schemaClosure, array $options) {
32
+        /** @var ISchemaWrapper $schema */
33
+        $schema = $schemaClosure();
34
+        if (!$schema->hasTable('whats_new')) {
35
+            $table = $schema->createTable('whats_new');
36
+            $table->addColumn('id', 'integer', [
37
+                'autoincrement' => true,
38
+                'notnull' => true,
39
+                'length' => 4,
40
+                'unsigned' => true,
41
+            ]);
42
+            $table->addColumn('version', 'string', [
43
+                'notnull' => true,
44
+                'length' => 64,
45
+                'default' => '11',
46
+            ]);
47
+            $table->addColumn('etag', 'string', [
48
+                'notnull' => true,
49
+                'length' => 64,
50
+                'default' => '',
51
+            ]);
52
+            $table->addColumn('last_check', 'integer', [
53
+                'notnull' => true,
54
+                'length' => 4,
55
+                'unsigned' => true,
56
+                'default' => 0,
57
+            ]);
58
+            $table->addColumn('data', 'text', [
59
+                'notnull' => true,
60
+                'default' => '',
61
+            ]);
62
+            $table->setPrimaryKey(['id']);
63
+            $table->addUniqueIndex(['version'], 'version');
64
+            $table->addIndex(['version', 'etag'], 'version_etag_idx');
65
+        }
66 66
 
67
-		return $schema;
68
-	}
67
+        return $schema;
68
+    }
69 69
 }
Please login to merge, or discard this patch.
core/Migrations/Version19000Date20200211083441.php 1 patch
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -10,36 +10,36 @@
 block discarded – undo
10 10
 use OCP\Migration\SimpleMigrationStep;
11 11
 
12 12
 class Version19000Date20200211083441 extends SimpleMigrationStep {
13
-	public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
14
-		/** @var ISchemaWrapper $schema */
15
-		$schema = $schemaClosure();
13
+    public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
14
+        /** @var ISchemaWrapper $schema */
15
+        $schema = $schemaClosure();
16 16
 
17
-		if (!$schema->hasTable('webauthn')) {
18
-			$table = $schema->createTable('webauthn');
19
-			$table->addColumn('id', 'integer', [
20
-				'autoincrement' => true,
21
-				'notnull' => true,
22
-				'length' => 64,
23
-			]);
24
-			$table->addColumn('uid', 'string', [
25
-				'notnull' => true,
26
-				'length' => 64,
27
-			]);
28
-			$table->addColumn('name', 'string', [
29
-				'notnull' => true,
30
-				'length' => 64,
31
-			]);
32
-			$table->addColumn('public_key_credential_id', 'string', [
33
-				'notnull' => true,
34
-				'length' => 255
35
-			]);
36
-			$table->addColumn('data', 'text', [
37
-				'notnull' => true,
38
-			]);
39
-			$table->setPrimaryKey(['id']);
40
-			$table->addIndex(['uid'], 'webauthn_uid');
41
-			$table->addIndex(['public_key_credential_id'], 'webauthn_publicKeyCredentialId');
42
-		}
43
-		return $schema;
44
-	}
17
+        if (!$schema->hasTable('webauthn')) {
18
+            $table = $schema->createTable('webauthn');
19
+            $table->addColumn('id', 'integer', [
20
+                'autoincrement' => true,
21
+                'notnull' => true,
22
+                'length' => 64,
23
+            ]);
24
+            $table->addColumn('uid', 'string', [
25
+                'notnull' => true,
26
+                'length' => 64,
27
+            ]);
28
+            $table->addColumn('name', 'string', [
29
+                'notnull' => true,
30
+                'length' => 64,
31
+            ]);
32
+            $table->addColumn('public_key_credential_id', 'string', [
33
+                'notnull' => true,
34
+                'length' => 255
35
+            ]);
36
+            $table->addColumn('data', 'text', [
37
+                'notnull' => true,
38
+            ]);
39
+            $table->setPrimaryKey(['id']);
40
+            $table->addIndex(['uid'], 'webauthn_uid');
41
+            $table->addIndex(['public_key_credential_id'], 'webauthn_publicKeyCredentialId');
42
+        }
43
+        return $schema;
44
+    }
45 45
 }
Please login to merge, or discard this patch.
core/Migrations/Version14000Date20180522074438.php 1 patch
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -33,31 +33,31 @@
 block discarded – undo
33 33
 use OCP\Migration\SimpleMigrationStep;
34 34
 
35 35
 class Version14000Date20180522074438 extends SimpleMigrationStep {
36
-	public function changeSchema(IOutput $output, Closure $schemaClosure,
37
-								 array $options): ISchemaWrapper {
38
-		$schema = $schemaClosure();
36
+    public function changeSchema(IOutput $output, Closure $schemaClosure,
37
+                                    array $options): ISchemaWrapper {
38
+        $schema = $schemaClosure();
39 39
 
40
-		if (!$schema->hasTable('twofactor_providers')) {
41
-			$table = $schema->createTable('twofactor_providers');
42
-			$table->addColumn('provider_id', 'string',
43
-				[
44
-					'notnull' => true,
45
-					'length' => 32,
46
-				]);
47
-			$table->addColumn('uid', 'string',
48
-				[
49
-					'notnull' => true,
50
-					'length' => 64,
51
-				]);
52
-			$table->addColumn('enabled', 'smallint',
53
-				[
54
-					'notnull' => true,
55
-					'length' => 1,
56
-				]);
57
-			$table->setPrimaryKey(['provider_id', 'uid']);
58
-			$table->addIndex(['uid'], 'twofactor_providers_uid');
59
-		}
40
+        if (!$schema->hasTable('twofactor_providers')) {
41
+            $table = $schema->createTable('twofactor_providers');
42
+            $table->addColumn('provider_id', 'string',
43
+                [
44
+                    'notnull' => true,
45
+                    'length' => 32,
46
+                ]);
47
+            $table->addColumn('uid', 'string',
48
+                [
49
+                    'notnull' => true,
50
+                    'length' => 64,
51
+                ]);
52
+            $table->addColumn('enabled', 'smallint',
53
+                [
54
+                    'notnull' => true,
55
+                    'length' => 1,
56
+                ]);
57
+            $table->setPrimaryKey(['provider_id', 'uid']);
58
+            $table->addIndex(['uid'], 'twofactor_providers_uid');
59
+        }
60 60
 
61
-		return $schema;
62
-	}
61
+        return $schema;
62
+    }
63 63
 }
Please login to merge, or discard this patch.
core/templates/403.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@
 block discarded – undo
7 7
 	require_once '../../lib/base.php';
8 8
 
9 9
 	$urlGenerator = \OC::$server->getURLGenerator();
10
-	header('Location: ' . $urlGenerator->getAbsoluteURL('/'));
10
+	header('Location: '.$urlGenerator->getAbsoluteURL('/'));
11 11
 	exit;
12 12
 }
13 13
 // @codeCoverageIgnoreEnd
Please login to merge, or discard this patch.
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,17 +1,17 @@
 block discarded – undo
1 1
 <?php
2 2
 // @codeCoverageIgnoreStart
3 3
 if (!isset($_)) {//standalone  page is not supported anymore - redirect to /
4
-	require_once '../../lib/base.php';
4
+    require_once '../../lib/base.php';
5 5
 
6
-	$urlGenerator = \OC::$server->getURLGenerator();
7
-	header('Location: ' . $urlGenerator->getAbsoluteURL('/'));
8
-	exit;
6
+    $urlGenerator = \OC::$server->getURLGenerator();
7
+    header('Location: ' . $urlGenerator->getAbsoluteURL('/'));
8
+    exit;
9 9
 }
10 10
 // @codeCoverageIgnoreEnd
11 11
 ?>
12 12
 <div class="guest-box">
13 13
 	<h2><?php p($l->t('Access forbidden')); ?></h2>
14 14
 		<p class='hint'><?php if (isset($_['message'])) {
15
-			p($_['message']);
16
-		}?></p>
15
+            p($_['message']);
16
+        }?></p>
17 17
 </ul>
Please login to merge, or discard this patch.
core/Controller/JsController.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -108,7 +108,7 @@
 block discarded – undo
108 108
 		if (strpos($encoding, 'gzip') !== false) {
109 109
 			try {
110 110
 				$gzip = true;
111
-				return $folder->getFile($fileName . '.gzip'); # Safari doesn't like .gz
111
+				return $folder->getFile($fileName.'.gzip'); # Safari doesn't like .gz
112 112
 			} catch (NotFoundException $e) {
113 113
 				// continue
114 114
 			}
Please login to merge, or discard this patch.
Indentation   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -44,71 +44,71 @@
 block discarded – undo
44 44
 use OCP\IRequest;
45 45
 
46 46
 class JsController extends Controller {
47
-	protected IAppData $appData;
48
-	protected ITimeFactory $timeFactory;
47
+    protected IAppData $appData;
48
+    protected ITimeFactory $timeFactory;
49 49
 
50
-	public function __construct($appName, IRequest $request, Factory $appDataFactory, ITimeFactory $timeFactory) {
51
-		parent::__construct($appName, $request);
50
+    public function __construct($appName, IRequest $request, Factory $appDataFactory, ITimeFactory $timeFactory) {
51
+        parent::__construct($appName, $request);
52 52
 
53
-		$this->appData = $appDataFactory->get('js');
54
-		$this->timeFactory = $timeFactory;
55
-	}
53
+        $this->appData = $appDataFactory->get('js');
54
+        $this->timeFactory = $timeFactory;
55
+    }
56 56
 
57
-	/**
58
-	 * @PublicPage
59
-	 * @NoCSRFRequired
60
-	 * @NoSameSiteCookieRequired
61
-	 *
62
-	 * @param string $fileName js filename with extension
63
-	 * @param string $appName js folder name
64
-	 * @return FileDisplayResponse|NotFoundResponse
65
-	 */
66
-	public function getJs(string $fileName, string $appName): Response {
67
-		try {
68
-			$folder = $this->appData->getFolder($appName);
69
-			$gzip = false;
70
-			$file = $this->getFile($folder, $fileName, $gzip);
71
-		} catch (NotFoundException $e) {
72
-			return new NotFoundResponse();
73
-		}
57
+    /**
58
+     * @PublicPage
59
+     * @NoCSRFRequired
60
+     * @NoSameSiteCookieRequired
61
+     *
62
+     * @param string $fileName js filename with extension
63
+     * @param string $appName js folder name
64
+     * @return FileDisplayResponse|NotFoundResponse
65
+     */
66
+    public function getJs(string $fileName, string $appName): Response {
67
+        try {
68
+            $folder = $this->appData->getFolder($appName);
69
+            $gzip = false;
70
+            $file = $this->getFile($folder, $fileName, $gzip);
71
+        } catch (NotFoundException $e) {
72
+            return new NotFoundResponse();
73
+        }
74 74
 
75
-		$response = new FileDisplayResponse($file, Http::STATUS_OK, ['Content-Type' => 'application/javascript']);
76
-		if ($gzip) {
77
-			$response->addHeader('Content-Encoding', 'gzip');
78
-		}
75
+        $response = new FileDisplayResponse($file, Http::STATUS_OK, ['Content-Type' => 'application/javascript']);
76
+        if ($gzip) {
77
+            $response->addHeader('Content-Encoding', 'gzip');
78
+        }
79 79
 
80
-		$ttl = 31536000;
81
-		$response->addHeader('Cache-Control', 'max-age='.$ttl.', immutable');
80
+        $ttl = 31536000;
81
+        $response->addHeader('Cache-Control', 'max-age='.$ttl.', immutable');
82 82
 
83
-		$expires = new \DateTime();
84
-		$expires->setTimestamp($this->timeFactory->getTime());
85
-		$expires->add(new \DateInterval('PT'.$ttl.'S'));
86
-		$response->addHeader('Expires', $expires->format(\DateTime::RFC1123));
87
-		$response->addHeader('Pragma', 'cache');
88
-		return $response;
89
-	}
83
+        $expires = new \DateTime();
84
+        $expires->setTimestamp($this->timeFactory->getTime());
85
+        $expires->add(new \DateInterval('PT'.$ttl.'S'));
86
+        $response->addHeader('Expires', $expires->format(\DateTime::RFC1123));
87
+        $response->addHeader('Pragma', 'cache');
88
+        return $response;
89
+    }
90 90
 
91
-	/**
92
-	 * @param ISimpleFolder $folder
93
-	 * @param string $fileName
94
-	 * @param bool $gzip is set to true if we use the gzip file
95
-	 * @return ISimpleFile
96
-	 *
97
-	 * @throws NotFoundException
98
-	 */
99
-	private function getFile(ISimpleFolder $folder, string $fileName, bool &$gzip): ISimpleFile {
100
-		$encoding = $this->request->getHeader('Accept-Encoding');
91
+    /**
92
+     * @param ISimpleFolder $folder
93
+     * @param string $fileName
94
+     * @param bool $gzip is set to true if we use the gzip file
95
+     * @return ISimpleFile
96
+     *
97
+     * @throws NotFoundException
98
+     */
99
+    private function getFile(ISimpleFolder $folder, string $fileName, bool &$gzip): ISimpleFile {
100
+        $encoding = $this->request->getHeader('Accept-Encoding');
101 101
 
102
-		if (strpos($encoding, 'gzip') !== false) {
103
-			try {
104
-				$gzip = true;
105
-				return $folder->getFile($fileName . '.gzip'); # Safari doesn't like .gz
106
-			} catch (NotFoundException $e) {
107
-				// continue
108
-			}
109
-		}
102
+        if (strpos($encoding, 'gzip') !== false) {
103
+            try {
104
+                $gzip = true;
105
+                return $folder->getFile($fileName . '.gzip'); # Safari doesn't like .gz
106
+            } catch (NotFoundException $e) {
107
+                // continue
108
+            }
109
+        }
110 110
 
111
-		$gzip = false;
112
-		return $folder->getFile($fileName);
113
-	}
111
+        $gzip = false;
112
+        return $folder->getFile($fileName);
113
+    }
114 114
 }
Please login to merge, or discard this patch.