20 const STAGEID =
'sspmod_core_Auth_UserPassOrgBase.state';
26 const AUTHID =
'sspmod_core_Auth_UserPassOrgBase.AuthId';
32 const ORGID =
'sspmod_core_Auth_UserPassOrgBase.SelectedOrg';
71 assert(
'is_array($info)');
72 assert(
'is_array($config)');
78 if (isset(
$config[
'remember.username.enabled'])) {
79 $this->rememberUsernameEnabled = (bool)
$config[
'remember.username.enabled'];
80 unset(
$config[
'remember.username.enabled']);
82 if (isset(
$config[
'remember.username.checked'])) {
83 $this->rememberUsernameChecked = (bool)
$config[
'remember.username.checked'];
84 unset(
$config[
'remember.username.checked']);
87 $this->usernameOrgMethod =
'none';
104 assert(
'in_array($usernameOrgMethod, array("none", "allow", "force"), TRUE)');
150 assert(
'is_array($state)');
177 abstract protected function login($username,
$password, $organization);
206 assert(
'is_string($authStateId)');
207 assert(
'is_string($username)');
208 assert(
'is_string($password)');
209 assert(
'is_string($organization)');
215 assert(
'array_key_exists(self::AUTHID, $state)');
218 throw new Exception(
'Could not find authentication source with id ' .
$state[self::AUTHID]);
221 $orgMethod =
$source->getUsernameOrgMethod();
222 if ($orgMethod !==
'none') {
223 $tmp = explode(
'@', $username, 2);
224 if (count($tmp) === 2) {
226 $organization = $tmp[1];
228 if ($orgMethod ===
'force') {
239 $state[self::ORGID] = $organization;
240 $state[
'PersistentAuthData'][] = self::ORGID;
257 assert(
'is_string($authStateId)');
263 assert(
'array_key_exists(self::AUTHID, $state)');
266 throw new Exception(
'Could not find authentication source with id ' .
$state[self::AUTHID]);
269 $orgMethod =
$source->getUsernameOrgMethod();
270 if ($orgMethod ===
'force') {
274 return $source->getOrganizations();
static handleLogin($authStateId, $username, $password, $organization)
Handle login request.
if(!array_key_exists('StateId', $_REQUEST)) $id
static redirectTrustedURL($url, $parameters=array())
This function redirects to the specified URL without performing any security checks.
const AUTHID
The key of the AuthId field in the state.
static getModuleURL($resource, array $parameters=array())
Get absolute URL to a specified module resource.
if(!array_key_exists('stateid', $_REQUEST)) $state
Handle linkback() response from LinkedIn.
static listOrganizations($authStateId)
Get available organizations.
getRememberUsernameEnabled()
Getter for the authsource config option remember.username.enabled.
const ORGID
The key of the OrgId field in the state, identifies which org was selected.
getOrganizations()
Retrieve list of organizations.
authenticate(&$state)
Initialize login.
static loadState($id, $stage, $allowMissing=false)
Retrieve saved state.
Create styles array
The data for the language used.
login($username, $password, $organization)
Attempt to log in using the given username, password and organization.
getRememberUsernameChecked()
Getter for the authsource config option remember.username.checked.
setUsernameOrgMethod($usernameOrgMethod)
Configure the way organizations as part of the username is handled.
$usernameOrgMethod
What way do we handle the organization as part of the username.
static completeAuth(&$state)
Complete authentication.
static getById($authId, $type=null)
Retrieve authentication source.
__construct($info, &$config)
Constructor for this authentication source.
getUsernameOrgMethod()
Retrieve the way organizations as part of the username should be handled.
if(!array_key_exists('AuthState', $_REQUEST)) $authStateId
static saveState(&$state, $stage, $rawId=false)
Save the state.
const STAGEID
The string used to identify our states.