@@ -28,15 +28,15 @@ |
||
28 | 28 | $route = isset($_GET['download']) ? 'files_sharing.sharecontroller.downloadShare' : 'files_sharing.sharecontroller.showShare'; |
29 | 29 | |
30 | 30 | if ($token !== '') { |
31 | - $protocol = \OC::$server->getRequest()->getHttpProtocol(); |
|
32 | - if ($protocol == 'HTTP/1.0') { |
|
33 | - http_response_code(302); |
|
34 | - } else { |
|
35 | - http_response_code(307); |
|
36 | - } |
|
37 | - header('Location: ' . $urlGenerator->linkToRoute($route, ['token' => $token])); |
|
31 | + $protocol = \OC::$server->getRequest()->getHttpProtocol(); |
|
32 | + if ($protocol == 'HTTP/1.0') { |
|
33 | + http_response_code(302); |
|
34 | + } else { |
|
35 | + http_response_code(307); |
|
36 | + } |
|
37 | + header('Location: ' . $urlGenerator->linkToRoute($route, ['token' => $token])); |
|
38 | 38 | } else { |
39 | - http_response_code(404); |
|
40 | - $tmpl = new OCP\Template('', '404', 'guest'); |
|
41 | - print_unescaped($tmpl->fetchPage()); |
|
39 | + http_response_code(404); |
|
40 | + $tmpl = new OCP\Template('', '404', 'guest'); |
|
41 | + print_unescaped($tmpl->fetchPage()); |
|
42 | 42 | } |
@@ -35,7 +35,7 @@ |
||
35 | 35 | $connection = new \OCA\User_LDAP\Connection($ldapWrapper, $prefix); |
36 | 36 | $configuration = $connection->getConfiguration(); |
37 | 37 | if (isset($configuration['ldap_agent_password']) && $configuration['ldap_agent_password'] !== '') { |
38 | - // hide password |
|
39 | - $configuration['ldap_agent_password'] = '**PASSWORD SET**'; |
|
38 | + // hide password |
|
39 | + $configuration['ldap_agent_password'] = '**PASSWORD SET**'; |
|
40 | 40 | } |
41 | 41 | \OC_JSON::success(['configuration' => $configuration]); |
@@ -29,40 +29,40 @@ |
||
29 | 29 | * @deprecated 18.0.0 |
30 | 30 | */ |
31 | 31 | class TemplateManager { |
32 | - protected $templates = []; |
|
32 | + protected $templates = []; |
|
33 | 33 | |
34 | - public function registerTemplate($mimetype, $path) { |
|
35 | - $this->templates[$mimetype] = $path; |
|
36 | - } |
|
34 | + public function registerTemplate($mimetype, $path) { |
|
35 | + $this->templates[$mimetype] = $path; |
|
36 | + } |
|
37 | 37 | |
38 | - /** |
|
39 | - * get the path of the template for a mimetype |
|
40 | - * |
|
41 | - * @deprecated 18.0.0 |
|
42 | - * @param string $mimetype |
|
43 | - * @return string|null |
|
44 | - */ |
|
45 | - public function getTemplatePath($mimetype) { |
|
46 | - if (isset($this->templates[$mimetype])) { |
|
47 | - return $this->templates[$mimetype]; |
|
48 | - } else { |
|
49 | - return null; |
|
50 | - } |
|
51 | - } |
|
38 | + /** |
|
39 | + * get the path of the template for a mimetype |
|
40 | + * |
|
41 | + * @deprecated 18.0.0 |
|
42 | + * @param string $mimetype |
|
43 | + * @return string|null |
|
44 | + */ |
|
45 | + public function getTemplatePath($mimetype) { |
|
46 | + if (isset($this->templates[$mimetype])) { |
|
47 | + return $this->templates[$mimetype]; |
|
48 | + } else { |
|
49 | + return null; |
|
50 | + } |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * get the template content for a mimetype |
|
55 | - * |
|
56 | - * @deprecated 18.0.0 |
|
57 | - * @param string $mimetype |
|
58 | - * @return string |
|
59 | - */ |
|
60 | - public function getTemplate($mimetype) { |
|
61 | - $path = $this->getTemplatePath($mimetype); |
|
62 | - if ($path) { |
|
63 | - return file_get_contents($path); |
|
64 | - } else { |
|
65 | - return ''; |
|
66 | - } |
|
67 | - } |
|
53 | + /** |
|
54 | + * get the template content for a mimetype |
|
55 | + * |
|
56 | + * @deprecated 18.0.0 |
|
57 | + * @param string $mimetype |
|
58 | + * @return string |
|
59 | + */ |
|
60 | + public function getTemplate($mimetype) { |
|
61 | + $path = $this->getTemplatePath($mimetype); |
|
62 | + if ($path) { |
|
63 | + return file_get_contents($path); |
|
64 | + } else { |
|
65 | + return ''; |
|
66 | + } |
|
67 | + } |
|
68 | 68 | } |
@@ -26,14 +26,14 @@ discard block |
||
26 | 26 | use OC\DB\ConnectionFactory; |
27 | 27 | |
28 | 28 | class Sqlite extends AbstractDatabase { |
29 | - public $dbprettyname = 'Sqlite'; |
|
29 | + public $dbprettyname = 'Sqlite'; |
|
30 | 30 | |
31 | - public function validate($config) { |
|
32 | - return []; |
|
33 | - } |
|
31 | + public function validate($config) { |
|
32 | + return []; |
|
33 | + } |
|
34 | 34 | |
35 | - public function initialize($config) { |
|
36 | - /* |
|
35 | + public function initialize($config) { |
|
36 | + /* |
|
37 | 37 | * Web: When using web based installer its not possible to set dbname |
38 | 38 | * or dbtableprefix. Defaults used from ConnectionFactory and dbtype = 'sqlite' |
39 | 39 | * is written to config.php. |
@@ -44,32 +44,32 @@ discard block |
||
44 | 44 | * in connection factory configuration is obtained from config.php. |
45 | 45 | */ |
46 | 46 | |
47 | - $this->dbName = empty($config['dbname']) |
|
48 | - ? ConnectionFactory::DEFAULT_DBNAME |
|
49 | - : $config['dbname']; |
|
47 | + $this->dbName = empty($config['dbname']) |
|
48 | + ? ConnectionFactory::DEFAULT_DBNAME |
|
49 | + : $config['dbname']; |
|
50 | 50 | |
51 | - $this->tablePrefix = empty($config['dbtableprefix']) |
|
52 | - ? ConnectionFactory::DEFAULT_DBTABLEPREFIX |
|
53 | - : $config['dbtableprefix']; |
|
51 | + $this->tablePrefix = empty($config['dbtableprefix']) |
|
52 | + ? ConnectionFactory::DEFAULT_DBTABLEPREFIX |
|
53 | + : $config['dbtableprefix']; |
|
54 | 54 | |
55 | - if ($this->dbName !== ConnectionFactory::DEFAULT_DBNAME) { |
|
56 | - $this->config->setValue('dbname', $this->dbName); |
|
57 | - } |
|
55 | + if ($this->dbName !== ConnectionFactory::DEFAULT_DBNAME) { |
|
56 | + $this->config->setValue('dbname', $this->dbName); |
|
57 | + } |
|
58 | 58 | |
59 | - if ($this->tablePrefix !== ConnectionFactory::DEFAULT_DBTABLEPREFIX) { |
|
60 | - $this->config->setValue('dbtableprefix', $this->tablePrefix); |
|
61 | - } |
|
62 | - } |
|
59 | + if ($this->tablePrefix !== ConnectionFactory::DEFAULT_DBTABLEPREFIX) { |
|
60 | + $this->config->setValue('dbtableprefix', $this->tablePrefix); |
|
61 | + } |
|
62 | + } |
|
63 | 63 | |
64 | - public function setupDatabase($username) { |
|
65 | - $datadir = $this->config->getValue( |
|
66 | - 'datadirectory', |
|
67 | - \OC::$SERVERROOT . '/data' |
|
68 | - ); |
|
64 | + public function setupDatabase($username) { |
|
65 | + $datadir = $this->config->getValue( |
|
66 | + 'datadirectory', |
|
67 | + \OC::$SERVERROOT . '/data' |
|
68 | + ); |
|
69 | 69 | |
70 | - $sqliteFile = $datadir . '/' . $this->dbName . 'db'; |
|
71 | - if (file_exists($sqliteFile)) { |
|
72 | - unlink($sqliteFile); |
|
73 | - } |
|
74 | - } |
|
70 | + $sqliteFile = $datadir . '/' . $this->dbName . 'db'; |
|
71 | + if (file_exists($sqliteFile)) { |
|
72 | + unlink($sqliteFile); |
|
73 | + } |
|
74 | + } |
|
75 | 75 | } |
@@ -33,48 +33,48 @@ |
||
33 | 33 | |
34 | 34 | class WebAuthn implements ISettings { |
35 | 35 | |
36 | - /** @var PublicKeyCredentialMapper */ |
|
37 | - private $mapper; |
|
36 | + /** @var PublicKeyCredentialMapper */ |
|
37 | + private $mapper; |
|
38 | 38 | |
39 | - /** @var string */ |
|
40 | - private $uid; |
|
39 | + /** @var string */ |
|
40 | + private $uid; |
|
41 | 41 | |
42 | - /** @var IInitialStateService */ |
|
43 | - private $initialStateService; |
|
42 | + /** @var IInitialStateService */ |
|
43 | + private $initialStateService; |
|
44 | 44 | |
45 | - /** @var Manager */ |
|
46 | - private $manager; |
|
45 | + /** @var Manager */ |
|
46 | + private $manager; |
|
47 | 47 | |
48 | - public function __construct(PublicKeyCredentialMapper $mapper, |
|
49 | - string $UserId, |
|
50 | - IInitialStateService $initialStateService, |
|
51 | - Manager $manager) { |
|
52 | - $this->mapper = $mapper; |
|
53 | - $this->uid = $UserId; |
|
54 | - $this->initialStateService = $initialStateService; |
|
55 | - $this->manager = $manager; |
|
56 | - } |
|
48 | + public function __construct(PublicKeyCredentialMapper $mapper, |
|
49 | + string $UserId, |
|
50 | + IInitialStateService $initialStateService, |
|
51 | + Manager $manager) { |
|
52 | + $this->mapper = $mapper; |
|
53 | + $this->uid = $UserId; |
|
54 | + $this->initialStateService = $initialStateService; |
|
55 | + $this->manager = $manager; |
|
56 | + } |
|
57 | 57 | |
58 | - public function getForm() { |
|
59 | - $this->initialStateService->provideInitialState( |
|
60 | - Application::APP_ID, |
|
61 | - 'webauthn-devices', |
|
62 | - $this->mapper->findAllForUid($this->uid) |
|
63 | - ); |
|
58 | + public function getForm() { |
|
59 | + $this->initialStateService->provideInitialState( |
|
60 | + Application::APP_ID, |
|
61 | + 'webauthn-devices', |
|
62 | + $this->mapper->findAllForUid($this->uid) |
|
63 | + ); |
|
64 | 64 | |
65 | - return new TemplateResponse('settings', 'settings/personal/security/webauthn', [ |
|
66 | - ]); |
|
67 | - } |
|
65 | + return new TemplateResponse('settings', 'settings/personal/security/webauthn', [ |
|
66 | + ]); |
|
67 | + } |
|
68 | 68 | |
69 | - public function getSection(): ?string { |
|
70 | - if (!$this->manager->isWebAuthnAvailable()) { |
|
71 | - return null; |
|
72 | - } |
|
69 | + public function getSection(): ?string { |
|
70 | + if (!$this->manager->isWebAuthnAvailable()) { |
|
71 | + return null; |
|
72 | + } |
|
73 | 73 | |
74 | - return 'security'; |
|
75 | - } |
|
74 | + return 'security'; |
|
75 | + } |
|
76 | 76 | |
77 | - public function getPriority(): int { |
|
78 | - return 20; |
|
79 | - } |
|
77 | + public function getPriority(): int { |
|
78 | + return 20; |
|
79 | + } |
|
80 | 80 | } |
@@ -25,72 +25,72 @@ |
||
25 | 25 | namespace OC\Authentication\Login; |
26 | 26 | |
27 | 27 | class WebAuthnChain { |
28 | - /** @var UserDisabledCheckCommand */ |
|
29 | - private $userDisabledCheckCommand; |
|
28 | + /** @var UserDisabledCheckCommand */ |
|
29 | + private $userDisabledCheckCommand; |
|
30 | 30 | |
31 | - /** @var LoggedInCheckCommand */ |
|
32 | - private $loggedInCheckCommand; |
|
31 | + /** @var LoggedInCheckCommand */ |
|
32 | + private $loggedInCheckCommand; |
|
33 | 33 | |
34 | - /** @var CompleteLoginCommand */ |
|
35 | - private $completeLoginCommand; |
|
34 | + /** @var CompleteLoginCommand */ |
|
35 | + private $completeLoginCommand; |
|
36 | 36 | |
37 | - /** @var CreateSessionTokenCommand */ |
|
38 | - private $createSessionTokenCommand; |
|
37 | + /** @var CreateSessionTokenCommand */ |
|
38 | + private $createSessionTokenCommand; |
|
39 | 39 | |
40 | - /** @var ClearLostPasswordTokensCommand */ |
|
41 | - private $clearLostPasswordTokensCommand; |
|
40 | + /** @var ClearLostPasswordTokensCommand */ |
|
41 | + private $clearLostPasswordTokensCommand; |
|
42 | 42 | |
43 | - /** @var UpdateLastPasswordConfirmCommand */ |
|
44 | - private $updateLastPasswordConfirmCommand; |
|
43 | + /** @var UpdateLastPasswordConfirmCommand */ |
|
44 | + private $updateLastPasswordConfirmCommand; |
|
45 | 45 | |
46 | - /** @var SetUserTimezoneCommand */ |
|
47 | - private $setUserTimezoneCommand; |
|
46 | + /** @var SetUserTimezoneCommand */ |
|
47 | + private $setUserTimezoneCommand; |
|
48 | 48 | |
49 | - /** @var TwoFactorCommand */ |
|
50 | - private $twoFactorCommand; |
|
49 | + /** @var TwoFactorCommand */ |
|
50 | + private $twoFactorCommand; |
|
51 | 51 | |
52 | - /** @var FinishRememberedLoginCommand */ |
|
53 | - private $finishRememberedLoginCommand; |
|
52 | + /** @var FinishRememberedLoginCommand */ |
|
53 | + private $finishRememberedLoginCommand; |
|
54 | 54 | |
55 | - /** @var WebAuthnLoginCommand */ |
|
56 | - private $webAuthnLoginCommand; |
|
55 | + /** @var WebAuthnLoginCommand */ |
|
56 | + private $webAuthnLoginCommand; |
|
57 | 57 | |
58 | - public function __construct(UserDisabledCheckCommand $userDisabledCheckCommand, |
|
59 | - WebAuthnLoginCommand $webAuthnLoginCommand, |
|
60 | - LoggedInCheckCommand $loggedInCheckCommand, |
|
61 | - CompleteLoginCommand $completeLoginCommand, |
|
62 | - CreateSessionTokenCommand $createSessionTokenCommand, |
|
63 | - ClearLostPasswordTokensCommand $clearLostPasswordTokensCommand, |
|
64 | - UpdateLastPasswordConfirmCommand $updateLastPasswordConfirmCommand, |
|
65 | - SetUserTimezoneCommand $setUserTimezoneCommand, |
|
66 | - TwoFactorCommand $twoFactorCommand, |
|
67 | - FinishRememberedLoginCommand $finishRememberedLoginCommand |
|
68 | - ) { |
|
69 | - $this->userDisabledCheckCommand = $userDisabledCheckCommand; |
|
70 | - $this->webAuthnLoginCommand = $webAuthnLoginCommand; |
|
71 | - $this->loggedInCheckCommand = $loggedInCheckCommand; |
|
72 | - $this->completeLoginCommand = $completeLoginCommand; |
|
73 | - $this->createSessionTokenCommand = $createSessionTokenCommand; |
|
74 | - $this->clearLostPasswordTokensCommand = $clearLostPasswordTokensCommand; |
|
75 | - $this->updateLastPasswordConfirmCommand = $updateLastPasswordConfirmCommand; |
|
76 | - $this->setUserTimezoneCommand = $setUserTimezoneCommand; |
|
77 | - $this->twoFactorCommand = $twoFactorCommand; |
|
78 | - $this->finishRememberedLoginCommand = $finishRememberedLoginCommand; |
|
79 | - } |
|
58 | + public function __construct(UserDisabledCheckCommand $userDisabledCheckCommand, |
|
59 | + WebAuthnLoginCommand $webAuthnLoginCommand, |
|
60 | + LoggedInCheckCommand $loggedInCheckCommand, |
|
61 | + CompleteLoginCommand $completeLoginCommand, |
|
62 | + CreateSessionTokenCommand $createSessionTokenCommand, |
|
63 | + ClearLostPasswordTokensCommand $clearLostPasswordTokensCommand, |
|
64 | + UpdateLastPasswordConfirmCommand $updateLastPasswordConfirmCommand, |
|
65 | + SetUserTimezoneCommand $setUserTimezoneCommand, |
|
66 | + TwoFactorCommand $twoFactorCommand, |
|
67 | + FinishRememberedLoginCommand $finishRememberedLoginCommand |
|
68 | + ) { |
|
69 | + $this->userDisabledCheckCommand = $userDisabledCheckCommand; |
|
70 | + $this->webAuthnLoginCommand = $webAuthnLoginCommand; |
|
71 | + $this->loggedInCheckCommand = $loggedInCheckCommand; |
|
72 | + $this->completeLoginCommand = $completeLoginCommand; |
|
73 | + $this->createSessionTokenCommand = $createSessionTokenCommand; |
|
74 | + $this->clearLostPasswordTokensCommand = $clearLostPasswordTokensCommand; |
|
75 | + $this->updateLastPasswordConfirmCommand = $updateLastPasswordConfirmCommand; |
|
76 | + $this->setUserTimezoneCommand = $setUserTimezoneCommand; |
|
77 | + $this->twoFactorCommand = $twoFactorCommand; |
|
78 | + $this->finishRememberedLoginCommand = $finishRememberedLoginCommand; |
|
79 | + } |
|
80 | 80 | |
81 | - public function process(LoginData $loginData): LoginResult { |
|
82 | - $chain = $this->userDisabledCheckCommand; |
|
83 | - $chain |
|
84 | - ->setNext($this->webAuthnLoginCommand) |
|
85 | - ->setNext($this->loggedInCheckCommand) |
|
86 | - ->setNext($this->completeLoginCommand) |
|
87 | - ->setNext($this->createSessionTokenCommand) |
|
88 | - ->setNext($this->clearLostPasswordTokensCommand) |
|
89 | - ->setNext($this->updateLastPasswordConfirmCommand) |
|
90 | - ->setNext($this->setUserTimezoneCommand) |
|
91 | - ->setNext($this->twoFactorCommand) |
|
92 | - ->setNext($this->finishRememberedLoginCommand); |
|
81 | + public function process(LoginData $loginData): LoginResult { |
|
82 | + $chain = $this->userDisabledCheckCommand; |
|
83 | + $chain |
|
84 | + ->setNext($this->webAuthnLoginCommand) |
|
85 | + ->setNext($this->loggedInCheckCommand) |
|
86 | + ->setNext($this->completeLoginCommand) |
|
87 | + ->setNext($this->createSessionTokenCommand) |
|
88 | + ->setNext($this->clearLostPasswordTokensCommand) |
|
89 | + ->setNext($this->updateLastPasswordConfirmCommand) |
|
90 | + ->setNext($this->setUserTimezoneCommand) |
|
91 | + ->setNext($this->twoFactorCommand) |
|
92 | + ->setNext($this->finishRememberedLoginCommand); |
|
93 | 93 | |
94 | - return $chain->process($loginData); |
|
95 | - } |
|
94 | + return $chain->process($loginData); |
|
95 | + } |
|
96 | 96 | } |
@@ -31,43 +31,43 @@ |
||
31 | 31 | */ |
32 | 32 | interface IAddressBookProvider { |
33 | 33 | |
34 | - /** |
|
35 | - * Provides the appId of the plugin |
|
36 | - * |
|
37 | - * @since 19.0.0 |
|
38 | - * @return string AppId |
|
39 | - */ |
|
40 | - public function getAppId(): string; |
|
34 | + /** |
|
35 | + * Provides the appId of the plugin |
|
36 | + * |
|
37 | + * @since 19.0.0 |
|
38 | + * @return string AppId |
|
39 | + */ |
|
40 | + public function getAppId(): string; |
|
41 | 41 | |
42 | - /** |
|
43 | - * Fetches all address books for a given principal uri |
|
44 | - * |
|
45 | - * @since 19.0.0 |
|
46 | - * @param string $principalUri E.g. principals/users/user1 |
|
47 | - * @return ExternalAddressBook[] Array of all address books |
|
48 | - */ |
|
49 | - public function fetchAllForAddressBookHome(string $principalUri): array; |
|
42 | + /** |
|
43 | + * Fetches all address books for a given principal uri |
|
44 | + * |
|
45 | + * @since 19.0.0 |
|
46 | + * @param string $principalUri E.g. principals/users/user1 |
|
47 | + * @return ExternalAddressBook[] Array of all address books |
|
48 | + */ |
|
49 | + public function fetchAllForAddressBookHome(string $principalUri): array; |
|
50 | 50 | |
51 | - /** |
|
52 | - * Checks whether plugin has an address book for a given principalUri and URI |
|
53 | - * |
|
54 | - * @since 19.0.0 |
|
55 | - * @param string $principalUri E.g. principals/users/user1 |
|
56 | - * @param string $uri E.g. personal |
|
57 | - * @return bool True if address book for principalUri and URI exists, false otherwise |
|
58 | - */ |
|
59 | - public function hasAddressBookInAddressBookHome(string $principalUri, string $uri): bool; |
|
51 | + /** |
|
52 | + * Checks whether plugin has an address book for a given principalUri and URI |
|
53 | + * |
|
54 | + * @since 19.0.0 |
|
55 | + * @param string $principalUri E.g. principals/users/user1 |
|
56 | + * @param string $uri E.g. personal |
|
57 | + * @return bool True if address book for principalUri and URI exists, false otherwise |
|
58 | + */ |
|
59 | + public function hasAddressBookInAddressBookHome(string $principalUri, string $uri): bool; |
|
60 | 60 | |
61 | - /** |
|
62 | - * Fetches an address book for a given principalUri and URI |
|
63 | - * Returns null if address book does not exist |
|
64 | - * |
|
65 | - * @param string $principalUri E.g. principals/users/user1 |
|
66 | - * @param string $uri E.g. personal |
|
67 | - * |
|
68 | - * @return ExternalAddressBook|null address book if it exists, null otherwise |
|
69 | - *@since 19.0.0 |
|
70 | - */ |
|
71 | - public function getAddressBookInAddressBookHome(string $principalUri, string $uri): ?ExternalAddressBook; |
|
61 | + /** |
|
62 | + * Fetches an address book for a given principalUri and URI |
|
63 | + * Returns null if address book does not exist |
|
64 | + * |
|
65 | + * @param string $principalUri E.g. principals/users/user1 |
|
66 | + * @param string $uri E.g. personal |
|
67 | + * |
|
68 | + * @return ExternalAddressBook|null address book if it exists, null otherwise |
|
69 | + *@since 19.0.0 |
|
70 | + */ |
|
71 | + public function getAddressBookInAddressBookHome(string $principalUri, string $uri): ?ExternalAddressBook; |
|
72 | 72 | |
73 | 73 | } |
@@ -37,77 +37,77 @@ |
||
37 | 37 | |
38 | 38 | class SecurityProvider implements IProvider { |
39 | 39 | |
40 | - /** @var L10nFactory */ |
|
41 | - private $l10n; |
|
40 | + /** @var L10nFactory */ |
|
41 | + private $l10n; |
|
42 | 42 | |
43 | - /** @var IURLGenerator */ |
|
44 | - private $urlGenerator; |
|
43 | + /** @var IURLGenerator */ |
|
44 | + private $urlGenerator; |
|
45 | 45 | |
46 | - /** @var IManager */ |
|
47 | - private $activityManager; |
|
46 | + /** @var IManager */ |
|
47 | + private $activityManager; |
|
48 | 48 | |
49 | - public function __construct(L10nFactory $l10n, IURLGenerator $urlGenerator, IManager $activityManager) { |
|
50 | - $this->urlGenerator = $urlGenerator; |
|
51 | - $this->l10n = $l10n; |
|
52 | - $this->activityManager = $activityManager; |
|
53 | - } |
|
49 | + public function __construct(L10nFactory $l10n, IURLGenerator $urlGenerator, IManager $activityManager) { |
|
50 | + $this->urlGenerator = $urlGenerator; |
|
51 | + $this->l10n = $l10n; |
|
52 | + $this->activityManager = $activityManager; |
|
53 | + } |
|
54 | 54 | |
55 | - public function parse($language, IEvent $event, IEvent $previousEvent = null) { |
|
56 | - if ($event->getType() !== 'security') { |
|
57 | - throw new InvalidArgumentException(); |
|
58 | - } |
|
55 | + public function parse($language, IEvent $event, IEvent $previousEvent = null) { |
|
56 | + if ($event->getType() !== 'security') { |
|
57 | + throw new InvalidArgumentException(); |
|
58 | + } |
|
59 | 59 | |
60 | - $l = $this->l10n->get('settings', $language); |
|
60 | + $l = $this->l10n->get('settings', $language); |
|
61 | 61 | |
62 | - switch ($event->getSubject()) { |
|
63 | - case 'twofactor_success': |
|
64 | - $params = $event->getSubjectParameters(); |
|
65 | - $event->setParsedSubject($l->t('You successfully logged in using two-factor authentication (%1$s)', [ |
|
66 | - $params['provider'], |
|
67 | - ])); |
|
68 | - if ($this->activityManager->getRequirePNG()) { |
|
69 | - $event->setIcon($this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'actions/password.png'))); |
|
70 | - } else { |
|
71 | - $event->setIcon($this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'actions/password.svg'))); |
|
72 | - } |
|
73 | - break; |
|
74 | - case 'twofactor_failed': |
|
75 | - $params = $event->getSubjectParameters(); |
|
76 | - $event->setParsedSubject($l->t('A login attempt using two-factor authentication failed (%1$s)', [ |
|
77 | - $params['provider'], |
|
78 | - ])); |
|
79 | - if ($this->activityManager->getRequirePNG()) { |
|
80 | - $event->setIcon($this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'actions/password.png'))); |
|
81 | - } else { |
|
82 | - $event->setIcon($this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'actions/password.svg'))); |
|
83 | - } |
|
84 | - break; |
|
85 | - case 'remote_wipe_start': |
|
86 | - $params = $event->getSubjectParameters(); |
|
87 | - $event->setParsedSubject($l->t('Remote wipe was started on %1$s', [ |
|
88 | - $params['name'], |
|
89 | - ])); |
|
90 | - if ($this->activityManager->getRequirePNG()) { |
|
91 | - $event->setIcon($this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'actions/delete.png'))); |
|
92 | - } else { |
|
93 | - $event->setIcon($this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'actions/delete.svg'))); |
|
94 | - } |
|
95 | - break; |
|
96 | - case 'remote_wipe_finish': |
|
97 | - $params = $event->getSubjectParameters(); |
|
98 | - $event->setParsedSubject($l->t('Remote wipe has finished on %1$s', [ |
|
99 | - $params['name'], |
|
100 | - ])); |
|
101 | - if ($this->activityManager->getRequirePNG()) { |
|
102 | - $event->setIcon($this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'actions/delete.png'))); |
|
103 | - } else { |
|
104 | - $event->setIcon($this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'actions/delete.svg'))); |
|
105 | - } |
|
106 | - break; |
|
107 | - default: |
|
108 | - throw new InvalidArgumentException(); |
|
109 | - } |
|
110 | - return $event; |
|
111 | - } |
|
62 | + switch ($event->getSubject()) { |
|
63 | + case 'twofactor_success': |
|
64 | + $params = $event->getSubjectParameters(); |
|
65 | + $event->setParsedSubject($l->t('You successfully logged in using two-factor authentication (%1$s)', [ |
|
66 | + $params['provider'], |
|
67 | + ])); |
|
68 | + if ($this->activityManager->getRequirePNG()) { |
|
69 | + $event->setIcon($this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'actions/password.png'))); |
|
70 | + } else { |
|
71 | + $event->setIcon($this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'actions/password.svg'))); |
|
72 | + } |
|
73 | + break; |
|
74 | + case 'twofactor_failed': |
|
75 | + $params = $event->getSubjectParameters(); |
|
76 | + $event->setParsedSubject($l->t('A login attempt using two-factor authentication failed (%1$s)', [ |
|
77 | + $params['provider'], |
|
78 | + ])); |
|
79 | + if ($this->activityManager->getRequirePNG()) { |
|
80 | + $event->setIcon($this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'actions/password.png'))); |
|
81 | + } else { |
|
82 | + $event->setIcon($this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'actions/password.svg'))); |
|
83 | + } |
|
84 | + break; |
|
85 | + case 'remote_wipe_start': |
|
86 | + $params = $event->getSubjectParameters(); |
|
87 | + $event->setParsedSubject($l->t('Remote wipe was started on %1$s', [ |
|
88 | + $params['name'], |
|
89 | + ])); |
|
90 | + if ($this->activityManager->getRequirePNG()) { |
|
91 | + $event->setIcon($this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'actions/delete.png'))); |
|
92 | + } else { |
|
93 | + $event->setIcon($this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'actions/delete.svg'))); |
|
94 | + } |
|
95 | + break; |
|
96 | + case 'remote_wipe_finish': |
|
97 | + $params = $event->getSubjectParameters(); |
|
98 | + $event->setParsedSubject($l->t('Remote wipe has finished on %1$s', [ |
|
99 | + $params['name'], |
|
100 | + ])); |
|
101 | + if ($this->activityManager->getRequirePNG()) { |
|
102 | + $event->setIcon($this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'actions/delete.png'))); |
|
103 | + } else { |
|
104 | + $event->setIcon($this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'actions/delete.svg'))); |
|
105 | + } |
|
106 | + break; |
|
107 | + default: |
|
108 | + throw new InvalidArgumentException(); |
|
109 | + } |
|
110 | + return $event; |
|
111 | + } |
|
112 | 112 | |
113 | 113 | } |
@@ -38,84 +38,84 @@ |
||
38 | 38 | use OCP\IUserSession; |
39 | 39 | |
40 | 40 | class AjaxController extends Controller { |
41 | - /** @var RSA */ |
|
42 | - private $rsaMechanism; |
|
43 | - /** @var GlobalAuth */ |
|
44 | - private $globalAuth; |
|
45 | - /** @var IUserSession */ |
|
46 | - private $userSession; |
|
47 | - /** @var IGroupManager */ |
|
48 | - private $groupManager; |
|
41 | + /** @var RSA */ |
|
42 | + private $rsaMechanism; |
|
43 | + /** @var GlobalAuth */ |
|
44 | + private $globalAuth; |
|
45 | + /** @var IUserSession */ |
|
46 | + private $userSession; |
|
47 | + /** @var IGroupManager */ |
|
48 | + private $groupManager; |
|
49 | 49 | |
50 | - /** |
|
51 | - * @param string $appName |
|
52 | - * @param IRequest $request |
|
53 | - * @param RSA $rsaMechanism |
|
54 | - * @param GlobalAuth $globalAuth |
|
55 | - * @param IUserSession $userSession |
|
56 | - * @param IGroupManager $groupManager |
|
57 | - */ |
|
58 | - public function __construct($appName, |
|
59 | - IRequest $request, |
|
60 | - RSA $rsaMechanism, |
|
61 | - GlobalAuth $globalAuth, |
|
62 | - IUserSession $userSession, |
|
63 | - IGroupManager $groupManager) { |
|
64 | - parent::__construct($appName, $request); |
|
65 | - $this->rsaMechanism = $rsaMechanism; |
|
66 | - $this->globalAuth = $globalAuth; |
|
67 | - $this->userSession = $userSession; |
|
68 | - $this->groupManager = $groupManager; |
|
69 | - } |
|
50 | + /** |
|
51 | + * @param string $appName |
|
52 | + * @param IRequest $request |
|
53 | + * @param RSA $rsaMechanism |
|
54 | + * @param GlobalAuth $globalAuth |
|
55 | + * @param IUserSession $userSession |
|
56 | + * @param IGroupManager $groupManager |
|
57 | + */ |
|
58 | + public function __construct($appName, |
|
59 | + IRequest $request, |
|
60 | + RSA $rsaMechanism, |
|
61 | + GlobalAuth $globalAuth, |
|
62 | + IUserSession $userSession, |
|
63 | + IGroupManager $groupManager) { |
|
64 | + parent::__construct($appName, $request); |
|
65 | + $this->rsaMechanism = $rsaMechanism; |
|
66 | + $this->globalAuth = $globalAuth; |
|
67 | + $this->userSession = $userSession; |
|
68 | + $this->groupManager = $groupManager; |
|
69 | + } |
|
70 | 70 | |
71 | - /** |
|
72 | - * @param int $keyLength |
|
73 | - * @return array |
|
74 | - */ |
|
75 | - private function generateSshKeys($keyLength) { |
|
76 | - $key = $this->rsaMechanism->createKey($keyLength); |
|
77 | - // Replace the placeholder label with a more meaningful one |
|
78 | - $key['publickey'] = str_replace('phpseclib-generated-key', gethostname(), $key['publickey']); |
|
71 | + /** |
|
72 | + * @param int $keyLength |
|
73 | + * @return array |
|
74 | + */ |
|
75 | + private function generateSshKeys($keyLength) { |
|
76 | + $key = $this->rsaMechanism->createKey($keyLength); |
|
77 | + // Replace the placeholder label with a more meaningful one |
|
78 | + $key['publickey'] = str_replace('phpseclib-generated-key', gethostname(), $key['publickey']); |
|
79 | 79 | |
80 | - return $key; |
|
81 | - } |
|
80 | + return $key; |
|
81 | + } |
|
82 | 82 | |
83 | - /** |
|
84 | - * Generates an SSH public/private key pair. |
|
85 | - * |
|
86 | - * @NoAdminRequired |
|
87 | - * @param int $keyLength |
|
88 | - */ |
|
89 | - public function getSshKeys($keyLength = 1024) { |
|
90 | - $key = $this->generateSshKeys($keyLength); |
|
91 | - return new JSONResponse( |
|
92 | - ['data' => [ |
|
93 | - 'private_key' => $key['privatekey'], |
|
94 | - 'public_key' => $key['publickey'] |
|
95 | - ], |
|
96 | - 'status' => 'success' |
|
97 | - ]); |
|
98 | - } |
|
83 | + /** |
|
84 | + * Generates an SSH public/private key pair. |
|
85 | + * |
|
86 | + * @NoAdminRequired |
|
87 | + * @param int $keyLength |
|
88 | + */ |
|
89 | + public function getSshKeys($keyLength = 1024) { |
|
90 | + $key = $this->generateSshKeys($keyLength); |
|
91 | + return new JSONResponse( |
|
92 | + ['data' => [ |
|
93 | + 'private_key' => $key['privatekey'], |
|
94 | + 'public_key' => $key['publickey'] |
|
95 | + ], |
|
96 | + 'status' => 'success' |
|
97 | + ]); |
|
98 | + } |
|
99 | 99 | |
100 | - /** |
|
101 | - * @NoAdminRequired |
|
102 | - * |
|
103 | - * @param string $uid |
|
104 | - * @param string $user |
|
105 | - * @param string $password |
|
106 | - * @return bool |
|
107 | - */ |
|
108 | - public function saveGlobalCredentials($uid, $user, $password) { |
|
109 | - $currentUser = $this->userSession->getUser(); |
|
100 | + /** |
|
101 | + * @NoAdminRequired |
|
102 | + * |
|
103 | + * @param string $uid |
|
104 | + * @param string $user |
|
105 | + * @param string $password |
|
106 | + * @return bool |
|
107 | + */ |
|
108 | + public function saveGlobalCredentials($uid, $user, $password) { |
|
109 | + $currentUser = $this->userSession->getUser(); |
|
110 | 110 | |
111 | - // Non-admins can only edit their own credentials |
|
112 | - $allowedToEdit = ($this->groupManager->isAdmin($currentUser->getUID()) || $currentUser->getUID() === $uid); |
|
111 | + // Non-admins can only edit their own credentials |
|
112 | + $allowedToEdit = ($this->groupManager->isAdmin($currentUser->getUID()) || $currentUser->getUID() === $uid); |
|
113 | 113 | |
114 | - if ($allowedToEdit) { |
|
115 | - $this->globalAuth->saveAuth($uid, $user, $password); |
|
116 | - return true; |
|
117 | - } else { |
|
118 | - return false; |
|
119 | - } |
|
120 | - } |
|
114 | + if ($allowedToEdit) { |
|
115 | + $this->globalAuth->saveAuth($uid, $user, $password); |
|
116 | + return true; |
|
117 | + } else { |
|
118 | + return false; |
|
119 | + } |
|
120 | + } |
|
121 | 121 | } |