@@ -33,61 +33,61 @@ |
||
| 33 | 33 | |
| 34 | 34 | class Version010000Date20200304152605 extends SimpleMigrationStep { |
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * @param IOutput $output |
|
| 38 | - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
| 39 | - * @param array $options |
|
| 40 | - * |
|
| 41 | - * @return ISchemaWrapper |
|
| 42 | - */ |
|
| 43 | - public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ISchemaWrapper { |
|
| 44 | - /** @var ISchemaWrapper $schema */ |
|
| 45 | - $schema = $schemaClosure(); |
|
| 36 | + /** |
|
| 37 | + * @param IOutput $output |
|
| 38 | + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
| 39 | + * @param array $options |
|
| 40 | + * |
|
| 41 | + * @return ISchemaWrapper |
|
| 42 | + */ |
|
| 43 | + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ISchemaWrapper { |
|
| 44 | + /** @var ISchemaWrapper $schema */ |
|
| 45 | + $schema = $schemaClosure(); |
|
| 46 | 46 | |
| 47 | - $table = $schema->createTable(RecentContactMapper::TABLE_NAME); |
|
| 48 | - $table->addColumn('id', 'integer', [ |
|
| 49 | - 'autoincrement' => true, |
|
| 50 | - 'notnull' => true, |
|
| 51 | - 'length' => 4, |
|
| 52 | - ]); |
|
| 53 | - $table->addColumn('actor_uid', 'string', [ |
|
| 54 | - 'notnull' => true, |
|
| 55 | - 'length' => 64, |
|
| 56 | - ]); |
|
| 57 | - $table->addColumn('uid', 'string', [ |
|
| 58 | - 'notnull' => false, |
|
| 59 | - 'length' => 64, |
|
| 60 | - ]); |
|
| 61 | - $table->addColumn('email', 'string', [ |
|
| 62 | - 'notnull' => false, |
|
| 63 | - 'length' => 255, |
|
| 64 | - ]); |
|
| 65 | - $table->addColumn('federated_cloud_id', 'string', [ |
|
| 66 | - 'notnull' => false, |
|
| 67 | - 'length' => 255, |
|
| 68 | - ]); |
|
| 69 | - $table->addColumn('card', 'blob', [ |
|
| 70 | - 'notnull' => true, |
|
| 71 | - ]); |
|
| 72 | - $table->addColumn('last_contact', 'integer', [ |
|
| 73 | - 'notnull' => true, |
|
| 74 | - 'length' => 4, |
|
| 75 | - ]); |
|
| 76 | - $table->setPrimaryKey(['id']); |
|
| 77 | - // To find all recent entries |
|
| 78 | - $table->addIndex(['actor_uid'], RecentContactMapper::TABLE_NAME . '_actor_uid'); |
|
| 79 | - // To find a specific entry |
|
| 80 | - $table->addIndex(['id', 'actor_uid'], RecentContactMapper::TABLE_NAME . '_id_uid'); |
|
| 81 | - // To find all recent entries with a given UID |
|
| 82 | - $table->addIndex(['uid'], RecentContactMapper::TABLE_NAME . '_uid'); |
|
| 83 | - // To find all recent entries with a given email address |
|
| 84 | - $table->addIndex(['email'], RecentContactMapper::TABLE_NAME . '_email'); |
|
| 85 | - // To find all recent entries with a give federated cloud id |
|
| 86 | - $table->addIndex(['federated_cloud_id'], RecentContactMapper::TABLE_NAME . '_fed_id'); |
|
| 87 | - // For the cleanup |
|
| 88 | - $table->addIndex(['last_contact'], RecentContactMapper::TABLE_NAME . '_last_contact'); |
|
| 47 | + $table = $schema->createTable(RecentContactMapper::TABLE_NAME); |
|
| 48 | + $table->addColumn('id', 'integer', [ |
|
| 49 | + 'autoincrement' => true, |
|
| 50 | + 'notnull' => true, |
|
| 51 | + 'length' => 4, |
|
| 52 | + ]); |
|
| 53 | + $table->addColumn('actor_uid', 'string', [ |
|
| 54 | + 'notnull' => true, |
|
| 55 | + 'length' => 64, |
|
| 56 | + ]); |
|
| 57 | + $table->addColumn('uid', 'string', [ |
|
| 58 | + 'notnull' => false, |
|
| 59 | + 'length' => 64, |
|
| 60 | + ]); |
|
| 61 | + $table->addColumn('email', 'string', [ |
|
| 62 | + 'notnull' => false, |
|
| 63 | + 'length' => 255, |
|
| 64 | + ]); |
|
| 65 | + $table->addColumn('federated_cloud_id', 'string', [ |
|
| 66 | + 'notnull' => false, |
|
| 67 | + 'length' => 255, |
|
| 68 | + ]); |
|
| 69 | + $table->addColumn('card', 'blob', [ |
|
| 70 | + 'notnull' => true, |
|
| 71 | + ]); |
|
| 72 | + $table->addColumn('last_contact', 'integer', [ |
|
| 73 | + 'notnull' => true, |
|
| 74 | + 'length' => 4, |
|
| 75 | + ]); |
|
| 76 | + $table->setPrimaryKey(['id']); |
|
| 77 | + // To find all recent entries |
|
| 78 | + $table->addIndex(['actor_uid'], RecentContactMapper::TABLE_NAME . '_actor_uid'); |
|
| 79 | + // To find a specific entry |
|
| 80 | + $table->addIndex(['id', 'actor_uid'], RecentContactMapper::TABLE_NAME . '_id_uid'); |
|
| 81 | + // To find all recent entries with a given UID |
|
| 82 | + $table->addIndex(['uid'], RecentContactMapper::TABLE_NAME . '_uid'); |
|
| 83 | + // To find all recent entries with a given email address |
|
| 84 | + $table->addIndex(['email'], RecentContactMapper::TABLE_NAME . '_email'); |
|
| 85 | + // To find all recent entries with a give federated cloud id |
|
| 86 | + $table->addIndex(['federated_cloud_id'], RecentContactMapper::TABLE_NAME . '_fed_id'); |
|
| 87 | + // For the cleanup |
|
| 88 | + $table->addIndex(['last_contact'], RecentContactMapper::TABLE_NAME . '_last_contact'); |
|
| 89 | 89 | |
| 90 | - return $schema; |
|
| 91 | - } |
|
| 90 | + return $schema; |
|
| 91 | + } |
|
| 92 | 92 | |
| 93 | 93 | } |
@@ -75,17 +75,17 @@ |
||
| 75 | 75 | ]); |
| 76 | 76 | $table->setPrimaryKey(['id']); |
| 77 | 77 | // To find all recent entries |
| 78 | - $table->addIndex(['actor_uid'], RecentContactMapper::TABLE_NAME . '_actor_uid'); |
|
| 78 | + $table->addIndex(['actor_uid'], RecentContactMapper::TABLE_NAME.'_actor_uid'); |
|
| 79 | 79 | // To find a specific entry |
| 80 | - $table->addIndex(['id', 'actor_uid'], RecentContactMapper::TABLE_NAME . '_id_uid'); |
|
| 80 | + $table->addIndex(['id', 'actor_uid'], RecentContactMapper::TABLE_NAME.'_id_uid'); |
|
| 81 | 81 | // To find all recent entries with a given UID |
| 82 | - $table->addIndex(['uid'], RecentContactMapper::TABLE_NAME . '_uid'); |
|
| 82 | + $table->addIndex(['uid'], RecentContactMapper::TABLE_NAME.'_uid'); |
|
| 83 | 83 | // To find all recent entries with a given email address |
| 84 | - $table->addIndex(['email'], RecentContactMapper::TABLE_NAME . '_email'); |
|
| 84 | + $table->addIndex(['email'], RecentContactMapper::TABLE_NAME.'_email'); |
|
| 85 | 85 | // To find all recent entries with a give federated cloud id |
| 86 | - $table->addIndex(['federated_cloud_id'], RecentContactMapper::TABLE_NAME . '_fed_id'); |
|
| 86 | + $table->addIndex(['federated_cloud_id'], RecentContactMapper::TABLE_NAME.'_fed_id'); |
|
| 87 | 87 | // For the cleanup |
| 88 | - $table->addIndex(['last_contact'], RecentContactMapper::TABLE_NAME . '_last_contact'); |
|
| 88 | + $table->addIndex(['last_contact'], RecentContactMapper::TABLE_NAME.'_last_contact'); |
|
| 89 | 89 | |
| 90 | 90 | return $schema; |
| 91 | 91 | } |
@@ -6,5 +6,5 @@ |
||
| 6 | 6 | $baseDir = $vendorDir; |
| 7 | 7 | |
| 8 | 8 | return array( |
| 9 | - 'OCA\\ContactsInteraction\\' => array($baseDir . '/../lib'), |
|
| 9 | + 'OCA\\ContactsInteraction\\' => array($baseDir.'/../lib'), |
|
| 10 | 10 | ); |
@@ -370,18 +370,18 @@ discard block |
||
| 370 | 370 | private function findFileWithExtension($class, $ext) |
| 371 | 371 | { |
| 372 | 372 | // PSR-4 lookup |
| 373 | - $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; |
|
| 373 | + $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR).$ext; |
|
| 374 | 374 | |
| 375 | 375 | $first = $class[0]; |
| 376 | 376 | if (isset($this->prefixLengthsPsr4[$first])) { |
| 377 | 377 | $subPath = $class; |
| 378 | 378 | while (false !== $lastPos = strrpos($subPath, '\\')) { |
| 379 | 379 | $subPath = substr($subPath, 0, $lastPos); |
| 380 | - $search = $subPath . '\\'; |
|
| 380 | + $search = $subPath.'\\'; |
|
| 381 | 381 | if (isset($this->prefixDirsPsr4[$search])) { |
| 382 | - $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1); |
|
| 382 | + $pathEnd = DIRECTORY_SEPARATOR.substr($logicalPathPsr4, $lastPos + 1); |
|
| 383 | 383 | foreach ($this->prefixDirsPsr4[$search] as $dir) { |
| 384 | - if (file_exists($file = $dir . $pathEnd)) { |
|
| 384 | + if (file_exists($file = $dir.$pathEnd)) { |
|
| 385 | 385 | return $file; |
| 386 | 386 | } |
| 387 | 387 | } |
@@ -391,7 +391,7 @@ discard block |
||
| 391 | 391 | |
| 392 | 392 | // PSR-4 fallback dirs |
| 393 | 393 | foreach ($this->fallbackDirsPsr4 as $dir) { |
| 394 | - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { |
|
| 394 | + if (file_exists($file = $dir.DIRECTORY_SEPARATOR.$logicalPathPsr4)) { |
|
| 395 | 395 | return $file; |
| 396 | 396 | } |
| 397 | 397 | } |
@@ -403,14 +403,14 @@ discard block |
||
| 403 | 403 | . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); |
| 404 | 404 | } else { |
| 405 | 405 | // PEAR-like class name |
| 406 | - $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; |
|
| 406 | + $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR).$ext; |
|
| 407 | 407 | } |
| 408 | 408 | |
| 409 | 409 | if (isset($this->prefixesPsr0[$first])) { |
| 410 | 410 | foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { |
| 411 | 411 | if (0 === strpos($class, $prefix)) { |
| 412 | 412 | foreach ($dirs as $dir) { |
| 413 | - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { |
|
| 413 | + if (file_exists($file = $dir.DIRECTORY_SEPARATOR.$logicalPathPsr0)) { |
|
| 414 | 414 | return $file; |
| 415 | 415 | } |
| 416 | 416 | } |
@@ -420,7 +420,7 @@ discard block |
||
| 420 | 420 | |
| 421 | 421 | // PSR-0 fallback dirs |
| 422 | 422 | foreach ($this->fallbackDirsPsr0 as $dir) { |
| 423 | - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { |
|
| 423 | + if (file_exists($file = $dir.DIRECTORY_SEPARATOR.$logicalPathPsr0)) { |
|
| 424 | 424 | return $file; |
| 425 | 425 | } |
| 426 | 426 | } |
@@ -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"> |