-
Andy Summers authoredAndy Summers authored
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
PreauthUserDetailsProvider.php 2.13 KiB
<?php
namespace edu\wisc\doit\uwphps\preauth;
use edu\wisc\doit\uwphps\UserDetailsProvider;
use edu\wisc\doit\uwphps\UWUserDetails;
/**
* PreauthUserDetailsProvider is an implementation of {@link UserDetailsProvider} for loading users authenticated
* with UW-Madison login.
*
* {@see FederatedPreauthUserDetailsProvider} for loading users authenticated through UW-System Federated login.
*/
class PreauthUserDetailsProvider extends UserDetailsProvider
{
// Constants defining common header values
const PVI = 'wiscEduPVI';
const FULL_NAME = 'cn';
const EMAIL = 'mail';
const UDDS = 'wiscEduUDDS';
const ISIS_EMPLID = 'wiscEduIsisEmplid';
const FIRST_NAME = 'givenName';
const LAST_NAME = 'sn';
/**
* {@inheritdoc}
*/
public function loadUser()
{
// Return null if no Shib session is found
if ($this->httpHeaders && !getenv(static::SHIB_SESSION_ID_HTTP) ||
!$this->httpHeaders && !getenv(static::SHIB_SESSION_ID)) {
return null;
}
if ($this->httpHeaders) {
$userDetails = new UWUserDetails(
getenv($this->mapAttribute(static::EPPN)),
getenv($this->mapAttribute(static::PVI)),
getenv($this->mapAttribute(static::FULL_NAME)),
getenv($this->mapAttribute(static::UDDS)),
getenv($this->mapAttribute(static::EPPN)),
getenv($this->mapAttribute(static::SOURCE)),
getenv($this->mapAttribute(static::ISIS_EMPLID)),
getenv($this->mapAttribute(static::FIRST_NAME)),
getenv($this->mapAttribute(static::LAST_NAME))
);
} else {
$userDetails = new UWUserDetails(
getenv(static::EPPN),
getenv(static::PVI),
getenv(static::FULL_NAME),
getenv(static::UDDS),
getenv(static::EPPN),
getenv(static::SOURCE),
getenv(static::ISIS_EMPLID),
getenv(static::FIRST_NAME),
getenv(static::LAST_NAME)
);
}
return $userDetails;
}
}