Completed
Push — stable13 ( f62775...bea70d )
by Roeland
12:09
created
apps/files_external/lib/Lib/Auth/Password/SessionCredentials.php 1 patch
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -39,31 +39,31 @@
 block discarded – undo
39 39
  */
40 40
 class SessionCredentials extends AuthMechanism {
41 41
 
42
-	/** @var CredentialsStore */
43
-	private $credentialsStore;
42
+    /** @var CredentialsStore */
43
+    private $credentialsStore;
44 44
 
45
-	public function __construct(IL10N $l, CredentialsStore $credentialsStore) {
46
-		$this->credentialsStore = $credentialsStore;
45
+    public function __construct(IL10N $l, CredentialsStore $credentialsStore) {
46
+        $this->credentialsStore = $credentialsStore;
47 47
 
48
-		$this->setIdentifier('password::sessioncredentials')
49
-			->setScheme(self::SCHEME_PASSWORD)
50
-			->setText($l->t('Log-in credentials, save in session'))
51
-			->addParameters([]);
52
-	}
48
+        $this->setIdentifier('password::sessioncredentials')
49
+            ->setScheme(self::SCHEME_PASSWORD)
50
+            ->setText($l->t('Log-in credentials, save in session'))
51
+            ->addParameters([]);
52
+    }
53 53
 
54
-	public function manipulateStorageConfig(StorageConfig &$storage, IUser $user = null) {
55
-		try {
56
-			$credentials = $this->credentialsStore->getLoginCredentials();
57
-		} catch (CredentialsUnavailableException $e) {
58
-			throw new InsufficientDataForMeaningfulAnswerException('No session credentials saved');
59
-		}
54
+    public function manipulateStorageConfig(StorageConfig &$storage, IUser $user = null) {
55
+        try {
56
+            $credentials = $this->credentialsStore->getLoginCredentials();
57
+        } catch (CredentialsUnavailableException $e) {
58
+            throw new InsufficientDataForMeaningfulAnswerException('No session credentials saved');
59
+        }
60 60
 
61
-		$storage->setBackendOption('user', $credentials->getLoginName());
62
-		$storage->setBackendOption('password', $credentials->getPassword());
63
-	}
61
+        $storage->setBackendOption('user', $credentials->getLoginName());
62
+        $storage->setBackendOption('password', $credentials->getPassword());
63
+    }
64 64
 
65
-	public function wrapStorage(Storage $storage) {
66
-		return new SessionStorageWrapper(['storage' => $storage]);
67
-	}
65
+    public function wrapStorage(Storage $storage) {
66
+        return new SessionStorageWrapper(['storage' => $storage]);
67
+    }
68 68
 
69 69
 }
Please login to merge, or discard this patch.
apps/files_external/lib/Lib/Auth/Password/Password.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -31,16 +31,16 @@
 block discarded – undo
31 31
  */
32 32
 class Password extends AuthMechanism {
33 33
 
34
-	public function __construct(IL10N $l) {
35
-		$this
36
-			->setIdentifier('password::password')
37
-			->setScheme(self::SCHEME_PASSWORD)
38
-			->setText($l->t('Username and password'))
39
-			->addParameters([
40
-				(new DefinitionParameter('user', $l->t('Username'))),
41
-				(new DefinitionParameter('password', $l->t('Password')))
42
-					->setType(DefinitionParameter::VALUE_PASSWORD),
43
-			]);
44
-	}
34
+    public function __construct(IL10N $l) {
35
+        $this
36
+            ->setIdentifier('password::password')
37
+            ->setScheme(self::SCHEME_PASSWORD)
38
+            ->setText($l->t('Username and password'))
39
+            ->addParameters([
40
+                (new DefinitionParameter('user', $l->t('Username'))),
41
+                (new DefinitionParameter('password', $l->t('Password')))
42
+                    ->setType(DefinitionParameter::VALUE_PASSWORD),
43
+            ]);
44
+    }
45 45
 
46 46
 }
Please login to merge, or discard this patch.
apps/files_external/lib/Lib/Auth/Password/LoginCredentials.php 1 patch
Indentation   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -38,56 +38,56 @@
 block discarded – undo
38 38
  */
