@@ -20,6 +20,6 @@ |
||
20 | 20 | ); |
21 | 21 | } |
22 | 22 | |
23 | -require_once __DIR__ . '/composer/autoload_real.php'; |
|
23 | +require_once __DIR__.'/composer/autoload_real.php'; |
|
24 | 24 | |
25 | 25 | return ComposerAutoloaderInitSystemTags::getLoader(); |
@@ -20,6 +20,6 @@ |
||
20 | 20 | ); |
21 | 21 | } |
22 | 22 | |
23 | -require_once __DIR__ . '/composer/autoload_real.php'; |
|
23 | +require_once __DIR__.'/composer/autoload_real.php'; |
|
24 | 24 | |
25 | 25 | return ComposerAutoloaderInitUserStatus::getLoader(); |
@@ -32,63 +32,63 @@ |
||
32 | 32 | * @since 26.0.0 |
33 | 33 | */ |
34 | 34 | class GroupChangedEvent extends Event { |
35 | - private IGroup $group; |
|
36 | - private string $feature; |
|
37 | - /** @var mixed */ |
|
38 | - private $value; |
|
39 | - /** @var mixed */ |
|
40 | - private $oldValue; |
|
35 | + private IGroup $group; |
|
36 | + private string $feature; |
|
37 | + /** @var mixed */ |
|
38 | + private $value; |
|
39 | + /** @var mixed */ |
|
40 | + private $oldValue; |
|
41 | 41 | |
42 | - /** |
|
43 | - * @since 26.0.0 |
|
44 | - */ |
|
45 | - public function __construct(IGroup $group, |
|
46 | - string $feature, |
|
47 | - $value, |
|
48 | - $oldValue = null) { |
|
49 | - parent::__construct(); |
|
50 | - $this->group = $group; |
|
51 | - $this->feature = $feature; |
|
52 | - $this->value = $value; |
|
53 | - $this->oldValue = $oldValue; |
|
54 | - } |
|
42 | + /** |
|
43 | + * @since 26.0.0 |
|
44 | + */ |
|
45 | + public function __construct(IGroup $group, |
|
46 | + string $feature, |
|
47 | + $value, |
|
48 | + $oldValue = null) { |
|
49 | + parent::__construct(); |
|
50 | + $this->group = $group; |
|
51 | + $this->feature = $feature; |
|
52 | + $this->value = $value; |
|
53 | + $this->oldValue = $oldValue; |
|
54 | + } |
|
55 | 55 | |
56 | - /** |
|
57 | - * |
|
58 | - * @since 26.0.0 |
|
59 | - * |
|
60 | - * @return IGroup |
|
61 | - */ |
|
62 | - public function getGroup(): IGroup { |
|
63 | - return $this->group; |
|
64 | - } |
|
56 | + /** |
|
57 | + * |
|
58 | + * @since 26.0.0 |
|
59 | + * |
|
60 | + * @return IGroup |
|
61 | + */ |
|
62 | + public function getGroup(): IGroup { |
|
63 | + return $this->group; |
|
64 | + } |
|
65 | 65 | |
66 | - /** |
|
67 | - * |
|
68 | - * @since 26.0.0 |
|
69 | - * |
|
70 | - * @return string |
|
71 | - */ |
|
72 | - public function getFeature(): string { |
|
73 | - return $this->feature; |
|
74 | - } |
|
66 | + /** |
|
67 | + * |
|
68 | + * @since 26.0.0 |
|
69 | + * |
|
70 | + * @return string |
|
71 | + */ |
|
72 | + public function getFeature(): string { |
|
73 | + return $this->feature; |
|
74 | + } |
|
75 | 75 | |
76 | - /** |
|
77 | - * @since 26.0.0 |
|
78 | - * |
|
79 | - * @return mixed |
|
80 | - */ |
|
81 | - public function getValue() { |
|
82 | - return $this->value; |
|
83 | - } |
|
76 | + /** |
|
77 | + * @since 26.0.0 |
|
78 | + * |
|
79 | + * @return mixed |
|
80 | + */ |
|
81 | + public function getValue() { |
|
82 | + return $this->value; |
|
83 | + } |
|
84 | 84 | |
85 | - /** |
|
86 | - * |
|
87 | - * @since 26.0.0 |
|
88 | - * |
|
89 | - * @return mixed |
|
90 | - */ |
|
91 | - public function getOldValue() { |
|
92 | - return $this->oldValue; |
|
93 | - } |
|
85 | + /** |
|
86 | + * |
|
87 | + * @since 26.0.0 |
|
88 | + * |
|
89 | + * @return mixed |
|
90 | + */ |
|
91 | + public function getOldValue() { |
|
92 | + return $this->oldValue; |
|
93 | + } |
|
94 | 94 | } |
@@ -116,7 +116,7 @@ |
||
116 | 116 | return null; |
117 | 117 | } |
118 | 118 | |
119 | - return (int)$row['last_contact']; |
|
119 | + return (int) $row['last_contact']; |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | public function cleanUp(int $olderThan): void { |
@@ -17,99 +17,99 @@ |
||
17 | 17 | * @template-extends QBMapper<RecentContact> |
18 | 18 | */ |
19 | 19 | class RecentContactMapper extends QBMapper { |
20 | - public const TABLE_NAME = 'recent_contact'; |
|
21 | - |
|
22 | - public function __construct(IDBConnection $db) { |
|
23 | - parent::__construct($db, self::TABLE_NAME); |
|
24 | - } |
|
25 | - |
|
26 | - /** |
|
27 | - * @return RecentContact[] |
|
28 | - */ |
|
29 | - public function findAll(string $uid): array { |
|
30 | - $qb = $this->db->getQueryBuilder(); |
|
31 | - |
|
32 | - $select = $qb |
|
33 | - ->select('*') |
|
34 | - ->from($this->getTableName()) |
|
35 | - ->where($qb->expr()->eq('actor_uid', $qb->createNamedParameter($uid))); |
|
36 | - |
|
37 | - return $this->findEntities($select); |
|
38 | - } |
|
39 | - |
|
40 | - /** |
|
41 | - * @throws DoesNotExistException |
|
42 | - */ |
|
43 | - public function find(string $uid, int $id): RecentContact { |
|
44 | - $qb = $this->db->getQueryBuilder(); |
|
45 | - |
|
46 | - $select = $qb |
|
47 | - ->select('*') |
|
48 | - ->from($this->getTableName()) |
|
49 | - ->where($qb->expr()->eq('id', $qb->createNamedParameter($id, $qb::PARAM_INT))) |
|
50 | - ->andWhere($qb->expr()->eq('actor_uid', $qb->createNamedParameter($uid))); |
|
51 | - |
|
52 | - return $this->findEntity($select); |
|
53 | - } |
|
54 | - |
|
55 | - /** |
|
56 | - * @return RecentContact[] |
|
57 | - */ |
|
58 | - public function findMatch(IUser $user, |
|
59 | - ?string $uid, |
|
60 | - ?string $email, |
|
61 | - ?string $cloudId): array { |
|
62 | - $qb = $this->db->getQueryBuilder(); |
|
63 | - |
|
64 | - $additionalWheres = []; |
|
65 | - if ($uid !== null) { |
|
66 | - $additionalWheres[] = $qb->expr()->eq('uid', $qb->createNamedParameter($uid)); |
|
67 | - } |
|
68 | - if ($email !== null) { |
|
69 | - $additionalWheres[] = $qb->expr()->eq('email', $qb->createNamedParameter($email)); |
|
70 | - } |
|
71 | - if ($cloudId !== null) { |
|
72 | - $additionalWheres[] = $qb->expr()->eq('federated_cloud_id', $qb->createNamedParameter($cloudId)); |
|
73 | - } |
|
74 | - |
|
75 | - $select = $qb |
|
76 | - ->select('*') |
|
77 | - ->from($this->getTableName()) |
|
78 | - ->where($qb->expr()->eq('actor_uid', $qb->createNamedParameter($user->getUID()))); |
|
79 | - |
|
80 | - if (!empty($additionalWheres)) { |
|
81 | - $select->andWhere($select->expr()->orX(...$additionalWheres)); |
|
82 | - } |
|
83 | - return $this->findEntities($select); |
|
84 | - } |
|
85 | - |
|
86 | - public function findLastUpdatedForUserId(string $uid): ?int { |
|
87 | - $qb = $this->db->getQueryBuilder(); |
|
88 | - |
|
89 | - $select = $qb |
|
90 | - ->select('last_contact') |
|
91 | - ->from($this->getTableName()) |
|
92 | - ->where($qb->expr()->eq('actor_uid', $qb->createNamedParameter($uid))) |
|
93 | - ->orderBy('last_contact', 'DESC') |
|
94 | - ->setMaxResults(1); |
|
95 | - |
|
96 | - $cursor = $select->executeQuery(); |
|
97 | - $row = $cursor->fetch(); |
|
98 | - |
|
99 | - if ($row === false) { |
|
100 | - return null; |
|
101 | - } |
|
102 | - |
|
103 | - return (int)$row['last_contact']; |
|
104 | - } |
|
105 | - |
|
106 | - public function cleanUp(int $olderThan): void { |
|
107 | - $qb = $this->db->getQueryBuilder(); |
|
108 | - |
|
109 | - $delete = $qb |
|
110 | - ->delete($this->getTableName()) |
|
111 | - ->where($qb->expr()->lt('last_contact', $qb->createNamedParameter($olderThan))); |
|
112 | - |
|
113 | - $delete->executeStatement(); |
|
114 | - } |
|
20 | + public const TABLE_NAME = 'recent_contact'; |
|
21 | + |
|
22 | + public function __construct(IDBConnection $db) { |
|
23 | + parent::__construct($db, self::TABLE_NAME); |
|
24 | + } |
|
25 | + |
|
26 | + /** |
|
27 | + * @return RecentContact[] |
|
28 | + */ |
|
29 | + public function findAll(string $uid): array { |
|
30 | + $qb = $this->db->getQueryBuilder(); |
|
31 | + |
|
32 | + $select = $qb |
|
33 | + ->select('*') |
|
34 | + ->from($this->getTableName()) |
|
35 | + ->where($qb->expr()->eq('actor_uid', $qb->createNamedParameter($uid))); |
|
36 | + |
|
37 | + return $this->findEntities($select); |
|
38 | + } |
|
39 | + |
|
40 | + /** |
|
41 | + * @throws DoesNotExistException |
|
42 | + */ |
|
43 | + public function find(string $uid, int $id): RecentContact { |
|
44 | + $qb = $this->db->getQueryBuilder(); |
|
45 | + |
|
46 | + $select = $qb |
|
47 | + ->select('*') |
|
48 | + ->from($this->getTableName()) |
|
49 | + ->where($qb->expr()->eq('id', $qb->createNamedParameter($id, $qb::PARAM_INT))) |
|
50 | + ->andWhere($qb->expr()->eq('actor_uid', $qb->createNamedParameter($uid))); |
|
51 | + |
|
52 | + return $this->findEntity($select); |
|
53 | + } |
|
54 | + |
|
55 | + /** |
|
56 | + * @return RecentContact[] |
|
57 | + */ |
|
58 | + public function findMatch(IUser $user, |
|
59 | + ?string $uid, |
|
60 | + ?string $email, |
|
61 | + ?string $cloudId): array { |
|
62 | + $qb = $this->db->getQueryBuilder(); |
|
63 | + |
|
64 | + $additionalWheres = []; |
|
65 | + if ($uid !== null) { |
|
66 | + $additionalWheres[] = $qb->expr()->eq('uid', $qb->createNamedParameter($uid)); |
|
67 | + } |
|
68 | + if ($email !== null) { |
|
69 | + $additionalWheres[] = $qb->expr()->eq('email', $qb->createNamedParameter($email)); |
|
70 | + } |
|
71 | + if ($cloudId !== null) { |
|
72 | + $additionalWheres[] = $qb->expr()->eq('federated_cloud_id', $qb->createNamedParameter($cloudId)); |
|
73 | + } |
|
74 | + |
|
75 | + $select = $qb |
|
76 | + ->select('*') |
|
77 | + ->from($this->getTableName()) |
|
78 | + ->where($qb->expr()->eq('actor_uid', $qb->createNamedParameter($user->getUID()))); |
|
79 | + |
|
80 | + if (!empty($additionalWheres)) { |
|
81 | + $select->andWhere($select->expr()->orX(...$additionalWheres)); |
|
82 | + } |
|
83 | + return $this->findEntities($select); |
|
84 | + } |
|
85 | + |
|
86 | + public function findLastUpdatedForUserId(string $uid): ?int { |
|
87 | + $qb = $this->db->getQueryBuilder(); |
|
88 | + |
|
89 | + $select = $qb |
|
90 | + ->select('last_contact') |
|
91 | + ->from($this->getTableName()) |
|
92 | + ->where($qb->expr()->eq('actor_uid', $qb->createNamedParameter($uid))) |
|
93 | + ->orderBy('last_contact', 'DESC') |
|
94 | + ->setMaxResults(1); |
|
95 | + |
|
96 | + $cursor = $select->executeQuery(); |
|
97 | + $row = $cursor->fetch(); |
|
98 | + |
|
99 | + if ($row === false) { |
|
100 | + return null; |
|
101 | + } |
|
102 | + |
|
103 | + return (int)$row['last_contact']; |
|
104 | + } |
|
105 | + |
|
106 | + public function cleanUp(int $olderThan): void { |
|
107 | + $qb = $this->db->getQueryBuilder(); |
|
108 | + |
|
109 | + $delete = $qb |
|
110 | + ->delete($this->getTableName()) |
|
111 | + ->where($qb->expr()->lt('last_contact', $qb->createNamedParameter($olderThan))); |
|
112 | + |
|
113 | + $delete->executeStatement(); |
|
114 | + } |
|
115 | 115 | } |
@@ -28,21 +28,21 @@ |
||
28 | 28 | use OCP\EventDispatcher\Event; |
29 | 29 | |
30 | 30 | class LoginFailed extends Event { |
31 | - private string $loginName; |
|
32 | - private ?string $password; |
|
31 | + private string $loginName; |
|
32 | + private ?string $password; |
|
33 | 33 | |
34 | - public function __construct(string $loginName, ?string $password) { |
|
35 | - parent::__construct(); |
|
34 | + public function __construct(string $loginName, ?string $password) { |
|
35 | + parent::__construct(); |
|
36 | 36 | |
37 | - $this->loginName = $loginName; |
|
38 | - $this->password = $password; |
|
39 | - } |
|
37 | + $this->loginName = $loginName; |
|
38 | + $this->password = $password; |
|
39 | + } |
|
40 | 40 | |
41 | - public function getLoginName(): string { |
|
42 | - return $this->loginName; |
|
43 | - } |
|
41 | + public function getLoginName(): string { |
|
42 | + return $this->loginName; |
|
43 | + } |
|
44 | 44 | |
45 | - public function getPassword(): ?string { |
|
46 | - return $this->password; |
|
47 | - } |
|
45 | + public function getPassword(): ?string { |
|
46 | + return $this->password; |
|
47 | + } |
|
48 | 48 | } |
@@ -48,7 +48,7 @@ |
||
48 | 48 | } |
49 | 49 | |
50 | 50 | protected function run($argument): void { |
51 | - $default = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . '/audit.log'; |
|
51 | + $default = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT.'/data').'/audit.log'; |
|
52 | 52 | $this->filePath = $this->config->getAppValue('admin_audit', 'logfile', $default); |
53 | 53 | |
54 | 54 | if ($this->filePath === '') { |
@@ -13,30 +13,30 @@ |
||
13 | 13 | use OCP\Log\RotationTrait; |
14 | 14 | |
15 | 15 | class Rotate extends TimedJob { |
16 | - use RotationTrait; |
|
16 | + use RotationTrait; |
|
17 | 17 | |
18 | - public function __construct( |
|
19 | - ITimeFactory $time, |
|
20 | - private IConfig $config, |
|
21 | - ) { |
|
22 | - parent::__construct($time); |
|
18 | + public function __construct( |
|
19 | + ITimeFactory $time, |
|
20 | + private IConfig $config, |
|
21 | + ) { |
|
22 | + parent::__construct($time); |
|
23 | 23 | |
24 | - $this->setInterval(60 * 60 * 3); |
|
25 | - } |
|
24 | + $this->setInterval(60 * 60 * 3); |
|
25 | + } |
|
26 | 26 | |
27 | - protected function run($argument): void { |
|
28 | - $default = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . '/audit.log'; |
|
29 | - $this->filePath = $this->config->getAppValue('admin_audit', 'logfile', $default); |
|
27 | + protected function run($argument): void { |
|
28 | + $default = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . '/audit.log'; |
|
29 | + $this->filePath = $this->config->getAppValue('admin_audit', 'logfile', $default); |
|
30 | 30 | |
31 | - if ($this->filePath === '') { |
|
32 | - // default log file, nothing to do |
|
33 | - return; |
|
34 | - } |
|
31 | + if ($this->filePath === '') { |
|
32 | + // default log file, nothing to do |
|
33 | + return; |
|
34 | + } |
|
35 | 35 | |
36 | - $this->maxSize = $this->config->getSystemValue('log_rotate_size', 100 * 1024 * 1024); |
|
36 | + $this->maxSize = $this->config->getSystemValue('log_rotate_size', 100 * 1024 * 1024); |
|
37 | 37 | |
38 | - if ($this->shouldRotateBySize()) { |
|
39 | - $this->rotate(); |
|
40 | - } |
|
41 | - } |
|
38 | + if ($this->shouldRotateBySize()) { |
|
39 | + $this->rotate(); |
|
40 | + } |
|
41 | + } |
|
42 | 42 | } |
@@ -34,47 +34,47 @@ |
||
34 | 34 | * @since 13.0.0 |
35 | 35 | */ |
36 | 36 | interface IMigrationStep { |
37 | - /** |
|
38 | - * Human-readable name of the migration step |
|
39 | - * |
|
40 | - * @return string |
|
41 | - * @since 14.0.0 |
|
42 | - */ |
|
43 | - public function name(): string; |
|
37 | + /** |
|
38 | + * Human-readable name of the migration step |
|
39 | + * |
|
40 | + * @return string |
|
41 | + * @since 14.0.0 |
|
42 | + */ |
|
43 | + public function name(): string; |
|
44 | 44 | |
45 | - /** |
|
46 | - * Human-readable description of the migration step |
|
47 | - * |
|
48 | - * @return string |
|
49 | - * @since 14.0.0 |
|
50 | - */ |
|
51 | - public function description(): string; |
|
45 | + /** |
|
46 | + * Human-readable description of the migration step |
|
47 | + * |
|
48 | + * @return string |
|
49 | + * @since 14.0.0 |
|
50 | + */ |
|
51 | + public function description(): string; |
|
52 | 52 | |
53 | - /** |
|
54 | - * @param IOutput $output |
|
55 | - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
56 | - * @psalm-param Closure():ISchemaWrapper $schemaClosure |
|
57 | - * @param array $options |
|
58 | - * @since 13.0.0 |
|
59 | - */ |
|
60 | - public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options); |
|
53 | + /** |
|
54 | + * @param IOutput $output |
|
55 | + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
56 | + * @psalm-param Closure():ISchemaWrapper $schemaClosure |
|
57 | + * @param array $options |
|
58 | + * @since 13.0.0 |
|
59 | + */ |
|
60 | + public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options); |
|
61 | 61 | |
62 | - /** |
|
63 | - * @param IOutput $output |
|
64 | - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
65 | - * @psalm-param Closure():ISchemaWrapper $schemaClosure |
|
66 | - * @param array $options |
|
67 | - * @return null|ISchemaWrapper |
|
68 | - * @since 13.0.0 |
|
69 | - */ |
|
70 | - public function changeSchema(IOutput $output, Closure $schemaClosure, array $options); |
|
62 | + /** |
|
63 | + * @param IOutput $output |
|
64 | + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
65 | + * @psalm-param Closure():ISchemaWrapper $schemaClosure |
|
66 | + * @param array $options |
|
67 | + * @return null|ISchemaWrapper |
|
68 | + * @since 13.0.0 |
|
69 | + */ |
|
70 | + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options); |
|
71 | 71 | |
72 | - /** |
|
73 | - * @param IOutput $output |
|
74 | - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
75 | - * @psalm-param Closure():ISchemaWrapper $schemaClosure |
|
76 | - * @param array $options |
|
77 | - * @since 13.0.0 |
|
78 | - */ |
|
79 | - public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options); |
|
72 | + /** |
|
73 | + * @param IOutput $output |
|
74 | + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
75 | + * @psalm-param Closure():ISchemaWrapper $schemaClosure |
|
76 | + * @param array $options |
|
77 | + * @since 13.0.0 |
|
78 | + */ |
|
79 | + public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options); |
|
80 | 80 | } |
@@ -35,55 +35,55 @@ |
||
35 | 35 | * @since 13.0.0 |
36 | 36 | */ |
37 | 37 | abstract class SimpleMigrationStep implements IMigrationStep { |
38 | - /** |
|
39 | - * Human-readable name of the migration step |
|
40 | - * |
|
41 | - * @return string |
|
42 | - * @since 14.0.0 |
|
43 | - */ |
|
44 | - public function name(): string { |
|
45 | - return ''; |
|
46 | - } |
|
38 | + /** |
|
39 | + * Human-readable name of the migration step |
|
40 | + * |
|
41 | + * @return string |
|
42 | + * @since 14.0.0 |
|
43 | + */ |
|
44 | + public function name(): string { |
|
45 | + return ''; |
|
46 | + } |
|
47 | 47 | |
48 | - /** |
|
49 | - * Human-readable description of the migration step |
|
50 | - * |
|
51 | - * @return string |
|
52 | - * @since 14.0.0 |
|
53 | - */ |
|
54 | - public function description(): string { |
|
55 | - return ''; |
|
56 | - } |
|
48 | + /** |
|
49 | + * Human-readable description of the migration step |
|
50 | + * |
|
51 | + * @return string |
|
52 | + * @since 14.0.0 |
|
53 | + */ |
|
54 | + public function description(): string { |
|
55 | + return ''; |
|
56 | + } |
|
57 | 57 | |
58 | - /** |
|
59 | - * @param IOutput $output |
|
60 | - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
61 | - * @psalm-param Closure():ISchemaWrapper $schemaClosure |
|
62 | - * @param array $options |
|
63 | - * @since 13.0.0 |
|
64 | - */ |
|
65 | - public function preSchemaChange(IOutput $output, \Closure $schemaClosure, array $options) { |
|
66 | - } |
|
58 | + /** |
|
59 | + * @param IOutput $output |
|
60 | + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
61 | + * @psalm-param Closure():ISchemaWrapper $schemaClosure |
|
62 | + * @param array $options |
|
63 | + * @since 13.0.0 |
|
64 | + */ |
|
65 | + public function preSchemaChange(IOutput $output, \Closure $schemaClosure, array $options) { |
|
66 | + } |
|
67 | 67 | |
68 | - /** |
|
69 | - * @param IOutput $output |
|
70 | - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
71 | - * @psalm-param Closure():ISchemaWrapper $schemaClosure |
|
72 | - * @param array $options |
|
73 | - * @return null|ISchemaWrapper |
|
74 | - * @since 13.0.0 |
|
75 | - */ |
|
76 | - public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) { |
|
77 | - return null; |
|
78 | - } |
|
68 | + /** |
|
69 | + * @param IOutput $output |
|
70 | + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
71 | + * @psalm-param Closure():ISchemaWrapper $schemaClosure |
|
72 | + * @param array $options |
|
73 | + * @return null|ISchemaWrapper |
|
74 | + * @since 13.0.0 |
|
75 | + */ |
|
76 | + public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) { |
|
77 | + return null; |
|
78 | + } |
|
79 | 79 | |
80 | - /** |
|
81 | - * @param IOutput $output |
|
82 | - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
83 | - * @psalm-param Closure():ISchemaWrapper $schemaClosure |
|
84 | - * @param array $options |
|
85 | - * @since 13.0.0 |
|
86 | - */ |
|
87 | - public function postSchemaChange(IOutput $output, \Closure $schemaClosure, array $options) { |
|
88 | - } |
|
80 | + /** |
|
81 | + * @param IOutput $output |
|
82 | + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
83 | + * @psalm-param Closure():ISchemaWrapper $schemaClosure |
|
84 | + * @param array $options |
|
85 | + * @since 13.0.0 |
|
86 | + */ |
|
87 | + public function postSchemaChange(IOutput $output, \Closure $schemaClosure, array $options) { |
|
88 | + } |
|
89 | 89 | } |
@@ -62,7 +62,7 @@ |
||
62 | 62 | |
63 | 63 | $controllerClassPath = explode('\\', get_class($controller)); |
64 | 64 | $controllerShortClass = end($controllerClassPath); |
65 | - $bruteforceProtectionAction = $controllerShortClass . '::' . $methodName; |
|
65 | + $bruteforceProtectionAction = $controllerShortClass.'::'.$methodName; |
|
66 | 66 | $this->throttler->sleepDelayOrThrowOnMax($this->request->getRemoteAddress(), $bruteforceProtectionAction); |
67 | 67 | |
68 | 68 | if (!$this->isLinkSharingEnabled()) { |
@@ -20,107 +20,107 @@ |
||
20 | 20 | |
21 | 21 | class PublicShareMiddleware extends Middleware { |
22 | 22 | |
23 | - public function __construct( |
|
24 | - private IRequest $request, |
|
25 | - private ISession $session, |
|
26 | - private IConfig $config, |
|
27 | - private IThrottler $throttler, |
|
28 | - ) { |
|
29 | - } |
|
30 | - |
|
31 | - public function beforeController($controller, $methodName) { |
|
32 | - if (!($controller instanceof PublicShareController)) { |
|
33 | - return; |
|
34 | - } |
|
35 | - |
|
36 | - $controllerClassPath = explode('\\', get_class($controller)); |
|
37 | - $controllerShortClass = end($controllerClassPath); |
|
38 | - $bruteforceProtectionAction = $controllerShortClass . '::' . $methodName; |
|
39 | - $this->throttler->sleepDelayOrThrowOnMax($this->request->getRemoteAddress(), $bruteforceProtectionAction); |
|
40 | - |
|
41 | - if (!$this->isLinkSharingEnabled()) { |
|
42 | - throw new NotFoundException('Link sharing is disabled'); |
|
43 | - } |
|
44 | - |
|
45 | - // We require the token parameter to be set |
|
46 | - $token = $this->request->getParam('token'); |
|
47 | - if ($token === null) { |
|
48 | - throw new NotFoundException(); |
|
49 | - } |
|
50 | - |
|
51 | - // Set the token |
|
52 | - $controller->setToken($token); |
|
53 | - |
|
54 | - if (!$controller->isValidToken()) { |
|
55 | - $this->throttle($bruteforceProtectionAction, $token); |
|
56 | - |
|
57 | - $controller->shareNotFound(); |
|
58 | - throw new NotFoundException(); |
|
59 | - } |
|
60 | - |
|
61 | - // No need to check for authentication when we try to authenticate |
|
62 | - if ($methodName === 'authenticate' || $methodName === 'showAuthenticate') { |
|
63 | - return; |
|
64 | - } |
|
65 | - |
|
66 | - // If authentication succeeds just continue |
|
67 | - if ($controller->isAuthenticated()) { |
|
68 | - return; |
|
69 | - } |
|
70 | - |
|
71 | - // If we can authenticate to this controller do it else we throw a 404 to not leak any info |
|
72 | - if ($controller instanceof AuthPublicShareController) { |
|
73 | - $this->session->set('public_link_authenticate_redirect', json_encode($this->request->getParams())); |
|
74 | - throw new NeedAuthenticationException(); |
|
75 | - } |
|
76 | - |
|
77 | - $this->throttle($bruteforceProtectionAction, $token); |
|
78 | - throw new NotFoundException(); |
|
79 | - } |
|
80 | - |
|
81 | - public function afterException($controller, $methodName, \Exception $exception) { |
|
82 | - if (!($controller instanceof PublicShareController)) { |
|
83 | - throw $exception; |
|
84 | - } |
|
85 | - |
|
86 | - if ($exception instanceof NotFoundException) { |
|
87 | - return new TemplateResponse(Application::APP_ID, 'sharenotfound', [ |
|
88 | - 'message' => $exception->getMessage(), |
|
89 | - ], 'guest', Http::STATUS_NOT_FOUND); |
|
90 | - } |
|
91 | - |
|
92 | - if ($controller instanceof AuthPublicShareController && $exception instanceof NeedAuthenticationException) { |
|
93 | - return $controller->getAuthenticationRedirect($this->getFunctionForRoute($this->request->getParam('_route'))); |
|
94 | - } |
|
95 | - |
|
96 | - throw $exception; |
|
97 | - } |
|
98 | - |
|
99 | - private function getFunctionForRoute(string $route): string { |
|
100 | - $tmp = explode('.', $route); |
|
101 | - return array_pop($tmp); |
|
102 | - } |
|
103 | - |
|
104 | - /** |
|
105 | - * Check if link sharing is allowed |
|
106 | - */ |
|
107 | - private function isLinkSharingEnabled(): bool { |
|
108 | - // Check if the shareAPI is enabled |
|
109 | - if ($this->config->getAppValue('core', 'shareapi_enabled', 'yes') !== 'yes') { |
|
110 | - return false; |
|
111 | - } |
|
112 | - |
|
113 | - // Check whether public sharing is enabled |
|
114 | - if ($this->config->getAppValue('core', 'shareapi_allow_links', 'yes') !== 'yes') { |
|
115 | - return false; |
|
116 | - } |
|
117 | - |
|
118 | - return true; |
|
119 | - } |
|
120 | - |
|
121 | - private function throttle($bruteforceProtectionAction, $token): void { |
|
122 | - $ip = $this->request->getRemoteAddress(); |
|
123 | - $this->throttler->sleepDelayOrThrowOnMax($ip, $bruteforceProtectionAction); |
|
124 | - $this->throttler->registerAttempt($bruteforceProtectionAction, $ip, ['token' => $token]); |
|
125 | - } |
|
23 | + public function __construct( |
|
24 | + private IRequest $request, |
|
25 | + private ISession $session, |
|
26 | + private IConfig $config, |
|
27 | + private IThrottler $throttler, |
|
28 | + ) { |
|
29 | + } |
|
30 | + |
|
31 | + public function beforeController($controller, $methodName) { |
|
32 | + if (!($controller instanceof PublicShareController)) { |
|
33 | + return; |
|
34 | + } |
|
35 | + |
|
36 | + $controllerClassPath = explode('\\', get_class($controller)); |
|
37 | + $controllerShortClass = end($controllerClassPath); |
|
38 | + $bruteforceProtectionAction = $controllerShortClass . '::' . $methodName; |
|
39 | + $this->throttler->sleepDelayOrThrowOnMax($this->request->getRemoteAddress(), $bruteforceProtectionAction); |
|
40 | + |
|
41 | + if (!$this->isLinkSharingEnabled()) { |
|
42 | + throw new NotFoundException('Link sharing is disabled'); |
|
43 | + } |
|
44 | + |
|
45 | + // We require the token parameter to be set |
|
46 | + $token = $this->request->getParam('token'); |
|
47 | + if ($token === null) { |
|
48 | + throw new NotFoundException(); |
|
49 | + } |
|
50 | + |
|
51 | + // Set the token |
|
52 | + $controller->setToken($token); |
|
53 | + |
|
54 | + if (!$controller->isValidToken()) { |
|
55 | + $this->throttle($bruteforceProtectionAction, $token); |
|
56 | + |
|
57 | + $controller->shareNotFound(); |
|
58 | + throw new NotFoundException(); |
|
59 | + } |
|
60 | + |
|
61 | + // No need to check for authentication when we try to authenticate |
|
62 | + if ($methodName === 'authenticate' || $methodName === 'showAuthenticate') { |
|
63 | + return; |
|
64 | + } |
|
65 | + |
|
66 | + // If authentication succeeds just continue |
|
67 | + if ($controller->isAuthenticated()) { |
|
68 | + return; |
|
69 | + } |
|
70 | + |
|
71 | + // If we can authenticate to this controller do it else we throw a 404 to not leak any info |
|
72 | + if ($controller instanceof AuthPublicShareController) { |
|
73 | + $this->session->set('public_link_authenticate_redirect', json_encode($this->request->getParams())); |
|
74 | + throw new NeedAuthenticationException(); |
|
75 | + } |
|
76 | + |
|
77 | + $this->throttle($bruteforceProtectionAction, $token); |
|
78 | + throw new NotFoundException(); |
|
79 | + } |
|
80 | + |
|
81 | + public function afterException($controller, $methodName, \Exception $exception) { |
|
82 | + if (!($controller instanceof PublicShareController)) { |
|
83 | + throw $exception; |
|
84 | + } |
|
85 | + |
|
86 | + if ($exception instanceof NotFoundException) { |
|
87 | + return new TemplateResponse(Application::APP_ID, 'sharenotfound', [ |
|
88 | + 'message' => $exception->getMessage(), |
|
89 | + ], 'guest', Http::STATUS_NOT_FOUND); |
|
90 | + } |
|
91 | + |
|
92 | + if ($controller instanceof AuthPublicShareController && $exception instanceof NeedAuthenticationException) { |
|
93 | + return $controller->getAuthenticationRedirect($this->getFunctionForRoute($this->request->getParam('_route'))); |
|
94 | + } |
|
95 | + |
|
96 | + throw $exception; |
|
97 | + } |
|
98 | + |
|
99 | + private function getFunctionForRoute(string $route): string { |
|
100 | + $tmp = explode('.', $route); |
|
101 | + return array_pop($tmp); |
|
102 | + } |
|
103 | + |
|
104 | + /** |
|
105 | + * Check if link sharing is allowed |
|
106 | + */ |
|
107 | + private function isLinkSharingEnabled(): bool { |
|
108 | + // Check if the shareAPI is enabled |
|
109 | + if ($this->config->getAppValue('core', 'shareapi_enabled', 'yes') !== 'yes') { |
|
110 | + return false; |
|
111 | + } |
|
112 | + |
|
113 | + // Check whether public sharing is enabled |
|
114 | + if ($this->config->getAppValue('core', 'shareapi_allow_links', 'yes') !== 'yes') { |
|
115 | + return false; |
|
116 | + } |
|
117 | + |
|
118 | + return true; |
|
119 | + } |
|
120 | + |
|
121 | + private function throttle($bruteforceProtectionAction, $token): void { |
|
122 | + $ip = $this->request->getRemoteAddress(); |
|
123 | + $this->throttler->sleepDelayOrThrowOnMax($ip, $bruteforceProtectionAction); |
|
124 | + $this->throttler->registerAttempt($bruteforceProtectionAction, $ip, ['token' => $token]); |
|
125 | + } |
|
126 | 126 | } |