Skip to content

Commit

Permalink
Added option "cas_disable_for_domains"
Browse files Browse the repository at this point in the history
  • Loading branch information
xaionaro committed Oct 7, 2016
1 parent 02b1bb3 commit 3c6b939
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
16 changes: 16 additions & 0 deletions cas_authn/cas_authn.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ function init() {

// load plugin configuration
$this->load_config();

if ($this->isDisabled()) {
return;
}

// add application hooks
$this->add_hook('startup', array($this, 'startup'));
Expand All @@ -42,6 +46,18 @@ function init() {
$this->add_hook('template_object_loginform', array($this, 'add_cas_login_html'));
}

function isDisabled() {
$cfg = rcmail::get_instance()->config->all();
if (is_array($cfg['cas_disable_for_domains'])) {
foreach ($cfg['cas_disable_for_domains'] as $domain_pattern) {
if (preg_match($domain_pattern, $_SERVER['SERVER_NAME'])) {
return true;
}
}
}
return false;
}

/**
* Handle plugin-specific actions
* These actions are handled at the startup hook rather than registered as
Expand Down
4 changes: 4 additions & 0 deletions cas_authn/config.inc.php.dist
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
// the CAS login URL. This means nobody will ever see the RC login page.
$rcmail_config['cas_force'] = false;

// Disable this plugin for 'SERVER_NAME' that matches to a pattern from the
// array:
$rcmail_config['cas_disable_for_domains'] = array("/nocas\.example\.com/", "/.*\.nocas\.example\.com/");

// whether to act as a CAS proxy. If set to true, a proxy ticket will be
// retrieved from the CAS server to be used as password for logging into
// the IMAP server. This is the preferred method of authenticating
Expand Down

0 comments on commit 3c6b939

Please sign in to comment.