👌 IMPROVE: add SSH port as possible parameter
Signed-off-by: Jonas Sulzer <jonas@violoncello.ch>
This commit is contained in:
@@ -156,14 +156,14 @@ SSH
|
|||||||
Authenticates users via SSH. You can use any SSH2 server, but it must accept password authentication.
|
Authenticates users via SSH. You can use any SSH2 server, but it must accept password authentication.
|
||||||
|
|
||||||
### Configuration
|
### Configuration
|
||||||
The only supported parameter is the hostname of the remote machine.
|
The supported parameters are the hostname and the port (default `22`) of the remote machine.
|
||||||
|
|
||||||
Add the following to your `config.php`:
|
Add the following to your `config.php`:
|
||||||
|
|
||||||
'user_backends' => array(
|
'user_backends' => array(
|
||||||
array(
|
array(
|
||||||
'class' => 'OC_User_SSH',
|
'class' => 'OC_User_SSH',
|
||||||
'arguments' => array('127.0.0.1'),
|
'arguments' => array('127.0.0.1', '22'),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
|
|||||||
@@ -19,15 +19,17 @@
|
|||||||
|
|
||||||
class OC_User_SSH extends \OCA\user_external\Base {
|
class OC_User_SSH extends \OCA\user_external\Base {
|
||||||
private $host;
|
private $host;
|
||||||
|
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) {
|
public function __construct($host, $port = 22) {
|
||||||
parent::__construct($host);
|
parent::__construct($host);
|
||||||
$this->host =$host;
|
$this->host = $host;
|
||||||
|
$this->port = $port;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -40,7 +42,7 @@ class OC_User_SSH extends \OCA\user_external\Base {
|
|||||||
* @return true/false
|
* @return true/false
|
||||||
*/
|
*/
|
||||||
public function checkPassword($uid, $password) {
|
public function checkPassword($uid, $password) {
|
||||||
$connection = ssh2_connect($this->host);
|
$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);
|
||||||
return $uid;
|
return $uid;
|
||||||
|
|||||||
Reference in New Issue
Block a user