@@ -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]); |
@@ -12,7 +12,7 @@ |
||
12 | 12 | \OC_JSON::checkAppEnabled('user_ldap'); |
13 | 13 | \OC_JSON::callCheck(); |
14 | 14 | |
15 | -$prefix = (string)$_POST['ldap_serverconfig_chooser']; |
|
15 | +$prefix = (string) $_POST['ldap_serverconfig_chooser']; |
|
16 | 16 | $ldapWrapper = new LDAP(); |
17 | 17 | $connection = new \OCA\User_LDAP\Connection($ldapWrapper, $prefix); |
18 | 18 | $configuration = $connection->getConfiguration(); |
@@ -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 | } |
@@ -56,7 +56,7 @@ |
||
56 | 56 | $uid = $publicKeyCredentialUserEntity->getId(); |
57 | 57 | $entities = $this->credentialMapper->findAllForUid($uid); |
58 | 58 | |
59 | - return array_map(function (PublicKeyCredentialEntity $entity) { |
|
59 | + return array_map(function(PublicKeyCredentialEntity $entity) { |
|
60 | 60 | return $entity->toPublicKeyCredentialSource(); |
61 | 61 | }, $entities); |
62 | 62 | } |
@@ -16,66 +16,66 @@ |
||
16 | 16 | use Webauthn\PublicKeyCredentialUserEntity; |
17 | 17 | |
18 | 18 | class CredentialRepository implements PublicKeyCredentialSourceRepository { |
19 | - /** @var PublicKeyCredentialMapper */ |
|
20 | - private $credentialMapper; |
|
21 | - |
|
22 | - public function __construct(PublicKeyCredentialMapper $credentialMapper) { |
|
23 | - $this->credentialMapper = $credentialMapper; |
|
24 | - } |
|
25 | - |
|
26 | - public function findOneByCredentialId(string $publicKeyCredentialId): ?PublicKeyCredentialSource { |
|
27 | - try { |
|
28 | - $entity = $this->credentialMapper->findOneByCredentialId($publicKeyCredentialId); |
|
29 | - return $entity->toPublicKeyCredentialSource(); |
|
30 | - } catch (IMapperException $e) { |
|
31 | - return null; |
|
32 | - } |
|
33 | - } |
|
34 | - |
|
35 | - /** |
|
36 | - * @return PublicKeyCredentialSource[] |
|
37 | - */ |
|
38 | - public function findAllForUserEntity(PublicKeyCredentialUserEntity $publicKeyCredentialUserEntity): array { |
|
39 | - $uid = $publicKeyCredentialUserEntity->getId(); |
|
40 | - $entities = $this->credentialMapper->findAllForUid($uid); |
|
41 | - |
|
42 | - return array_map(function (PublicKeyCredentialEntity $entity) { |
|
43 | - return $entity->toPublicKeyCredentialSource(); |
|
44 | - }, $entities); |
|
45 | - } |
|
46 | - |
|
47 | - public function saveAndReturnCredentialSource(PublicKeyCredentialSource $publicKeyCredentialSource, ?string $name = null, bool $userVerification = false): PublicKeyCredentialEntity { |
|
48 | - $oldEntity = null; |
|
49 | - |
|
50 | - try { |
|
51 | - $oldEntity = $this->credentialMapper->findOneByCredentialId($publicKeyCredentialSource->getPublicKeyCredentialId()); |
|
52 | - } catch (IMapperException $e) { |
|
53 | - } |
|
54 | - |
|
55 | - $defaultName = false; |
|
56 | - if ($name === null) { |
|
57 | - $defaultName = true; |
|
58 | - $name = 'default'; |
|
59 | - } |
|
60 | - |
|
61 | - $entity = PublicKeyCredentialEntity::fromPublicKeyCrendentialSource($name, $publicKeyCredentialSource, $userVerification); |
|
62 | - |
|
63 | - if ($oldEntity) { |
|
64 | - $entity->setId($oldEntity->getId()); |
|
65 | - if ($defaultName) { |
|
66 | - $entity->setName($oldEntity->getName()); |
|
67 | - } |
|
68 | - |
|
69 | - // Don't downgrade UV just because it was skipped during a login due to another key |
|
70 | - if ($oldEntity->getUserVerification()) { |
|
71 | - $entity->setUserVerification(true); |
|
72 | - } |
|
73 | - } |
|
74 | - |
|
75 | - return $this->credentialMapper->insertOrUpdate($entity); |
|
76 | - } |
|
77 | - |
|
78 | - public function saveCredentialSource(PublicKeyCredentialSource $publicKeyCredentialSource, ?string $name = null): void { |
|
79 | - $this->saveAndReturnCredentialSource($publicKeyCredentialSource, $name); |
|
80 | - } |
|
19 | + /** @var PublicKeyCredentialMapper */ |
|
20 | + private $credentialMapper; |
|
21 | + |
|
22 | + public function __construct(PublicKeyCredentialMapper $credentialMapper) { |
|
23 | + $this->credentialMapper = $credentialMapper; |
|
24 | + } |
|
25 | + |
|
26 | + public function findOneByCredentialId(string $publicKeyCredentialId): ?PublicKeyCredentialSource { |
|
27 | + try { |
|
28 | + $entity = $this->credentialMapper->findOneByCredentialId($publicKeyCredentialId); |
|
29 | + return $entity->toPublicKeyCredentialSource(); |
|
30 | + } catch (IMapperException $e) { |
|
31 | + return null; |
|
32 | + } |
|
33 | + } |
|
34 | + |
|
35 | + /** |
|
36 | + * @return PublicKeyCredentialSource[] |
|
37 | + */ |
|
38 | + public function findAllForUserEntity(PublicKeyCredentialUserEntity $publicKeyCredentialUserEntity): array { |
|
39 | + $uid = $publicKeyCredentialUserEntity->getId(); |
|
40 | + $entities = $this->credentialMapper->findAllForUid($uid); |
|
41 | + |
|
42 | + return array_map(function (PublicKeyCredentialEntity $entity) { |
|
43 | + return $entity->toPublicKeyCredentialSource(); |
|
44 | + }, $entities); |
|
45 | + } |
|
46 | + |
|
47 | + public function saveAndReturnCredentialSource(PublicKeyCredentialSource $publicKeyCredentialSource, ?string $name = null, bool $userVerification = false): PublicKeyCredentialEntity { |
|
48 | + $oldEntity = null; |
|
49 | + |
|
50 | + try { |
|
51 | + $oldEntity = $this->credentialMapper->findOneByCredentialId($publicKeyCredentialSource->getPublicKeyCredentialId()); |
|
52 | + } catch (IMapperException $e) { |
|
53 | + } |
|
54 | + |
|
55 | + $defaultName = false; |
|
56 | + if ($name === null) { |
|
57 | + $defaultName = true; |
|
58 | + $name = 'default'; |
|
59 | + } |
|
60 | + |
|
61 | + $entity = PublicKeyCredentialEntity::fromPublicKeyCrendentialSource($name, $publicKeyCredentialSource, $userVerification); |
|
62 | + |
|
63 | + if ($oldEntity) { |
|
64 | + $entity->setId($oldEntity->getId()); |
|
65 | + if ($defaultName) { |
|
66 | + $entity->setName($oldEntity->getName()); |
|
67 | + } |
|
68 | + |
|
69 | + // Don't downgrade UV just because it was skipped during a login due to another key |
|
70 | + if ($oldEntity->getUserVerification()) { |
|
71 | + $entity->setUserVerification(true); |
|
72 | + } |
|
73 | + } |
|
74 | + |
|
75 | + return $this->credentialMapper->insertOrUpdate($entity); |
|
76 | + } |
|
77 | + |
|
78 | + public function saveCredentialSource(PublicKeyCredentialSource $publicKeyCredentialSource, ?string $name = null): void { |
|
79 | + $this->saveAndReturnCredentialSource($publicKeyCredentialSource, $name); |
|
80 | + } |
|
81 | 81 | } |
@@ -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 | } |
@@ -77,7 +77,7 @@ |
||
77 | 77 | 'preLoginNameUsedAsUserName', |
78 | 78 | ['uid' => &$uid] |
79 | 79 | ); |
80 | - $this->logger->debug('Got UID: ' . $uid); |
|
80 | + $this->logger->debug('Got UID: '.$uid); |
|
81 | 81 | |
82 | 82 | $publicKeyCredentialRequestOptions = $this->webAuthnManger->startAuthentication($uid, $this->request->getServerHost()); |
83 | 83 | $this->session->set(self::WEBAUTHN_LOGIN, json_encode($publicKeyCredentialRequestOptions)); |
@@ -25,69 +25,69 @@ |
||
25 | 25 | use Webauthn\PublicKeyCredentialRequestOptions; |
26 | 26 | |
27 | 27 | class WebAuthnController extends Controller { |
28 | - private const WEBAUTHN_LOGIN = 'webauthn_login'; |
|
29 | - private const WEBAUTHN_LOGIN_UID = 'webauthn_login_uid'; |
|
28 | + private const WEBAUTHN_LOGIN = 'webauthn_login'; |
|
29 | + private const WEBAUTHN_LOGIN_UID = 'webauthn_login_uid'; |
|
30 | 30 | |
31 | - public function __construct( |
|
32 | - string $appName, |
|
33 | - IRequest $request, |
|
34 | - private Manager $webAuthnManger, |
|
35 | - private ISession $session, |
|
36 | - private LoggerInterface $logger, |
|
37 | - private WebAuthnChain $webAuthnChain, |
|
38 | - private URLGenerator $urlGenerator, |
|
39 | - ) { |
|
40 | - parent::__construct($appName, $request); |
|
41 | - } |
|
31 | + public function __construct( |
|
32 | + string $appName, |
|
33 | + IRequest $request, |
|
34 | + private Manager $webAuthnManger, |
|
35 | + private ISession $session, |
|
36 | + private LoggerInterface $logger, |
|
37 | + private WebAuthnChain $webAuthnChain, |
|
38 | + private URLGenerator $urlGenerator, |
|
39 | + ) { |
|
40 | + parent::__construct($appName, $request); |
|
41 | + } |
|
42 | 42 | |
43 | - #[PublicPage] |
|
44 | - #[UseSession] |
|
45 | - #[FrontpageRoute(verb: 'POST', url: 'login/webauthn/start')] |
|
46 | - public function startAuthentication(string $loginName): JSONResponse { |
|
47 | - $this->logger->debug('Starting WebAuthn login'); |
|
43 | + #[PublicPage] |
|
44 | + #[UseSession] |
|
45 | + #[FrontpageRoute(verb: 'POST', url: 'login/webauthn/start')] |
|
46 | + public function startAuthentication(string $loginName): JSONResponse { |
|
47 | + $this->logger->debug('Starting WebAuthn login'); |
|
48 | 48 | |
49 | - $this->logger->debug('Converting login name to UID'); |
|
50 | - $uid = $loginName; |
|
51 | - Util::emitHook( |
|
52 | - '\OCA\Files_Sharing\API\Server2Server', |
|
53 | - 'preLoginNameUsedAsUserName', |
|
54 | - ['uid' => &$uid] |
|
55 | - ); |
|
56 | - $this->logger->debug('Got UID: ' . $uid); |
|
49 | + $this->logger->debug('Converting login name to UID'); |
|
50 | + $uid = $loginName; |
|
51 | + Util::emitHook( |
|
52 | + '\OCA\Files_Sharing\API\Server2Server', |
|
53 | + 'preLoginNameUsedAsUserName', |
|
54 | + ['uid' => &$uid] |
|
55 | + ); |
|
56 | + $this->logger->debug('Got UID: ' . $uid); |
|
57 | 57 | |
58 | - $publicKeyCredentialRequestOptions = $this->webAuthnManger->startAuthentication($uid, $this->request->getServerHost()); |
|
59 | - $this->session->set(self::WEBAUTHN_LOGIN, json_encode($publicKeyCredentialRequestOptions)); |
|
60 | - $this->session->set(self::WEBAUTHN_LOGIN_UID, $uid); |
|
58 | + $publicKeyCredentialRequestOptions = $this->webAuthnManger->startAuthentication($uid, $this->request->getServerHost()); |
|
59 | + $this->session->set(self::WEBAUTHN_LOGIN, json_encode($publicKeyCredentialRequestOptions)); |
|
60 | + $this->session->set(self::WEBAUTHN_LOGIN_UID, $uid); |
|
61 | 61 | |
62 | - return new JSONResponse($publicKeyCredentialRequestOptions); |
|
63 | - } |
|
62 | + return new JSONResponse($publicKeyCredentialRequestOptions); |
|
63 | + } |
|
64 | 64 | |
65 | - #[PublicPage] |
|
66 | - #[UseSession] |
|
67 | - #[FrontpageRoute(verb: 'POST', url: 'login/webauthn/finish')] |
|
68 | - public function finishAuthentication(string $data): JSONResponse { |
|
69 | - $this->logger->debug('Validating WebAuthn login'); |
|
65 | + #[PublicPage] |
|
66 | + #[UseSession] |
|
67 | + #[FrontpageRoute(verb: 'POST', url: 'login/webauthn/finish')] |
|
68 | + public function finishAuthentication(string $data): JSONResponse { |
|
69 | + $this->logger->debug('Validating WebAuthn login'); |
|
70 | 70 | |
71 | - if (!$this->session->exists(self::WEBAUTHN_LOGIN) || !$this->session->exists(self::WEBAUTHN_LOGIN_UID)) { |
|
72 | - $this->logger->debug('Trying to finish WebAuthn login without session data'); |
|
73 | - return new JSONResponse([], Http::STATUS_BAD_REQUEST); |
|
74 | - } |
|
71 | + if (!$this->session->exists(self::WEBAUTHN_LOGIN) || !$this->session->exists(self::WEBAUTHN_LOGIN_UID)) { |
|
72 | + $this->logger->debug('Trying to finish WebAuthn login without session data'); |
|
73 | + return new JSONResponse([], Http::STATUS_BAD_REQUEST); |
|
74 | + } |
|
75 | 75 | |
76 | - // Obtain the publicKeyCredentialOptions from when we started the registration |
|
77 | - $publicKeyCredentialRequestOptions = PublicKeyCredentialRequestOptions::createFromString($this->session->get(self::WEBAUTHN_LOGIN)); |
|
78 | - $uid = $this->session->get(self::WEBAUTHN_LOGIN_UID); |
|
79 | - $this->webAuthnManger->finishAuthentication($publicKeyCredentialRequestOptions, $data, $uid); |
|
76 | + // Obtain the publicKeyCredentialOptions from when we started the registration |
|
77 | + $publicKeyCredentialRequestOptions = PublicKeyCredentialRequestOptions::createFromString($this->session->get(self::WEBAUTHN_LOGIN)); |
|
78 | + $uid = $this->session->get(self::WEBAUTHN_LOGIN_UID); |
|
79 | + $this->webAuthnManger->finishAuthentication($publicKeyCredentialRequestOptions, $data, $uid); |
|
80 | 80 | |
81 | - //TODO: add other parameters |
|
82 | - $loginData = new LoginData( |
|
83 | - $this->request, |
|
84 | - $uid, |
|
85 | - '' |
|
86 | - ); |
|
87 | - $this->webAuthnChain->process($loginData); |
|
81 | + //TODO: add other parameters |
|
82 | + $loginData = new LoginData( |
|
83 | + $this->request, |
|
84 | + $uid, |
|
85 | + '' |
|
86 | + ); |
|
87 | + $this->webAuthnChain->process($loginData); |
|
88 | 88 | |
89 | - return new JSONResponse([ |
|
90 | - 'defaultRedirectUrl' => $this->urlGenerator->linkToDefaultPageUrl(), |
|
91 | - ]); |
|
92 | - } |
|
89 | + return new JSONResponse([ |
|
90 | + 'defaultRedirectUrl' => $this->urlGenerator->linkToDefaultPageUrl(), |
|
91 | + ]); |
|
92 | + } |
|
93 | 93 | } |
@@ -30,7 +30,7 @@ |
||
30 | 30 | <h2><?php p($l->t('Connect to your account')) ?></h2> |
31 | 31 | <p class="info"> |
32 | 32 | <?php print_unescaped($l->t('Please log in before granting %1$s access to your %2$s account.', [ |
33 | - '<strong>' . \OCP\Util::sanitizeHTML($_['client']) . '</strong>', |
|
33 | + '<strong>'.\OCP\Util::sanitizeHTML($_['client']).'</strong>', |
|
34 | 34 | \OCP\Util::sanitizeHTML($_['instanceName']) |
35 | 35 | ])) ?> |
36 | 36 | </p> |
@@ -31,9 +31,9 @@ |
||
31 | 31 | <h2><?php p($l->t('Connect to your account')) ?></h2> |
32 | 32 | <p class="info"> |
33 | 33 | <?php print_unescaped($l->t('Please log in before granting %1$s access to your %2$s account.', [ |
34 | - '<strong>' . \OCP\Util::sanitizeHTML($_['client']) . '</strong>', |
|
35 | - \OCP\Util::sanitizeHTML($_['instanceName']) |
|
36 | - ])) ?> |
|
34 | + '<strong>' . \OCP\Util::sanitizeHTML($_['client']) . '</strong>', |
|
35 | + \OCP\Util::sanitizeHTML($_['instanceName']) |
|
36 | + ])) ?> |
|
37 | 37 | </p> |
38 | 38 | |
39 | 39 | <div class="notecard warning"> |
@@ -28,7 +28,7 @@ |
||
28 | 28 | namespace OCA\Files_Trashbin\Sabre; |
29 | 29 | |
30 | 30 | class TrashFolderFile extends AbstractTrashFile { |
31 | - public function get() { |
|
32 | - return $this->data->getStorage()->fopen($this->data->getInternalPath(), 'rb'); |
|
33 | - } |
|
31 | + public function get() { |
|
32 | + return $this->data->getStorage()->fopen($this->data->getInternalPath(), 'rb'); |
|
33 | + } |
|
34 | 34 | } |
@@ -28,11 +28,11 @@ |
||
28 | 28 | namespace OC\Authentication\Token; |
29 | 29 | |
30 | 30 | interface INamedToken extends IToken { |
31 | - /** |
|
32 | - * Set token name |
|
33 | - * |
|
34 | - * @param string $name |
|
35 | - * @return void |
|
36 | - */ |
|
37 | - public function setName(string $name): void; |
|
31 | + /** |
|
32 | + * Set token name |
|
33 | + * |
|
34 | + * @param string $name |
|
35 | + * @return void |
|
36 | + */ |
|
37 | + public function setName(string $name): void; |
|
38 | 38 | } |
@@ -143,7 +143,7 @@ |
||
143 | 143 | * @return boolean |
144 | 144 | */ |
145 | 145 | public function isActive(IUser $user): bool { |
146 | - $appIds = array_filter($this->appManager->getEnabledAppsForUser($user), function ($appId) { |
|
146 | + $appIds = array_filter($this->appManager->getEnabledAppsForUser($user), function($appId) { |
|
147 | 147 | return $appId !== $this->appName; |
148 | 148 | }); |
149 | 149 | foreach ($appIds as $appId) { |
@@ -22,120 +22,120 @@ |
||
22 | 22 | |
23 | 23 | class BackupCodesProvider implements IDeactivatableByAdmin, IProvidesPersonalSettings { |
24 | 24 | |
25 | - /** @var AppManager */ |
|
26 | - private $appManager; |
|
25 | + /** @var AppManager */ |
|
26 | + private $appManager; |
|
27 | 27 | |
28 | - /** |
|
29 | - * @param string $appName |
|
30 | - * @param BackupCodeStorage $storage |
|
31 | - * @param IL10N $l10n |
|
32 | - * @param AppManager $appManager |
|
33 | - */ |
|
34 | - public function __construct( |
|
35 | - private string $appName, |
|
36 | - private BackupCodeStorage $storage, |
|
37 | - private IL10N $l10n, |
|
38 | - AppManager $appManager, |
|
39 | - private IInitialStateService $initialStateService, |
|
40 | - private ITemplateManager $templateManager, |
|
41 | - ) { |
|
42 | - $this->appManager = $appManager; |
|
43 | - } |
|
28 | + /** |
|
29 | + * @param string $appName |
|
30 | + * @param BackupCodeStorage $storage |
|
31 | + * @param IL10N $l10n |
|
32 | + * @param AppManager $appManager |
|
33 | + */ |
|
34 | + public function __construct( |
|
35 | + private string $appName, |
|
36 | + private BackupCodeStorage $storage, |
|
37 | + private IL10N $l10n, |
|
38 | + AppManager $appManager, |
|
39 | + private IInitialStateService $initialStateService, |
|
40 | + private ITemplateManager $templateManager, |
|
41 | + ) { |
|
42 | + $this->appManager = $appManager; |
|
43 | + } |
|
44 | 44 | |
45 | - /** |
|
46 | - * Get unique identifier of this 2FA provider |
|
47 | - * |
|
48 | - * @return string |
|
49 | - */ |
|
50 | - public function getId(): string { |
|
51 | - return 'backup_codes'; |
|
52 | - } |
|
45 | + /** |
|
46 | + * Get unique identifier of this 2FA provider |
|
47 | + * |
|
48 | + * @return string |
|
49 | + */ |
|
50 | + public function getId(): string { |
|
51 | + return 'backup_codes'; |
|
52 | + } |
|
53 | 53 | |
54 | - /** |
|
55 | - * Get the display name for selecting the 2FA provider |
|
56 | - * |
|
57 | - * @return string |
|
58 | - */ |
|
59 | - public function getDisplayName(): string { |
|
60 | - return $this->l10n->t('Backup code'); |
|
61 | - } |
|
54 | + /** |
|
55 | + * Get the display name for selecting the 2FA provider |
|
56 | + * |
|
57 | + * @return string |
|
58 | + */ |
|
59 | + public function getDisplayName(): string { |
|
60 | + return $this->l10n->t('Backup code'); |
|
61 | + } |
|
62 | 62 | |
63 | - /** |
|
64 | - * Get the description for selecting the 2FA provider |
|
65 | - * |
|
66 | - * @return string |
|
67 | - */ |
|
68 | - public function getDescription(): string { |
|
69 | - return $this->l10n->t('Use backup code'); |
|
70 | - } |
|
63 | + /** |
|
64 | + * Get the description for selecting the 2FA provider |
|
65 | + * |
|
66 | + * @return string |
|
67 | + */ |
|
68 | + public function getDescription(): string { |
|
69 | + return $this->l10n->t('Use backup code'); |
|
70 | + } |
|
71 | 71 | |
72 | - /** |
|
73 | - * Get the template for rending the 2FA provider view |
|
74 | - * |
|
75 | - * @param IUser $user |
|
76 | - * @return ITemplate |
|
77 | - */ |
|
78 | - public function getTemplate(IUser $user): ITemplate { |
|
79 | - return $this->templateManager->getTemplate('twofactor_backupcodes', 'challenge'); |
|
80 | - } |
|
72 | + /** |
|
73 | + * Get the template for rending the 2FA provider view |
|
74 | + * |
|
75 | + * @param IUser $user |
|
76 | + * @return ITemplate |
|
77 | + */ |
|
78 | + public function getTemplate(IUser $user): ITemplate { |
|
79 | + return $this->templateManager->getTemplate('twofactor_backupcodes', 'challenge'); |
|
80 | + } |
|
81 | 81 | |
82 | - /** |
|
83 | - * Verify the given challenge |
|
84 | - * |
|
85 | - * @param IUser $user |
|
86 | - * @param string $challenge |
|
87 | - * @return bool |
|
88 | - */ |
|
89 | - public function verifyChallenge(IUser $user, string $challenge): bool { |
|
90 | - return $this->storage->validateCode($user, $challenge); |
|
91 | - } |
|
82 | + /** |
|
83 | + * Verify the given challenge |
|
84 | + * |
|
85 | + * @param IUser $user |
|
86 | + * @param string $challenge |
|
87 | + * @return bool |
|
88 | + */ |
|
89 | + public function verifyChallenge(IUser $user, string $challenge): bool { |
|
90 | + return $this->storage->validateCode($user, $challenge); |
|
91 | + } |
|
92 | 92 | |
93 | - /** |
|
94 | - * Decides whether 2FA is enabled for the given user |
|
95 | - * |
|
96 | - * @param IUser $user |
|
97 | - * @return boolean |
|
98 | - */ |
|
99 | - public function isTwoFactorAuthEnabledForUser(IUser $user): bool { |
|
100 | - return $this->storage->hasBackupCodes($user); |
|
101 | - } |
|
93 | + /** |
|
94 | + * Decides whether 2FA is enabled for the given user |
|
95 | + * |
|
96 | + * @param IUser $user |
|
97 | + * @return boolean |
|
98 | + */ |
|
99 | + public function isTwoFactorAuthEnabledForUser(IUser $user): bool { |
|
100 | + return $this->storage->hasBackupCodes($user); |
|
101 | + } |
|
102 | 102 | |
103 | - /** |
|
104 | - * Determine whether backup codes should be active or not |
|
105 | - * |
|
106 | - * Backup codes only make sense if at least one 2FA provider is active, |
|
107 | - * hence this method checks all enabled apps on whether they provide 2FA |
|
108 | - * functionality or not. If there's at least one app, backup codes are |
|
109 | - * enabled on the personal settings page. |
|
110 | - * |
|
111 | - * @param IUser $user |
|
112 | - * @return boolean |
|
113 | - */ |
|
114 | - public function isActive(IUser $user): bool { |
|
115 | - $appIds = array_filter($this->appManager->getEnabledAppsForUser($user), function ($appId) { |
|
116 | - return $appId !== $this->appName; |
|
117 | - }); |
|
118 | - foreach ($appIds as $appId) { |
|
119 | - $info = $this->appManager->getAppInfo($appId); |
|
120 | - if (isset($info['two-factor-providers']) && count($info['two-factor-providers']) > 0) { |
|
121 | - return true; |
|
122 | - } |
|
123 | - } |
|
124 | - return false; |
|
125 | - } |
|
103 | + /** |
|
104 | + * Determine whether backup codes should be active or not |
|
105 | + * |
|
106 | + * Backup codes only make sense if at least one 2FA provider is active, |
|
107 | + * hence this method checks all enabled apps on whether they provide 2FA |
|
108 | + * functionality or not. If there's at least one app, backup codes are |
|
109 | + * enabled on the personal settings page. |
|
110 | + * |
|
111 | + * @param IUser $user |
|
112 | + * @return boolean |
|
113 | + */ |
|
114 | + public function isActive(IUser $user): bool { |
|
115 | + $appIds = array_filter($this->appManager->getEnabledAppsForUser($user), function ($appId) { |
|
116 | + return $appId !== $this->appName; |
|
117 | + }); |
|
118 | + foreach ($appIds as $appId) { |
|
119 | + $info = $this->appManager->getAppInfo($appId); |
|
120 | + if (isset($info['two-factor-providers']) && count($info['two-factor-providers']) > 0) { |
|
121 | + return true; |
|
122 | + } |
|
123 | + } |
|
124 | + return false; |
|
125 | + } |
|
126 | 126 | |
127 | - /** |
|
128 | - * @param IUser $user |
|
129 | - * |
|
130 | - * @return IPersonalProviderSettings |
|
131 | - */ |
|
132 | - public function getPersonalSettings(IUser $user): IPersonalProviderSettings { |
|
133 | - $state = $this->storage->getBackupCodesState($user); |
|
134 | - $this->initialStateService->provideInitialState($this->appName, 'state', $state); |
|
135 | - return new Personal(); |
|
136 | - } |
|
127 | + /** |
|
128 | + * @param IUser $user |
|
129 | + * |
|
130 | + * @return IPersonalProviderSettings |
|
131 | + */ |
|
132 | + public function getPersonalSettings(IUser $user): IPersonalProviderSettings { |
|
133 | + $state = $this->storage->getBackupCodesState($user); |
|
134 | + $this->initialStateService->provideInitialState($this->appName, 'state', $state); |
|
135 | + return new Personal(); |
|
136 | + } |
|
137 | 137 | |
138 | - public function disableFor(IUser $user) { |
|
139 | - $this->storage->deleteCodes($user); |
|
140 | - } |
|
138 | + public function disableFor(IUser $user) { |
|
139 | + $this->storage->deleteCodes($user); |
|
140 | + } |
|
141 | 141 | } |