diff options
Diffstat (limited to 'plugins/http_authentication')
-rw-r--r-- | plugins/http_authentication/config.inc.php.dist | 9 | ||||
-rw-r--r-- | plugins/http_authentication/http_authentication.php | 11 | ||||
-rw-r--r-- | plugins/http_authentication/tests/HttpAuthentication.php | 23 |
3 files changed, 42 insertions, 1 deletions
diff --git a/plugins/http_authentication/config.inc.php.dist b/plugins/http_authentication/config.inc.php.dist new file mode 100644 index 000000000..0d798a586 --- /dev/null +++ b/plugins/http_authentication/config.inc.php.dist @@ -0,0 +1,9 @@ +<?php + +// HTTP Basic Authentication Plugin options +// ---------------------------------------- +// Default mail host to log-in using user/password from HTTP Authentication. +// This is useful if the users are free to choose arbitrary mail hosts (or +// from a list), but have one host they usually want to log into. +// Unlike $rcmail_config['default_host'] this must be a string! +$rcmail_config['http_authentication_host'] = ''; diff --git a/plugins/http_authentication/http_authentication.php b/plugins/http_authentication/http_authentication.php index a14b5cbcc..57227cb03 100644 --- a/plugins/http_authentication/http_authentication.php +++ b/plugins/http_authentication/http_authentication.php @@ -11,6 +11,8 @@ * * See logout.html (in this directory) for an example how HTTP auth can be cleared. * + * For other configuration options, see config.inc.php.dist! + * * @version @package_version@ * @license GNU GPLv3+ * @author Thomas Bruederli @@ -36,7 +38,7 @@ class http_authentication extends rcube_plugin $args['action'] = 'login'; } // Set user password in session (see shutdown() method for more info) - else if (!empty($_SESSION['user_id']) && empty($_SESION['password'])) { + else if (!empty($_SESSION['user_id']) && empty($_SESSION['password'])) { $_SESSION['password'] = $rcmail->encrypt($_SERVER['PHP_AUTH_PW']); } } @@ -46,6 +48,13 @@ class http_authentication extends rcube_plugin function authenticate($args) { + // Load plugin's config file + $this->load_config(); + + $host = rcmail::get_instance()->config->get('http_authentication_host'); + if (is_string($host) && trim($host) !== '') + $args['host'] = rcube_utils::idn_to_ascii(rcube_utils::parse_host($host)); + // Allow entering other user data in login form, // e.g. after log out (#1487953) if (!empty($args['user'])) { diff --git a/plugins/http_authentication/tests/HttpAuthentication.php b/plugins/http_authentication/tests/HttpAuthentication.php new file mode 100644 index 000000000..c17236821 --- /dev/null +++ b/plugins/http_authentication/tests/HttpAuthentication.php @@ -0,0 +1,23 @@ +<?php + +class HttpAuthentication_Plugin extends PHPUnit_Framework_TestCase +{ + + function setUp() + { + include_once dirname(__FILE__) . '/../http_authentication.php'; + } + + /** + * Plugin object construction test + */ + function test_constructor() + { + $rcube = rcube::get_instance(); + $plugin = new http_authentication($rcube->api); + + $this->assertInstanceOf('http_authentication', $plugin); + $this->assertInstanceOf('rcube_plugin', $plugin); + } +} + |