From 90be8f336cf55a3238aeecacf3a852484d5c342b Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 28 May 2018 16:17:19 +0200 Subject: Add support for using kerberos ticket to authenticate to smb servers Signed-off-by: Robin Appelman --- apps/files_external/lib/Lib/Storage/SMB.php | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'apps/files_external/lib/Lib/Storage/SMB.php') diff --git a/apps/files_external/lib/Lib/Storage/SMB.php b/apps/files_external/lib/Lib/Storage/SMB.php index 93fc020d71b..6213e54dff9 100644 --- a/apps/files_external/lib/Lib/Storage/SMB.php +++ b/apps/files_external/lib/Lib/Storage/SMB.php @@ -78,19 +78,27 @@ class SMB extends Common implements INotifyStorage { protected $statCache; public function __construct($params) { - if (isset($params['host']) && isset($params['user']) && isset($params['password']) && isset($params['share'])) { + if (!isset($params['host'])) { + throw new \Exception('Invalid configuration, no host provided'); + } + + if (isset($params['auth'])) { + $auth = $params['auth']; + } else if (isset($params['user']) && isset($params['password']) && isset($params['share'])) { list($workgroup, $user) = $this->splitUser($params['user']); $auth = new BasicAuth($user, $workgroup, $params['password']); - $serverFactory = new ServerFactory(); - $this->server = $serverFactory->createServer($params['host'], $auth); - $this->share = $this->server->getShare(trim($params['share'], '/')); - - $this->root = $params['root'] ?? '/'; - $this->root = '/' . ltrim($this->root, '/'); - $this->root = rtrim($this->root, '/') . '/'; } else { - throw new \Exception('Invalid configuration'); + throw new \Exception('Invalid configuration, no credentials provided'); } + + $serverFactory = new ServerFactory(); + $this->server = $serverFactory->createServer($params['host'], $auth); + $this->share = $this->server->getShare(trim($params['share'], '/')); + + $this->root = $params['root'] ?? '/'; + $this->root = '/' . ltrim($this->root, '/'); + $this->root = rtrim($this->root, '/') . '/'; + $this->statCache = new CappedMemoryCache(); parent::__construct($params); } -- cgit v1.2.3