diff --git a/AuthCAS/AuthCAS.php b/AuthCAS/AuthCAS.php index f5485eb..3f27e20 100644 --- a/AuthCAS/AuthCAS.php +++ b/AuthCAS/AuthCAS.php @@ -70,8 +70,9 @@ class AuthCAS extends AuthPluginBase ), 'casMailAttr' => array( 'type' => 'string', - 'label' => 'CAS attribute for mail', - 'default' => 'mail' + 'label' => 'CAS attribute for mail (or @domain))', + 'default' => 'mail', + 'help' => 'If your CAS server doesn\'t return an email address attribute, specify the @domain, and it will be combined with the username.' ), 'server' => array( 'type' => 'string', @@ -435,8 +436,20 @@ public function newUserSession() // disable SSL validation of the CAS server //phpCAS::setNoCasServerValidation(); $cas_fullname = phpCAS::getAttribute($this->get('casFullnameAttr')); + $cas_login = phpCAS::getAttribute($this->get('casLoginAttr')); + if (empty($cas_login)) { + $cas_login = phpCAS::getUser(); + } + $cas_mail = phpCAS::getAttribute($this->get('casMailAttr')); + if (empty($cas_mail)) { + // If attribute is empty, check if casMailAttr contains a @domain + if (strpos($this->get('casMailAttr'), '@') == 0) { + $cas_domain = $this->get('casMailAttr'); + $cas_mail = $cas_login . $cas_domain; + } + } } catch (Exception $e) { $this->setAuthFailure(self::ERROR_USERNAME_INVALID);