39 39
 class LoginCredentials extends AuthMechanism {
40 40
 
41
-	const CREDENTIALS_IDENTIFIER = 'password::logincredentials/credentials';
41
+    const CREDENTIALS_IDENTIFIER = 'password::logincredentials/credentials';
42 42
 
43
-	/** @var ISession */
44
-	protected $session;
43
+    /** @var ISession */
44
+    protected $session;
45 45
 
46
-	/** @var ICredentialsManager */
47
-	protected $credentialsManager;
46
+    /** @var ICredentialsManager */
47
+    protected $credentialsManager;
48 48
 
49
-	public function __construct(IL10N $l, ISession $session, ICredentialsManager $credentialsManager) {
50
-		$this->session = $session;
51
-		$this->credentialsManager = $credentialsManager;
49
+    public function __construct(IL10N $l, ISession $session, ICredentialsManager $credentialsManager) {
50
+        $this->session = $session;
51
+        $this->credentialsManager = $credentialsManager;
52 52
 
53
-		$this
54
-			->setIdentifier('password::logincredentials')
55
-			->setScheme(self::SCHEME_PASSWORD)
56
-			->setText($l->t('Log-in credentials, save in database'))
57
-			->addParameters([
58
-			])
59
-		;
53
+        $this
54
+            ->setIdentifier('password::logincredentials')
55
+            ->setScheme(self::SCHEME_PASSWORD)
56
+            ->setText($l->t('Log-in credentials, save in database'))
57
+            ->addParameters([
58
+            ])
59
+        ;
60 60
 
61
-		\OCP\Util::connectHook('OC_User', 'post_login', $this, 'authenticate');
62
-	}
61
+        \OCP\Util::connectHook('OC_User', 'post_login', $this, 'authenticate');
62
+    }
63 63
 
64
-	/**
65
-	 * Hook listener on post login
66
-	 *
67
-	 * @param array $params
68
-	 */
69
-	public function authenticate(array $params) {
70
-		$userId = $params['uid'];
71
-		$credentials = [
72
-			'user' => $this->session->get('loginname'),
73
-			'password' => $params['password']
74
-		];
75
-		$this->credentialsManager->store($userId, self::CREDENTIALS_IDENTIFIER, $credentials);
76
-	}
64
+    /**
65
+     * Hook listener on post login
66
+     *
67
+     * @param array $params
68
+     */
69
+    public function authenticate(array $params) {
70
+        $userId = $params['uid'];
71
+        $credentials = [
72
+            'user' => $this->session->get('loginname'),
73
+            'password' => $params['password']
74
+        ];
75
+        $this->credentialsManager->store($userId, self::CREDENTIALS_IDENTIFIER, $credentials);
76
+    }
77 77
 
78
-	public function manipulateStorageConfig(StorageConfig &$storage, IUser $user = null) {
79
-		if (!isset($user)) {
80
-			throw new InsufficientDataForMeaningfulAnswerException('No login credentials saved');
81
-		}
82
-		$uid = $user->getUID();
83
-		$credentials = $this->credentialsManager->retrieve($uid, self::CREDENTIALS_IDENTIFIER);
78
+    public function manipulateStorageConfig(StorageConfig &$storage, IUser $user = null) {
79
+        if (!isset($user)) {
80
+            throw new InsufficientDataForMeaningfulAnswerException('No login credentials saved');
81
+        }
82
+        $uid = $user->getUID();
83
+        $credentials = $this->credentialsManager->retrieve($uid, self::CREDENTIALS_IDENTIFIER);
84 84
 
85
-		if (!isset($credentials)) {
86
-			throw new InsufficientDataForMeaningfulAnswerException('No login credentials saved');
87
-		}
85
+        if (!isset($credentials)) {
86
+            throw new InsufficientDataForMeaningfulAnswerException('No login credentials saved');
87
+        }
88 88
 
89
-		$storage->setBackendOption('user', $credentials['user']);
90
-		$storage->setBackendOption('password', $credentials['password']);
91
-	}
89
+        $storage->setBackendOption('user', $credentials['user']);
90
+        $storage->setBackendOption('password', $credentials['password']);
91
+    }
92 92
 
93 93
 }
Please login to merge, or discard this patch.
apps/files_external/lib/Lib/Auth/Password/UserProvided.php 1 patch
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -38,52 +38,52 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
apps/files_external/lib/Lib/Auth/Password/GlobalAuth.php 1 patch
Indentation   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -36,54 +36,54 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
apps/files_external/lib/Lib/Auth/OAuth1/OAuth1.php 1 patch
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -31,24 +31,24 @@
 block discarded – undo
31 31
  */
