Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retrieve Required Info from Basic Authentication Attributes #28

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions AuthCAS/AuthCAS.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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);
Expand Down