ShibSessionVars.php in Shibboleth Authentication 8
File
src/Login/ShibSessionVars.php
View source
<?php
namespace Drupal\shib_auth\Login;
class ShibSessionVars {
private $session_id;
private $targeted_id;
private $email;
private $idp;
private $entitlement;
private $affiliation;
public function __construct($config) {
$this->session_id = self::fixModRewriteIssues('Shib-Session-ID');
$this->targeted_id = self::fixModRewriteIssues($config
->get('server_variable_username'));
$this->email = self::fixModRewriteIssues($config
->get('server_variable_email'));
$this->idp = self::fixModRewriteIssues('Shib-Identity-Provider');
$this->entitlement = self::fixModRewriteIssues('entitlement');
$this->affiliation = self::fixModRewriteIssues('affiliation');
}
public function getSessionId() {
return $this->session_id;
}
public function getTargetedId() {
return $this->targeted_id;
}
public function getEmail() {
return $this->email;
}
public function getIdp() {
return $this->idp;
}
public function getEntitlement() {
return $this->entitlement;
}
public function getAffiliation() {
return $this->affiliation;
}
private static function fixModRewriteIssues($var) {
if (!$var) {
return NULL;
}
if (array_key_exists($var, $_SERVER)) {
return $_SERVER[$var];
}
$var = strtoupper($var);
if (array_key_exists($var, $_SERVER)) {
return $_SERVER[$var];
}
$var = "REDIRECT_" . str_replace('-', '_', $var);
if (array_key_exists($var, $_SERVER)) {
return $_SERVER[$var];
}
$var = strtoupper($var);
$var = preg_replace('/^REDIRECT/', 'HTTP', $var);
if (array_key_exists($var, $_SERVER)) {
return $_SERVER[$var];
}
return NULL;
}
}