Skip to content

Commit

Permalink
Add get username parser
Browse files Browse the repository at this point in the history
  • Loading branch information
karatakis committed Sep 27, 2019
1 parent addf6f0 commit 21c04b2
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions Limesurvey-SAML-Authentication/AuthSAML.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,20 +240,29 @@ public function get_saml_instance() {
public function getUserName() {

if ($this->_username == null) {
$ssp = $this->get_saml_instance();
$attributes = $this->ssp->getAttributes();
if (!empty($attributes)) {
$saml_uid_mapping = $this->get('saml_uid_mapping', null, null, 'uid');
if (array_key_exists($saml_uid_mapping , $attributes) && !empty($attributes[$saml_uid_mapping])) {
$username = $attributes[$saml_uid_mapping][0];
$this->setUsername($username);
}
$username = $this->getUserNameAttribute();
if ($username !== false) {
$this->setUsername($username);
}
}

return $this->_username;
}

public function getUserNameAttribute()
{
$ssp = $this->get_saml_instance();
$attributes = $this->ssp->getAttributes();
if (!empty($attributes)) {
$saml_uid_mapping = $this->get('saml_uid_mapping', null, null, 'uid');
if (array_key_exists($saml_uid_mapping, $attributes) && !empty($attributes[$saml_uid_mapping])) {
$username = $attributes[$saml_uid_mapping][0];
return $username;
}
}
return false;
}

public function getUserCommonName() {

$name = '';
Expand Down

0 comments on commit 21c04b2

Please sign in to comment.