@@ -41,96 +41,96 @@ |
||
41 | 41 | use OCP\IUser; |
42 | 42 | |
43 | 43 | class SMB extends Backend { |
44 | - use LegacyDependencyCheckPolyfill; |
|
44 | + use LegacyDependencyCheckPolyfill; |
|
45 | 45 | |
46 | - public function __construct(IL10N $l, Password $legacyAuth) { |
|
47 | - $this |
|
48 | - ->setIdentifier('smb') |
|
49 | - ->addIdentifierAlias('\OC\Files\Storage\SMB')// legacy compat |
|
50 | - ->setStorageClass('\OCA\Files_External\Lib\Storage\SMB') |
|
51 | - ->setText($l->t('SMB/CIFS')) |
|
52 | - ->addParameters([ |
|
53 | - new DefinitionParameter('host', $l->t('Host')), |
|
54 | - new DefinitionParameter('share', $l->t('Share')), |
|
55 | - (new DefinitionParameter('root', $l->t('Remote subfolder'))) |
|
56 | - ->setFlag(DefinitionParameter::FLAG_OPTIONAL), |
|
57 | - (new DefinitionParameter('domain', $l->t('Domain'))) |
|
58 | - ->setFlag(DefinitionParameter::FLAG_OPTIONAL), |
|
59 | - (new DefinitionParameter('show_hidden', $l->t('Show hidden files'))) |
|
60 | - ->setType(DefinitionParameter::VALUE_BOOLEAN) |
|
61 | - ->setFlag(DefinitionParameter::FLAG_OPTIONAL), |
|
62 | - (new DefinitionParameter('check_acl', $l->t('Verify ACL access when listing files'))) |
|
63 | - ->setType(DefinitionParameter::VALUE_BOOLEAN) |
|
64 | - ->setFlag(DefinitionParameter::FLAG_OPTIONAL) |
|
65 | - ->setTooltip($l->t("Check the ACL's of each file or folder inside a directory to filter out items where the user has no read permissions, comes with a performance penalty")), |
|
66 | - (new DefinitionParameter('timeout', $l->t('Timeout'))) |
|
67 | - ->setType(DefinitionParameter::VALUE_HIDDEN) |
|
68 | - ->setFlag(DefinitionParameter::FLAG_OPTIONAL), |
|
69 | - ]) |
|
70 | - ->addAuthScheme(AuthMechanism::SCHEME_PASSWORD) |
|
71 | - ->addAuthScheme(AuthMechanism::SCHEME_SMB) |
|
72 | - ->setLegacyAuthMechanism($legacyAuth); |
|
73 | - } |
|
46 | + public function __construct(IL10N $l, Password $legacyAuth) { |
|
47 | + $this |
|
48 | + ->setIdentifier('smb') |
|
49 | + ->addIdentifierAlias('\OC\Files\Storage\SMB')// legacy compat |
|
50 | + ->setStorageClass('\OCA\Files_External\Lib\Storage\SMB') |
|
51 | + ->setText($l->t('SMB/CIFS')) |
|
52 | + ->addParameters([ |
|
53 | + new DefinitionParameter('host', $l->t('Host')), |
|
54 | + new DefinitionParameter('share', $l->t('Share')), |
|
55 | + (new DefinitionParameter('root', $l->t('Remote subfolder'))) |
|
56 | + ->setFlag(DefinitionParameter::FLAG_OPTIONAL), |
|
57 | + (new DefinitionParameter('domain', $l->t('Domain'))) |
|
58 | + ->setFlag(DefinitionParameter::FLAG_OPTIONAL), |
|
59 | + (new DefinitionParameter('show_hidden', $l->t('Show hidden files'))) |
|
60 | + ->setType(DefinitionParameter::VALUE_BOOLEAN) |
|
61 | + ->setFlag(DefinitionParameter::FLAG_OPTIONAL), |
|
62 | + (new DefinitionParameter('check_acl', $l->t('Verify ACL access when listing files'))) |
|
63 | + ->setType(DefinitionParameter::VALUE_BOOLEAN) |
|
64 | + ->setFlag(DefinitionParameter::FLAG_OPTIONAL) |
|
65 | + ->setTooltip($l->t("Check the ACL's of each file or folder inside a directory to filter out items where the user has no read permissions, comes with a performance penalty")), |
|
66 | + (new DefinitionParameter('timeout', $l->t('Timeout'))) |
|
67 | + ->setType(DefinitionParameter::VALUE_HIDDEN) |
|
68 | + ->setFlag(DefinitionParameter::FLAG_OPTIONAL), |
|
69 | + ]) |
|
70 | + ->addAuthScheme(AuthMechanism::SCHEME_PASSWORD) |
|
71 | + ->addAuthScheme(AuthMechanism::SCHEME_SMB) |
|
72 | + ->setLegacyAuthMechanism($legacyAuth); |
|
73 | + } |
|
74 | 74 | |
75 | - public function manipulateStorageConfig(StorageConfig &$storage, IUser $user = null) { |
|
76 | - $auth = $storage->getAuthMechanism(); |
|
77 | - if ($auth->getScheme() === AuthMechanism::SCHEME_PASSWORD) { |
|
78 | - if (!is_string($storage->getBackendOption('user')) || !is_string($storage->getBackendOption('password'))) { |
|
79 | - throw new \InvalidArgumentException('user or password is not set'); |
|
80 | - } |
|
75 | + public function manipulateStorageConfig(StorageConfig &$storage, IUser $user = null) { |
|
76 | + $auth = $storage->getAuthMechanism(); |
|
77 | + if ($auth->getScheme() === AuthMechanism::SCHEME_PASSWORD) { |
|
78 | + if (!is_string($storage->getBackendOption('user')) || !is_string($storage->getBackendOption('password'))) { |
|
79 | + throw new \InvalidArgumentException('user or password is not set'); |
|
80 | + } |
|
81 | 81 | |
82 | - $smbAuth = new BasicAuth( |
|
83 | - $storage->getBackendOption('user'), |
|
84 | - $storage->getBackendOption('domain'), |
|
85 | - $storage->getBackendOption('password') |
|
86 | - ); |
|
87 | - } else { |
|
88 | - switch ($auth->getIdentifier()) { |
|
89 | - case 'smb::kerberos': |
|
90 | - $smbAuth = new KerberosAuth(); |
|
91 | - break; |
|
92 | - case 'smb::kerberosapache': |
|
93 | - if (!$auth instanceof KerberosApacheAuthMechanism) { |
|
94 | - throw new \InvalidArgumentException('invalid authentication backend'); |
|
95 | - } |
|
96 | - $credentialsStore = $auth->getCredentialsStore(); |
|
97 | - $kerbAuth = new KerberosApacheAuth(); |
|
98 | - // check if a kerberos ticket is available, else fallback to session credentials |
|
99 | - if ($kerbAuth->checkTicket()) { |
|
100 | - $smbAuth = $kerbAuth; |
|
101 | - } else { |
|
102 | - try { |
|
103 | - $credentials = $credentialsStore->getLoginCredentials(); |
|
104 | - $user = $credentials->getLoginName(); |
|
105 | - $pass = $credentials->getPassword(); |
|
106 | - preg_match('/(.*)@(.*)/', $user, $matches); |
|
107 | - $realm = $storage->getBackendOption('default_realm'); |
|
108 | - if (empty($realm)) { |
|
109 | - $realm = 'WORKGROUP'; |
|
110 | - } |
|
111 | - if (count($matches) === 0) { |
|
112 | - $username = $user; |
|
113 | - $workgroup = $realm; |
|
114 | - } else { |
|
115 | - $username = $matches[1];; |
|
116 | - $workgroup = $matches[2]; |
|
117 | - } |
|
118 | - $smbAuth = new BasicAuth( |
|
119 | - $username, |
|
120 | - $workgroup, |
|
121 | - $pass |
|
122 | - ); |
|
123 | - } catch (\Exception $e) { |
|
124 | - throw new InsufficientDataForMeaningfulAnswerException('No session credentials saved'); |
|
125 | - } |
|
126 | - } |
|
82 | + $smbAuth = new BasicAuth( |
|
83 | + $storage->getBackendOption('user'), |
|
84 | + $storage->getBackendOption('domain'), |
|
85 | + $storage->getBackendOption('password') |
|
86 | + ); |
|
87 | + } else { |
|
88 | + switch ($auth->getIdentifier()) { |
|
89 | + case 'smb::kerberos': |
|
90 | + $smbAuth = new KerberosAuth(); |
|
91 | + break; |
|
92 | + case 'smb::kerberosapache': |
|
93 | + if (!$auth instanceof KerberosApacheAuthMechanism) { |
|
94 | + throw new \InvalidArgumentException('invalid authentication backend'); |
|
95 | + } |
|
96 | + $credentialsStore = $auth->getCredentialsStore(); |
|
97 | + $kerbAuth = new KerberosApacheAuth(); |
|
98 | + // check if a kerberos ticket is available, else fallback to session credentials |
|
99 | + if ($kerbAuth->checkTicket()) { |
|
100 | + $smbAuth = $kerbAuth; |
|
101 | + } else { |
|
102 | + try { |
|
103 | + $credentials = $credentialsStore->getLoginCredentials(); |
|
104 | + $user = $credentials->getLoginName(); |
|
105 | + $pass = $credentials->getPassword(); |
|
106 | + preg_match('/(.*)@(.*)/', $user, $matches); |
|
107 | + $realm = $storage->getBackendOption('default_realm'); |
|
108 | + if (empty($realm)) { |
|
109 | + $realm = 'WORKGROUP'; |
|
110 | + } |
|
111 | + if (count($matches) === 0) { |
|
112 | + $username = $user; |
|
113 | + $workgroup = $realm; |
|
114 | + } else { |
|
115 | + $username = $matches[1];; |
|
116 | + $workgroup = $matches[2]; |
|
117 | + } |
|
118 | + $smbAuth = new BasicAuth( |
|
119 | + $username, |
|
120 | + $workgroup, |
|
121 | + $pass |
|
122 | + ); |
|
123 | + } catch (\Exception $e) { |
|
124 | + throw new InsufficientDataForMeaningfulAnswerException('No session credentials saved'); |
|
125 | + } |
|
126 | + } |
|
127 | 127 | |
128 | - break; |
|
129 | - default: |
|
130 | - throw new \InvalidArgumentException('unknown authentication backend'); |
|
131 | - } |
|
132 | - } |
|
128 | + break; |
|
129 | + default: |
|
130 | + throw new \InvalidArgumentException('unknown authentication backend'); |
|
131 | + } |
|
132 | + } |
|
133 | 133 | |
134 | - $storage->setBackendOption('auth', $smbAuth); |
|
135 | - } |
|
134 | + $storage->setBackendOption('auth', $smbAuth); |
|
135 | + } |
|
136 | 136 | } |
@@ -112,7 +112,7 @@ |
||
112 | 112 | $username = $user; |
113 | 113 | $workgroup = $realm; |
114 | 114 | } else { |
115 | - $username = $matches[1];; |
|
115 | + $username = $matches[1]; ; |
|
116 | 116 | $workgroup = $matches[2]; |
117 | 117 | } |
118 | 118 | $smbAuth = new BasicAuth( |