@@ -38,52 +38,52 @@ |
||
38 | 38 | */ |
39 | 39 | class UserProvided extends AuthMechanism implements IUserProvided { |
40 | 40 | |
41 | - const CREDENTIALS_IDENTIFIER_PREFIX = 'password::userprovided/'; |
|
41 | + const CREDENTIALS_IDENTIFIER_PREFIX = 'password::userprovided/'; |
|
42 | 42 | |
43 | - /** @var ICredentialsManager */ |
|
44 | - protected $credentialsManager; |
|
43 | + /** @var ICredentialsManager */ |
|
44 | + protected $credentialsManager; |
|
45 | 45 | |
46 | - public function __construct(IL10N $l, ICredentialsManager $credentialsManager) { |
|
47 | - $this->credentialsManager = $credentialsManager; |
|
46 | + public function __construct(IL10N $l, ICredentialsManager $credentialsManager) { |
|
47 | + $this->credentialsManager = $credentialsManager; |
|
48 | 48 | |
49 | - $this |
|
50 | - ->setIdentifier('password::userprovided') |
|
51 | - ->setVisibility(BackendService::VISIBILITY_ADMIN) |
|
52 | - ->setScheme(self::SCHEME_PASSWORD) |
|
53 | - ->setText($l->t('User entered, store in database')) |
|
54 | - ->addParameters([ |
|
55 | - (new DefinitionParameter('user', $l->t('Username'))) |
|
56 | - ->setFlag(DefinitionParameter::FLAG_USER_PROVIDED), |
|
57 | - (new DefinitionParameter('password', $l->t('Password'))) |
|
58 | - ->setType(DefinitionParameter::VALUE_PASSWORD) |
|
59 | - ->setFlag(DefinitionParameter::FLAG_USER_PROVIDED), |
|
60 | - ]); |
|
61 | - } |
|
49 | + $this |
|
50 | + ->setIdentifier('password::userprovided') |
|
51 | + ->setVisibility(BackendService::VISIBILITY_ADMIN) |
|
52 | + ->setScheme(self::SCHEME_PASSWORD) |
|
53 | + ->setText($l->t('User entered, store in database')) |
|
54 | + ->addParameters([ |
|
55 | + (new DefinitionParameter('user', $l->t('Username'))) |
|
56 | + ->setFlag(DefinitionParameter::FLAG_USER_PROVIDED), |
|
57 | + (new DefinitionParameter('password', $l->t('Password'))) |
|
58 | + ->setType(DefinitionParameter::VALUE_PASSWORD) |
|
59 | + ->setFlag(DefinitionParameter::FLAG_USER_PROVIDED), |
|
60 | + ]); |
|
61 | + } |
|
62 | 62 | |
63 | - private function getCredentialsIdentifier($storageId) { |
|
64 | - return self::CREDENTIALS_IDENTIFIER_PREFIX . $storageId; |
|
65 | - } |
|
63 | + private function getCredentialsIdentifier($storageId) { |
|
64 | + return self::CREDENTIALS_IDENTIFIER_PREFIX . $storageId; |
|
65 | + } |
|
66 | 66 | |
67 | - public function saveBackendOptions(IUser $user, $id, array $options) { |
|
68 | - $this->credentialsManager->store($user->getUID(), $this->getCredentialsIdentifier($id), [ |
|
69 | - 'user' => $options['user'], // explicitly copy the fields we want instead of just passing the entire $options array |
|
70 | - 'password' => $options['password'] // this way we prevent users from being able to modify any other field |
|
71 | - ]); |
|
72 | - } |
|
67 | + public function saveBackendOptions(IUser $user, $id, array $options) { |
|
68 | + $this->credentialsManager->store($user->getUID(), $this->getCredentialsIdentifier($id), [ |
|
69 | + 'user' => $options['user'], // explicitly copy the fields we want instead of just passing the entire $options array |
|
70 | + 'password' => $options['password'] // this way we prevent users from being able to modify any other field |
|
71 | + ]); |
|
72 | + } |
|
73 | 73 | |
74 | - public function manipulateStorageConfig(StorageConfig &$storage, IUser $user = null) { |
|
75 | - if (!isset($user)) { |
|
76 | - throw new InsufficientDataForMeaningfulAnswerException('No credentials saved'); |
|
77 | - } |
|
78 | - $uid = $user->getUID(); |
|
79 | - $credentials = $this->credentialsManager->retrieve($uid, $this->getCredentialsIdentifier($storage->getId())); |
|
74 | + public function manipulateStorageConfig(StorageConfig &$storage, IUser $user = null) { |
|
75 | + if (!isset($user)) { |
|
76 | + throw new InsufficientDataForMeaningfulAnswerException('No credentials saved'); |
|
77 | + } |
|
78 | + $uid = $user->getUID(); |
|
79 | + $credentials = $this->credentialsManager->retrieve($uid, $this->getCredentialsIdentifier($storage->getId())); |
|
80 | 80 | |
81 | - if (!isset($credentials)) { |
|
82 | - throw new InsufficientDataForMeaningfulAnswerException('No credentials saved'); |
|
83 | - } |
|
81 | + if (!isset($credentials)) { |
|
82 | + throw new InsufficientDataForMeaningfulAnswerException('No credentials saved'); |
|
83 | + } |
|
84 | 84 | |
85 | - $storage->setBackendOption('user', $credentials['user']); |
|
86 | - $storage->setBackendOption('password', $credentials['password']); |
|
87 | - } |
|
85 | + $storage->setBackendOption('user', $credentials['user']); |
|
86 | + $storage->setBackendOption('password', $credentials['password']); |
|
87 | + } |
|
88 | 88 | |
89 | 89 | } |
@@ -61,7 +61,7 @@ |
||
61 | 61 | } |
62 | 62 | |
63 | 63 | private function getCredentialsIdentifier($storageId) { |
64 | - return self::CREDENTIALS_IDENTIFIER_PREFIX . $storageId; |
|
64 | + return self::CREDENTIALS_IDENTIFIER_PREFIX.$storageId; |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | public function saveBackendOptions(IUser $user, $id, array $options) { |
@@ -36,54 +36,54 @@ |
||
36 | 36 | */ |
37 | 37 | class GlobalAuth extends AuthMechanism { |
38 | 38 | |
39 | - const CREDENTIALS_IDENTIFIER = 'password::global'; |
|
39 | + const CREDENTIALS_IDENTIFIER = 'password::global'; |
|
40 | 40 | |
41 | - /** @var ICredentialsManager */ |
|
42 | - protected $credentialsManager; |
|
41 | + /** @var ICredentialsManager */ |
|
42 | + protected $credentialsManager; |
|
43 | 43 | |
44 | - public function __construct(IL10N $l, ICredentialsManager $credentialsManager) { |
|
45 | - $this->credentialsManager = $credentialsManager; |
|
44 | + public function __construct(IL10N $l, ICredentialsManager $credentialsManager) { |
|
45 | + $this->credentialsManager = $credentialsManager; |
|
46 | 46 | |
47 | - $this |
|
48 | - ->setIdentifier('password::global') |
|
49 | - ->setVisibility(BackendService::VISIBILITY_DEFAULT) |
|
50 | - ->setScheme(self::SCHEME_PASSWORD) |
|
51 | - ->setText($l->t('Global credentials')); |
|
52 | - } |
|
47 | + $this |
|
48 | + ->setIdentifier('password::global') |
|
49 | + ->setVisibility(BackendService::VISIBILITY_DEFAULT) |
|
50 | + ->setScheme(self::SCHEME_PASSWORD) |
|
51 | + ->setText($l->t('Global credentials')); |
|
52 | + } |
|
53 | 53 | |
54 | - public function getAuth($uid) { |
|
55 | - $auth = $this->credentialsManager->retrieve($uid, self::CREDENTIALS_IDENTIFIER); |
|
56 | - if (!is_array($auth)) { |
|
57 | - return [ |
|
58 | - 'user' => '', |
|
59 | - 'password' => '' |
|
60 | - ]; |
|
61 | - } else { |
|
62 | - return $auth; |
|
63 | - } |
|
64 | - } |
|
54 | + public function getAuth($uid) { |
|
55 | + $auth = $this->credentialsManager->retrieve($uid, self::CREDENTIALS_IDENTIFIER); |
|
56 | + if (!is_array($auth)) { |
|
57 | + return [ |
|
58 | + 'user' => '', |
|
59 | + 'password' => '' |
|
60 | + ]; |
|
61 | + } else { |
|
62 | + return $auth; |
|
63 | + } |
|
64 | + } |
|
65 | 65 | |
66 | - public function saveAuth($uid, $user, $password) { |
|
67 | - $this->credentialsManager->store($uid, self::CREDENTIALS_IDENTIFIER, [ |
|
68 | - 'user' => $user, |
|
69 | - 'password' => $password |
|
70 | - ]); |
|
71 | - } |
|
66 | + public function saveAuth($uid, $user, $password) { |
|
67 | + $this->credentialsManager->store($uid, self::CREDENTIALS_IDENTIFIER, [ |
|
68 | + 'user' => $user, |
|
69 | + 'password' => $password |
|
70 | + ]); |
|
71 | + } |
|
72 | 72 | |
73 | - public function manipulateStorageConfig(StorageConfig &$storage, IUser $user = null) { |
|
74 | - if ($storage->getType() === StorageConfig::MOUNT_TYPE_ADMIN) { |
|
75 | - $uid = ''; |
|
76 | - } elseif (is_null($user)) { |
|
77 | - throw new InsufficientDataForMeaningfulAnswerException('No credentials saved'); |
|
78 | - } else { |
|
79 | - $uid = $user->getUID(); |
|
80 | - } |
|
81 | - $credentials = $this->credentialsManager->retrieve($uid, self::CREDENTIALS_IDENTIFIER); |
|
73 | + public function manipulateStorageConfig(StorageConfig &$storage, IUser $user = null) { |
|
74 | + if ($storage->getType() === StorageConfig::MOUNT_TYPE_ADMIN) { |
|
75 | + $uid = ''; |
|
76 | + } elseif (is_null($user)) { |
|
77 | + throw new InsufficientDataForMeaningfulAnswerException('No credentials saved'); |
|
78 | + } else { |
|
79 | + $uid = $user->getUID(); |
|
80 | + } |
|
81 | + $credentials = $this->credentialsManager->retrieve($uid, self::CREDENTIALS_IDENTIFIER); |
|
82 | 82 | |
83 | - if (is_array($credentials)) { |
|
84 | - $storage->setBackendOption('user', $credentials['user']); |
|
85 | - $storage->setBackendOption('password', $credentials['password']); |
|
86 | - } |
|
87 | - } |
|
83 | + if (is_array($credentials)) { |
|
84 | + $storage->setBackendOption('user', $credentials['user']); |
|
85 | + $storage->setBackendOption('password', $credentials['password']); |
|
86 | + } |
|
87 | + } |
|
88 | 88 | |
89 | 89 | } |
@@ -28,10 +28,10 @@ |
||
28 | 28 | * For auth mechanisms where the user needs to provide credentials |
29 | 29 | */ |
30 | 30 | interface IUserProvided { |
31 | - /** |
|
32 | - * @param IUser $user the user for which to save the user provided options |
|
33 | - * @param int $mountId the mount id to save the options for |
|
34 | - * @param array $options the user provided options |
|
35 | - */ |
|
36 | - public function saveBackendOptions(IUser $user, $mountId, array $options); |
|
31 | + /** |
|
32 | + * @param IUser $user the user for which to save the user provided options |
|
33 | + * @param int $mountId the mount id to save the options for |
|
34 | + * @param array $options the user provided options |
|
35 | + */ |
|
36 | + public function saveBackendOptions(IUser $user, $mountId, array $options); |
|
37 | 37 | } |
@@ -29,12 +29,12 @@ |
||
29 | 29 | */ |
30 | 30 | class Builtin extends AuthMechanism { |
31 | 31 | |
32 | - public function __construct(IL10N $l) { |
|
33 | - $this |
|
34 | - ->setIdentifier('builtin::builtin') |
|
35 | - ->setScheme(self::SCHEME_BUILTIN) |
|
36 | - ->setText($l->t('Builtin')) |
|
37 | - ; |
|
38 | - } |
|
32 | + public function __construct(IL10N $l) { |
|
33 | + $this |
|
34 | + ->setIdentifier('builtin::builtin') |
|
35 | + ->setScheme(self::SCHEME_BUILTIN) |
|
36 | + ->setText($l->t('Builtin')) |
|
37 | + ; |
|
38 | + } |
|
39 | 39 | |
40 | 40 | } |
@@ -29,12 +29,12 @@ |
||
29 | 29 | */ |
30 | 30 | class NullMechanism extends AuthMechanism { |
31 | 31 | |
32 | - public function __construct(IL10N $l) { |
|
33 | - $this |
|
34 | - ->setIdentifier('null::null') |
|
35 | - ->setScheme(self::SCHEME_NULL) |
|
36 | - ->setText($l->t('None')) |
|
37 | - ; |
|
38 | - } |
|
32 | + public function __construct(IL10N $l) { |
|
33 | + $this |
|
34 | + ->setIdentifier('null::null') |
|
35 | + ->setScheme(self::SCHEME_NULL) |
|
36 | + ->setText($l->t('None')) |
|
37 | + ; |
|
38 | + } |
|
39 | 39 | |
40 | 40 | } |
@@ -29,33 +29,33 @@ |
||
29 | 29 | */ |
30 | 30 | trait PriorityTrait { |
31 | 31 | |
32 | - /** @var int initial priority */ |
|
33 | - protected $priority = BackendService::PRIORITY_DEFAULT; |
|
34 | - |
|
35 | - /** |
|
36 | - * @return int |
|
37 | - */ |
|
38 | - public function getPriority() { |
|
39 | - return $this->priority; |
|
40 | - } |
|
41 | - |
|
42 | - /** |
|
43 | - * @param int $priority |
|
44 | - * @return self |
|
45 | - */ |
|
46 | - public function setPriority($priority) { |
|
47 | - $this->priority = $priority; |
|
48 | - return $this; |
|
49 | - } |
|
50 | - |
|
51 | - /** |
|
52 | - * @param PriorityTrait $a |
|
53 | - * @param PriorityTrait $b |
|
54 | - * @return int |
|
55 | - */ |
|
56 | - public static function priorityCompare(PriorityTrait $a, PriorityTrait $b) { |
|
57 | - return ($a->getPriority() - $b->getPriority()); |
|
58 | - } |
|
32 | + /** @var int initial priority */ |
|
33 | + protected $priority = BackendService::PRIORITY_DEFAULT; |
|
34 | + |
|
35 | + /** |
|
36 | + * @return int |
|
37 | + */ |
|
38 | + public function getPriority() { |
|
39 | + return $this->priority; |
|
40 | + } |
|
41 | + |
|
42 | + /** |
|
43 | + * @param int $priority |
|
44 | + * @return self |
|
45 | + */ |
|
46 | + public function setPriority($priority) { |
|
47 | + $this->priority = $priority; |
|
48 | + return $this; |
|
49 | + } |
|
50 | + |
|
51 | + /** |
|
52 | + * @param PriorityTrait $a |
|
53 | + * @param PriorityTrait $b |
|
54 | + * @return int |
|
55 | + */ |
|
56 | + public static function priorityCompare(PriorityTrait $a, PriorityTrait $b) { |
|
57 | + return ($a->getPriority() - $b->getPriority()); |
|
58 | + } |
|
59 | 59 | |
60 | 60 | } |
61 | 61 |
@@ -30,10 +30,10 @@ |
||
30 | 30 | */ |
31 | 31 | interface IBackendProvider { |
32 | 32 | |
33 | - /** |
|
34 | - * @since 9.1.0 |
|
35 | - * @return Backend[] |
|
36 | - */ |
|
37 | - public function getBackends(); |
|
33 | + /** |
|
34 | + * @since 9.1.0 |
|
35 | + * @return Backend[] |
|
36 | + */ |
|
37 | + public function getBackends(); |
|
38 | 38 | |
39 | 39 | } |
@@ -30,10 +30,10 @@ |
||
30 | 30 | */ |
31 | 31 | interface IAuthMechanismProvider { |
32 | 32 | |
33 | - /** |
|
34 | - * @since 9.1.0 |
|
35 | - * @return AuthMechanism[] |
|
36 | - */ |
|
37 | - public function getAuthMechanisms(); |
|
33 | + /** |
|
34 | + * @since 9.1.0 |
|
35 | + * @return AuthMechanism[] |
|
36 | + */ |
|
37 | + public function getAuthMechanisms(); |
|
38 | 38 | |
39 | 39 | } |
@@ -31,14 +31,14 @@ |
||
31 | 31 | */ |
32 | 32 | class SessionStorageWrapper extends PermissionsMask { |
33 | 33 | |
34 | - /** |
|
35 | - * @param array $arguments ['storage' => $storage] |
|
36 | - */ |
|
37 | - public function __construct($arguments) { |
|
38 | - // disable sharing permission |
|
39 | - $arguments['mask'] = Constants::PERMISSION_ALL & ~Constants::PERMISSION_SHARE; |
|
40 | - parent::__construct($arguments); |
|
41 | - } |
|
34 | + /** |
|
35 | + * @param array $arguments ['storage' => $storage] |
|
36 | + */ |
|
37 | + public function __construct($arguments) { |
|
38 | + // disable sharing permission |
|
39 | + $arguments['mask'] = Constants::PERMISSION_ALL & ~Constants::PERMISSION_SHARE; |
|
40 | + parent::__construct($arguments); |
|
41 | + } |
|
42 | 42 | |
43 | 43 | } |
44 | 44 |