40
lib/ssh.php
40
lib/ssh.php
@@ -22,33 +22,33 @@ class OC_User_SSH extends \OCA\user_external\Base {
|
|||||||
private $port;
|
private $port;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new SSH authentication provider
|
* Create a new SSH authentication provider
|
||||||
*
|
*
|
||||||
* @param string $host Hostname or IP address of SSH servr
|
* @param string $host Hostname or IP address of SSH servr
|
||||||
*/
|
*/
|
||||||
public function __construct($host, $port = 22) {
|
public function __construct($host, $port = 22) {
|
||||||
parent::__construct($host);
|
parent::__construct($host);
|
||||||
$this->host = $host;
|
$this->host = $host;
|
||||||
$this->port = $port;
|
$this->port = $port;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the password is correct without logging in
|
* Check if the password is correct without logging in
|
||||||
* Requires the php-ssh2 pecl extension
|
* Requires the php-ssh2 pecl extension
|
||||||
*
|
*
|
||||||
* @param string $uid The username
|
* @param string $uid The username
|
||||||
* @param string $password The password
|
* @param string $password The password
|
||||||
*
|
*
|
||||||
* @return true/false
|
* @return true/false
|
||||||
*/
|
*/
|
||||||
public function checkPassword($uid, $password) {
|
public function checkPassword($uid, $password) {
|
||||||
if (!extension_loaded('ssh2')) {
|
if (!extension_loaded('ssh2')) {
|
||||||
OC::$server->getLogger()->error(
|
OC::$server->getLogger()->error(
|
||||||
'ERROR: php-ssh2 PECL module missing',
|
'ERROR: php-ssh2 PECL module missing',
|
||||||
['app' => 'user_external']
|
['app' => 'user_external']
|
||||||
);
|
);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$connection = ssh2_connect($this->host, $this->port);
|
$connection = ssh2_connect($this->host, $this->port);
|
||||||
if (ssh2_auth_password($connection, $uid, $password)) {
|
if (ssh2_auth_password($connection, $uid, $password)) {
|
||||||
$this->storeUser($uid);
|
$this->storeUser($uid);
|
||||||
|
|||||||
Reference in New Issue
Block a user