Fix driver initialization with config properties for the right method (T1784)
Summary: Proposed fix for the bug reported in T1784 The method kolab_2fa::get_driver() is called with the full factor ID (<method>:<uuid>) and therefore fails to retrieve the right properties from plugin config. This change fixes this at the right place. Reviewers: machniak Reviewed By: machniak Subscribers: jh23453 Differential Revision: https://git.kolab.org/D242
This commit is contained in:
parent
4889334d13
commit
db2d3bc800
3 changed files with 17 additions and 13 deletions
|
@ -121,4 +121,5 @@ $config['kolab_2fa_yubikey'] = array(
|
|||
'clientid' => '123456',
|
||||
'apikey' => '<your-server-api-key>',
|
||||
// 'hosts' => array('api.myhost1.com','api2.myhost.com'),
|
||||
'use_https' => true, // connect via https if set to true
|
||||
);
|
|
@ -280,14 +280,19 @@ class kolab_2fa extends rcube_plugin
|
|||
}
|
||||
|
||||
/**
|
||||
* Load driver class for the given method
|
||||
* Load driver class for the given authentication factor
|
||||
*
|
||||
* @param string $factor Factor identifier (<method>:<id>)
|
||||
* @return Kolab2FA\Driver\Base
|
||||
*/
|
||||
public function get_driver($method)
|
||||
public function get_driver($factor)
|
||||
{
|
||||
list($method) = explode(':', $factor, 2);
|
||||
|
||||
$rcmail = rcmail::get_instance();
|
||||
|
||||
if ($this->drivers[$method]) {
|
||||
return $this->drivers[$method];
|
||||
if ($this->drivers[$factor]) {
|
||||
return $this->drivers[$factor];
|
||||
}
|
||||
|
||||
$config = $rcmail->config->get('kolab_2fa_' . $method, array());
|
||||
|
@ -300,7 +305,7 @@ class kolab_2fa extends rcube_plugin
|
|||
try {
|
||||
// TODO: use external auth service if configured
|
||||
|
||||
$driver = \Kolab2FA\Driver\Base::factory($method, $config);
|
||||
$driver = \Kolab2FA\Driver\Base::factory($factor, $config);
|
||||
|
||||
// attach storage
|
||||
$driver->storage = $this->get_storage();
|
||||
|
@ -309,7 +314,7 @@ class kolab_2fa extends rcube_plugin
|
|||
$driver->username = $rcmail->get_user_name();
|
||||
}
|
||||
|
||||
$this->drivers[$method] = $driver;
|
||||
$this->drivers[$factor] = $driver;
|
||||
return $driver;
|
||||
}
|
||||
catch (Exception $e) {
|
||||
|
|
|
@ -27,12 +27,6 @@ class Yubikey extends Base
|
|||
{
|
||||
public $method = 'yubikey';
|
||||
|
||||
protected $config = array(
|
||||
'clientid' => '42',
|
||||
'apikey' => 'FOOBAR=',
|
||||
'hosts' => null,
|
||||
);
|
||||
|
||||
protected $backend;
|
||||
|
||||
/**
|
||||
|
@ -57,6 +51,10 @@ class Yubikey extends Base
|
|||
if (!empty($this->config['hosts'])) {
|
||||
$this->backend->setHosts((array)$this->config['hosts']);
|
||||
}
|
||||
|
||||
if (isset($this->config['use_https'])) {
|
||||
$this->backend->setUseSecure((bool)$this->config['use_https']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -84,7 +82,7 @@ class Yubikey extends Base
|
|||
}
|
||||
}
|
||||
|
||||
// rcube::console('VERIFY TOTP', $this->username, $keyid, $code, $pass);
|
||||
// rcube::console('VERIFY Yubikey', $this->username, $keyid, $code, $pass);
|
||||
return $pass;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue