You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
67 lines
1.4 KiB
PHTML
67 lines
1.4 KiB
PHTML
4 years ago
|
<?php
|
||
|
|
||
|
class mailu extends rcube_plugin
|
||
|
{
|
||
|
|
||
|
function init()
|
||
|
{
|
||
|
$this->add_hook('startup', array($this, 'startup'));
|
||
|
$this->add_hook('authenticate', array($this, 'authenticate'));
|
||
|
$this->add_hook('login_after', array($this, 'login'));
|
||
|
$this->add_hook('login_failed', array($this, 'login_failed'));
|
||
|
$this->add_hook('logout_after', array($this, 'logout'));
|
||
|
}
|
||
|
|
||
|
function startup($args)
|
||
|
{
|
||
|
if (empty($_SESSION['user_id'])) {
|
||
3 years ago
|
$args['action'] = 'login';
|
||
|
}
|
||
|
|
||
4 years ago
|
return $args;
|
||
|
}
|
||
|
|
||
|
function authenticate($args)
|
||
|
{
|
||
3 years ago
|
if (!array_key_exists('HTTP_X_REMOTE_USER', $_SERVER) or !array_key_exists('HTTP_X_REMOTE_USER_TOKEN', $_SERVER)) {
|
||
3 years ago
|
if ($_SERVER['PHP_SELF'] == '/sso.php') {
|
||
|
header('HTTP/1.0 403 Forbidden');
|
||
|
print('mailu sso failure');
|
||
|
} else {
|
||
|
header('Location: sso.php');
|
||
|
}
|
||
|
exit();
|
||
4 years ago
|
}
|
||
3 years ago
|
|
||
4 years ago
|
$args['user'] = $_SERVER['HTTP_X_REMOTE_USER'];
|
||
|
$args['pass'] = $_SERVER['HTTP_X_REMOTE_USER_TOKEN'];
|
||
|
|
||
|
$args['cookiecheck'] = false;
|
||
|
$args['valid'] = true;
|
||
|
|
||
|
return $args;
|
||
|
}
|
||
|
|
||
3 years ago
|
// Redirect to global SSO logout path.
|
||
|
function logout($args)
|
||
|
{
|
||
4 years ago
|
$this->load_config();
|
||
|
$sso_logout_url = rcmail::get_instance()->config->get('sso_logout_url');
|
||
3 years ago
|
header('Location: ' . $sso_logout_url, true);
|
||
|
exit();
|
||
4 years ago
|
}
|
||
|
|
||
|
function login($args)
|
||
|
{
|
||
3 years ago
|
header('Location: index.php');
|
||
|
exit();
|
||
4 years ago
|
}
|
||
3 years ago
|
|
||
4 years ago
|
function login_failed($args)
|
||
|
{
|
||
3 years ago
|
header('Location: sso.php');
|
||
|
exit();
|
||
4 years ago
|
}
|
||
|
|
||
|
}
|