32 32
 class OAuth1 extends AuthMechanism {
33 33
 
34
-	public function __construct(IL10N $l) {
35
-		$this
36
-			->setIdentifier('oauth1::oauth1')
37
-			->setScheme(self::SCHEME_OAUTH1)
38
-			->setText($l->t('OAuth1'))
39
-			->addParameters([
40
-				(new DefinitionParameter('configured', 'configured'))
41
-					->setType(DefinitionParameter::VALUE_HIDDEN),
42
-				(new DefinitionParameter('app_key', $l->t('App key'))),
43
-				(new DefinitionParameter('app_secret', $l->t('App secret')))
44
-					->setType(DefinitionParameter::VALUE_PASSWORD),
45
-				(new DefinitionParameter('token', 'token'))
46
-					->setType(DefinitionParameter::VALUE_HIDDEN),
47
-				(new DefinitionParameter('token_secret', 'token_secret'))
48
-					->setType(DefinitionParameter::VALUE_HIDDEN),
49
-			])
50
-			->addCustomJs('oauth1')
51
-		;
52
-	}
34
+    public function __construct(IL10N $l) {
35
+        $this
36
+            ->setIdentifier('oauth1::oauth1')
37
+            ->setScheme(self::SCHEME_OAUTH1)
38
+            ->setText($l->t('OAuth1'))
39
+            ->addParameters([
40
+                (new DefinitionParameter('configured', 'configured'))
41
+                    ->setType(DefinitionParameter::VALUE_HIDDEN),
42
+                (new DefinitionParameter('app_key', $l->t('App key'))),
43
+                (new DefinitionParameter('app_secret', $l->t('App secret')))
44
+                    ->setType(DefinitionParameter::VALUE_PASSWORD),
45
+                (new DefinitionParameter('token', 'token'))
46
+                    ->setType(DefinitionParameter::VALUE_HIDDEN),
47
+                (new DefinitionParameter('token_secret', 'token_secret'))
48
+                    ->setType(DefinitionParameter::VALUE_HIDDEN),
49
+            ])
50
+            ->addCustomJs('oauth1')
51
+        ;
52
+    }
53 53
 
54 54
 }
Please login to merge, or discard this patch.
apps/files_external/lib/Lib/Auth/OAuth2/OAuth2.php 1 patch
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -31,22 +31,22 @@
 block discarded – undo
31 31
  */
32 32
 class OAuth2 extends AuthMechanism {
33 33
 
34
-	public function __construct(IL10N $l) {
35
-		$this
36
-			->setIdentifier('oauth2::oauth2')
37
-			->setScheme(self::SCHEME_OAUTH2)
38
-			->setText($l->t('OAuth2'))
39
-			->addParameters([
40
-				(new DefinitionParameter('configured', 'configured'))
41
-					->setType(DefinitionParameter::VALUE_HIDDEN),
42
-				(new DefinitionParameter('client_id', $l->t('Client ID'))),
43
-				(new DefinitionParameter('client_secret', $l->t('Client secret')))
44
-					->setType(DefinitionParameter::VALUE_PASSWORD),
45
-				(new DefinitionParameter('token', 'token'))
46
-					->setType(DefinitionParameter::VALUE_HIDDEN),
47
-			])
48
-			->addCustomJs('oauth2')
49
-		;
50
-	}
34
+    public function __construct(IL10N $l) {
35
+        $this
36
+            ->setIdentifier('oauth2::oauth2')
37
+            ->setScheme(self::SCHEME_OAUTH2)
38
+            ->setText($l->t('OAuth2'))
39
+            ->addParameters([
40
+                (new DefinitionParameter('configured', 'configured'))
41
+                    ->setType(DefinitionParameter::VALUE_HIDDEN),
42
+                (new DefinitionParameter('client_id', $l->t('Client ID'))),
43
+                (new DefinitionParameter('client_secret', $l->t('Client secret')))
44
+                    ->setType(DefinitionParameter::VALUE_PASSWORD),
45
+                (new DefinitionParameter('token', 'token'))
46
+                    ->setType(DefinitionParameter::VALUE_HIDDEN),
47
+            ])
48
+            ->addCustomJs('oauth2')
49
+        ;
50
+    }
51 51
 
52 52
 }
Please login to merge, or discard this patch.
apps/files_external/lib/Lib/Auth/IUserProvided.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -28,10 +28,10 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
apps/files_external/lib/Lib/Auth/OpenStack/Rackspace.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -31,17 +31,17 @@
 block discarded – undo
31 31
  */
32 32
 class Rackspace extends AuthMechanism {
33 33
 
34
-	public function __construct(IL10N $l) {
35
-		$this
36
-			->setIdentifier('openstack::rackspace')
37
-			->setScheme(self::SCHEME_OPENSTACK)
38
-			->setText($l->t('Rackspace'))
39
-			->addParameters([
40
-				(new DefinitionParameter('user', $l->t('Username'))),
41
-				(new DefinitionParameter('key', $l->t('API key')))
42
-					->setType(DefinitionParameter::VALUE_PASSWORD),
43
-			])
44
-		;
45
-	}
34
+    public function __construct(IL10N $l) {
35
+        $this
36
+            ->setIdentifier('openstack::rackspace')
37
+            ->setScheme(self::SCHEME_OPENSTACK)
38
+            ->setText($l->t('Rackspace'))
39
+            ->addParameters([
40
+                (new DefinitionParameter('user', $l->t('Username'))),
41
+                (new DefinitionParameter('key', $l->t('API key')))
42
+                    ->setType(DefinitionParameter::VALUE_PASSWORD),
43
+            ])
44
+        ;
45
+    }
46 46
 
47 47
 }
Please login to merge, or discard this patch.