migration to nextcloud app v3.0.0
Signed-off-by: Biermair Martin <martin.biermair@wimbergerhaus.at>
This commit is contained in:
26
lib/AppInfo/Application.php
Normal file
26
lib/AppInfo/Application.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace OCA\UserExternal\AppInfo;
|
||||
|
||||
use OCP\AppFramework\App;
|
||||
use OCP\AppFramework\Bootstrap\IBootContext;
|
||||
use OCP\AppFramework\Bootstrap\IBootstrap;
|
||||
use OCP\AppFramework\Bootstrap\IRegistrationContext;
|
||||
use OCP\Notification\IManager;
|
||||
use OCP\User\Events;
|
||||
|
||||
class Application extends App implements IBootstrap {
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct('user_external');
|
||||
}
|
||||
|
||||
public function register(IRegistrationContext $context): void {
|
||||
}
|
||||
|
||||
public function boot(IBootContext $context): void {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -7,7 +7,7 @@
|
||||
* later.
|
||||
* See the COPYING-README file.
|
||||
*/
|
||||
namespace OCA\user_external;
|
||||
namespace OCA\UserExternal;
|
||||
|
||||
/**
|
||||
* Base class for external auth implementations that stores users
|
||||
@@ -6,7 +6,9 @@
|
||||
* See the COPYING-README file.
|
||||
*/
|
||||
|
||||
class OC_User_BasicAuth extends \OCA\user_external\Base {
|
||||
namespace OCA\UserExternal;
|
||||
|
||||
class BasicAuth extends Base {
|
||||
|
||||
private $authUrl;
|
||||
|
||||
@@ -36,14 +38,14 @@ class OC_User_BasicAuth extends \OCA\user_external\Base {
|
||||
);
|
||||
$canary = get_headers($this->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']
|
||||
);
|
||||
@@ -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']
|
||||
);
|
||||
@@ -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']
|
||||
);
|
||||
@@ -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']
|
||||
);
|
||||
@@ -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']
|
||||
);
|
||||
@@ -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;
|
||||
|
||||
}
|
||||
@@ -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)
|
||||
Reference in New Issue
Block a user