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)');
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') {
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();
if(!array_key_exists('stateid', $_REQUEST)) $state
Handle linkback() response from LinkedIn.
An exception for terminatinating execution or to throw for unit testing.
static getModuleURL($resource, array $parameters=array())
Get absolute URL to a specified module resource.
static redirectTrustedURL($url, $parameters=array())
This function redirects to the specified URL without performing any security checks.
static getById($authId, $type=null)
Retrieve authentication source.
static completeAuth(&$state)
Complete authentication.
static saveState(&$state, $stage, $rawId=false)
Save the state.
static loadState($id, $stage, $allowMissing=false)
Retrieve saved state.
const AUTHID
The key of the AuthId field in the state.
static listOrganizations($authStateId)
Get available organizations.
login($username, $password, $organization)
Attempt to log in using the given username, password and organization.
getOrganizations()
Retrieve list of organizations.
authenticate(&$state)
Initialize login.
getRememberUsernameChecked()
Getter for the authsource config option remember.username.checked.
const STAGEID
The string used to identify our states.
__construct($info, &$config)
Constructor for this authentication source.
getUsernameOrgMethod()
Retrieve the way organizations as part of the username should be handled.
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.
$usernameOrgMethod
What way do we handle the organization as part of the username.
setUsernameOrgMethod($usernameOrgMethod)
Configure the way organizations as part of the username is handled.
static handleLogin($authStateId, $username, $password, $organization)
Handle login request.
if(!array_key_exists('StateId', $_REQUEST)) $id
if(!array_key_exists('AuthState', $_REQUEST)) $authStateId