diff --git a/plugins/kolab_2fa/config.inc.php.dist b/plugins/kolab_2fa/config.inc.php.dist --- a/plugins/kolab_2fa/config.inc.php.dist +++ b/plugins/kolab_2fa/config.inc.php.dist @@ -121,4 +121,5 @@ 'clientid' => '123456', 'apikey' => '', // 'hosts' => array('api.myhost1.com','api2.myhost.com'), + 'use_https' => true, // connect via https if set to true ); \ No newline at end of file diff --git a/plugins/kolab_2fa/kolab_2fa.php b/plugins/kolab_2fa/kolab_2fa.php --- a/plugins/kolab_2fa/kolab_2fa.php +++ b/plugins/kolab_2fa/kolab_2fa.php @@ -280,14 +280,19 @@ } /** - * Load driver class for the given method + * Load driver class for the given authentication factor + * + * @param string $factor Factor identifier (:) + * @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 @@ 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 @@ $driver->username = $rcmail->get_user_name(); } - $this->drivers[$method] = $driver; + $this->drivers[$factor] = $driver; return $driver; } catch (Exception $e) { diff --git a/plugins/kolab_2fa/lib/Kolab2FA/Driver/Yubikey.php b/plugins/kolab_2fa/lib/Kolab2FA/Driver/Yubikey.php --- a/plugins/kolab_2fa/lib/Kolab2FA/Driver/Yubikey.php +++ b/plugins/kolab_2fa/lib/Kolab2FA/Driver/Yubikey.php @@ -27,12 +27,6 @@ { public $method = 'yubikey'; - protected $config = array( - 'clientid' => '42', - 'apikey' => 'FOOBAR=', - 'hosts' => null, - ); - protected $backend; /** @@ -57,6 +51,10 @@ 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 @@ } } - // rcube::console('VERIFY TOTP', $this->username, $keyid, $code, $pass); + // rcube::console('VERIFY Yubikey', $this->username, $keyid, $code, $pass); return $pass; }