diff --git a/README.md b/README.md
index 0bad94b..cc95816 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,12 @@
External user authentication
============================
+
+**⚠⚠ Warning:** As of Version 3.0 this app uses namespace \OCA\UserExternal now. You MUST change your config to adopt to this change. ⚠⚠
+
+## Usage
+
+Go to Apps-Folder of your Nextcloud Installation
+
**Authenticate user login against IMAP, SMB, FTP, WebDAV, HTTP BasicAuth, SSH and XMPP**
Passwords are not stored locally; authentication always happens against
@@ -30,7 +37,7 @@ Add the following to `config.php`:
'user_backends' => array(
array(
- 'class' => 'OC_User_FTP',
+ 'class' => '\OCA\UserExternal\FTP',
'arguments' => array('127.0.0.1'),
),
),
@@ -39,7 +46,7 @@ To enable SSL connections via `ftps`, append a second parameter `true`:
'user_backends' => array(
array(
- 'class' => 'OC_User_FTP',
+ 'class' => '\OCA\UserExternal\FTP',
'arguments' => array('127.0.0.1', true),
),
),
@@ -68,7 +75,7 @@ Add the following to your `config.php`:
'user_backends' => array(
array(
- 'class' => 'OC_User_IMAP',
+ 'class' => '\OCA\UserExternal\IMAP',
'arguments' => array(
'127.0.0.1', 993, 'ssl', 'example.com', true, false
),
@@ -104,7 +111,7 @@ Add the following to your `config.php`:
'user_backends' => array(
array(
- 'class' => 'OC_User_SMB',
+ 'class' => '\OCA\UserExternal\SMB',
'arguments' => array('127.0.0.1'),
),
),
@@ -128,7 +135,7 @@ Add the following to your `config.php`:
'user_backends' => array(
array(
- 'class' => '\OCA\User_External\WebDAVAuth',
+ 'class' => '\OCA\UserExternal\WebDAVAuth',
'arguments' => array('https://example.com/webdav'),
),
),
@@ -151,7 +158,7 @@ Add the following to your `config.php`:
'user_backends' => array(
array(
- 'class' => 'OC_User_BasicAuth',
+ 'class' => '\OCA\UserExternal\BasicAuth',
'arguments' => array('https://example.com/basic_auth'),
),
),
@@ -172,7 +179,7 @@ Add the following to your `config.php`:
'user_backends' => array(
array(
- 'class' => 'OC_User_SSH',
+ 'class' => '\OCA\UserExternal\SSH',
'arguments' => array('127.0.0.1', '22'),
),
),
@@ -193,7 +200,7 @@ Add the following to your `config.php`:
'user_backends' => array (
0 => array (
- 'class' => 'OC_User_XMPP',
+ 'class' => '\OCA\UserExternal\XMPP',
'arguments' => array (
0 => 'dbhost',
1 => 'prosodydb',
diff --git a/appinfo/app.php b/appinfo/app.php
deleted file mode 100644
index 6c3b095..0000000
--- a/appinfo/app.php
+++ /dev/null
@@ -1,7 +0,0 @@
-https://github.com/nextcloud/user_external/issues
https://github.com/nextcloud/user_external.git
-
+
diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php
new file mode 100644
index 0000000..05dec26
--- /dev/null
+++ b/lib/AppInfo/Application.php
@@ -0,0 +1,26 @@
+authUrl, 1, $context);
if(!$canary) {
- OC::$server->getLogger()->error(
+ \OC::$server->getLogger()->error(
'ERROR: Not possible to connect to BasicAuth Url: '.$this->authUrl,
['app' => 'user_external']
);
return false;
}
if (!isset(array_change_key_case($canary, CASE_LOWER)['www-authenticate'])) {
- OC::$server->getLogger()->error(
+ \OC::$server->getLogger()->error(
'ERROR: Mis-configured BasicAuth Url: '.$this->authUrl.', provided URL does not do authentication!',
['app' => 'user_external']
);
@@ -60,7 +62,7 @@ class OC_User_BasicAuth extends \OCA\user_external\Base {
$headers = get_headers($this->authUrl, 1, $context);
if(!$headers) {
- OC::$server->getLogger()->error(
+ \OC::$server->getLogger()->error(
'ERROR: Not possible to connect to BasicAuth Url: '.$this->authUrl,
['app' => 'user_external']
);
@@ -81,7 +83,7 @@ class OC_User_BasicAuth extends \OCA\user_external\Base {
$this->storeUser($uid);
return $uid;
case "3":
- OC::$server->getLogger()->error(
+ \OC::$server->getLogger()->error(
'ERROR: Too many redirects from BasicAuth Url: '.$this->authUrl,
['app' => 'user_external']
);
diff --git a/lib/ftp.php b/lib/FTP.php
similarity index 94%
rename from lib/ftp.php
rename to lib/FTP.php
index ce9ae19..24a4a00 100644
--- a/lib/ftp.php
+++ b/lib/FTP.php
@@ -6,6 +6,8 @@
* See the COPYING-README file.
*/
+namespace OCA\UserExternal;
+
/**
* User authentication against a FTP/FTPS server
*
@@ -15,7 +17,7 @@
* @license http://www.gnu.org/licenses/agpl AGPL
* @link http://github.com/owncloud/apps
*/
-class OC_User_FTP extends \OCA\user_external\Base{
+class FTP extends Base{
private $host;
private $secure;
private $protocol;
@@ -46,7 +48,7 @@ class OC_User_FTP extends \OCA\user_external\Base{
*/
public function checkPassword($uid, $password) {
if (false === array_search($this->protocol, stream_get_wrappers())) {
- OC::$server->getLogger()->error(
+ \OC::$server->getLogger()->error(
'ERROR: Stream wrapper not available: ' . $this->protocol,
['app' => 'user_external']
);
diff --git a/lib/imap.php b/lib/IMAP.php
similarity index 96%
rename from lib/imap.php
rename to lib/IMAP.php
index c48fba6..6406782 100644
--- a/lib/imap.php
+++ b/lib/IMAP.php
@@ -7,6 +7,8 @@
* later.
* See the COPYING-README file.
*/
+namespace OCA\UserExternal;
+
/**
* User authentication against an IMAP mail server
@@ -17,7 +19,7 @@
* @license http://www.gnu.org/licenses/agpl AGPL
* @link http://github.com/owncloud/apps
*/
-class OC_User_IMAP extends \OCA\user_external\Base {
+class IMAP extends Base {
private $mailbox;
private $port;
private $sslmode;
@@ -70,7 +72,7 @@ class OC_User_IMAP extends \OCA\user_external\Base {
$uid = $pieces[0];
}
} else {
- OC::$server->getLogger()->error(
+ \OC::$server->getLogger()->error(
'ERROR: User has a wrong domain! Expecting: '.$this->domain,
['app' => 'user_external']
);
@@ -105,7 +107,7 @@ class OC_User_IMAP extends \OCA\user_external\Base {
$this->storeUser($uid, $groups);
return $uid;
} else {
- OC::$server->getLogger()->error(
+ \OC::$server->getLogger()->error(
'ERROR: Could not connect to imap server via curl: '.curl_error($ch),
['app' => 'user_external']
);
diff --git a/lib/smb.php b/lib/SMB.php
similarity index 94%
rename from lib/smb.php
rename to lib/SMB.php
index 49d785d..f5fbe32 100644
--- a/lib/smb.php
+++ b/lib/SMB.php
@@ -5,6 +5,7 @@
* later.
* See the COPYING-README file.
*/
+namespace OCA\UserExternal;
/**
* User authentication via samba (smbclient)
@@ -15,7 +16,7 @@
* @license http://www.gnu.org/licenses/agpl AGPL
* @link http://github.com/owncloud/apps
*/
-class OC_User_SMB extends \OCA\user_external\Base{
+class SMB extends Base{
private $host;
const SMBCLIENT = 'smbclient -L';
@@ -42,7 +43,7 @@ class OC_User_SMB extends \OCA\user_external\Base{
$command = self::SMBCLIENT.' '.escapeshellarg('//' . $this->host . '/dummy').' -U '.$uidEscaped.'%'.$password;
$lastline = exec($command, $output, $retval);
if ($retval === 127) {
- OC::$server->getLogger()->error(
+ \OC::$server->getLogger()->error(
'ERROR: smbclient executable missing',
['app' => 'user_external']
);
@@ -55,7 +56,7 @@ class OC_User_SMB extends \OCA\user_external\Base{
goto login;
} else if ($retval !== 0) {
//some other error
- OC::$server->getLogger()->error(
+ \OC::$server->getLogger()->error(
'ERROR: smbclient error: ' . trim($lastline),
['app' => 'user_external']
);
diff --git a/lib/ssh.php b/lib/SSH.php
similarity index 92%
rename from lib/ssh.php
rename to lib/SSH.php
index 2461b06..5f7212c 100644
--- a/lib/ssh.php
+++ b/lib/SSH.php
@@ -5,6 +5,7 @@
* later.
* See the COPYING-README file.
*/
+namespace OCA\UserExternal;
/**
* User authentication against a SSH server
@@ -17,9 +18,9 @@
*/
-class OC_User_SSH extends \OCA\user_external\Base {
+class SSH extends Base {
private $host;
- private $port;
+ private $port;
/**
* Create a new SSH authentication provider
@@ -43,7 +44,7 @@ class OC_User_SSH extends \OCA\user_external\Base {
*/
public function checkPassword($uid, $password) {
if (!extension_loaded('ssh2')) {
- OC::$server->getLogger()->error(
+ \OC::$server->getLogger()->error(
'ERROR: php-ssh2 PECL module missing',
['app' => 'user_external']
);
diff --git a/lib/webdavauth.php b/lib/WebDavAuth.php
similarity index 78%
rename from lib/webdavauth.php
rename to lib/WebDavAuth.php
index 747f9ac..33c8ed0 100644
--- a/lib/webdavauth.php
+++ b/lib/WebDavAuth.php
@@ -6,7 +6,7 @@
* See the COPYING-README file.
*/
-namespace OCA\user_external;
+namespace OCA\UserExternal;
class WebDavAuth extends Base {
@@ -28,14 +28,14 @@ class WebDavAuth extends Base {
public function checkPassword($uid, $password) {
$arr = explode('://', $this->webDavAuthUrl, 2);
if( ! isset($arr) OR count($arr) !== 2) {
- OC::$server->getLogger()->error('ERROR: Invalid WebdavUrl: "'.$this->webDavAuthUrl.'" ', ['app' => 'user_external']);
+ \OC::$server->getLogger()->error('ERROR: Invalid WebdavUrl: "'.$this->webDavAuthUrl.'" ', ['app' => 'user_external']);
return false;
}
list($protocol, $path) = $arr;
$url= $protocol.'://'.urlencode($uid).':'.urlencode($password).'@'.$path;
$headers = get_headers($url);
if($headers === false) {
- OC::$server->getLogger()->error('ERROR: Not possible to connect to WebDAV Url: "'.$protocol.'://'.$path.'" ', ['app' => 'user_external']);
+ \OC::$server->getLogger()->error('ERROR: Not possible to connect to WebDAV Url: "'.$protocol.'://'.$path.'" ', ['app' => 'user_external']);
return false;
}
diff --git a/lib/xmpp.php b/lib/XMPP.php
similarity index 96%
rename from lib/xmpp.php
rename to lib/XMPP.php
index 3d787ce..c46f888 100644
--- a/lib/xmpp.php
+++ b/lib/XMPP.php
@@ -5,6 +5,7 @@
* later.
* See the COPYING-README file.
*/
+namespace OCA\UserExternal;
/**
* User authentication against a XMPP Prosody MySQL database
@@ -14,7 +15,7 @@
* @author Sebastian Sterk https://wiuwiu.de/Imprint
* @license http://www.gnu.org/licenses/agpl AGPL
*/
-class OC_User_XMPP extends \OCA\user_external\Base {
+class XMPP extends Base {
private $host;
private $xmppDb;
private $xmppDbUser;
@@ -96,7 +97,7 @@ class OC_User_XMPP extends \OCA\user_external\Base {
}
public function checkPassword($uid, $password){
- $pdo = new PDO("mysql:host=$this->host;dbname=$this->xmppDb", $this->xmppDbUser, $this->xmppDbPassword);
+ $pdo = new \PDO("mysql:host=$this->host;dbname=$this->xmppDb", $this->xmppDbUser, $this->xmppDbPassword);
if(isset($uid)
&& isset($password)) {
if(!filter_var($uid, FILTER_VALIDATE_EMAIL)