ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
loginuserpassorg.php
Go to the documentation of this file.
1 <?php
2 
12 // Retrieve the authentication state
13 if (!array_key_exists('AuthState', $_REQUEST)) {
14  throw new SimpleSAML_Error_BadRequest('Missing AuthState parameter.');
15 }
16 $authStateId = $_REQUEST['AuthState'];
18 
20 if ($source === NULL) {
21  throw new Exception('Could not find authentication source with id ' . $state[sspmod_core_Auth_UserPassOrgBase::AUTHID]);
22 }
23 
25 
26 if (array_key_exists('username', $_REQUEST)) {
27  $username = $_REQUEST['username'];
28 } elseif ($source->getRememberUsernameEnabled() && array_key_exists($source->getAuthId() . '-username', $_COOKIE)) {
29  $username = $_COOKIE[$source->getAuthId() . '-username'];
30 } elseif (isset($state['core:username'])) {
31  $username = (string)$state['core:username'];
32 } else {
33  $username = '';
34 }
35 
36 if (array_key_exists('password', $_REQUEST)) {
37  $password = $_REQUEST['password'];
38 } else {
39  $password = '';
40 }
41 
42 if (array_key_exists('organization', $_REQUEST)) {
43  $organization = $_REQUEST['organization'];
44 } elseif (isset($state['core:organization'])) {
45  $organization = (string)$state['core:organization'];
46 } else {
47  $organization = '';
48 }
49 
50 $errorCode = NULL;
51 $errorParams = NULL;
52 if ($organizations === NULL || !empty($organization)) {
53  if (!empty($username) && !empty($password)) {
54 
55  if ($source->getRememberUsernameEnabled()) {
57  $params = $sessionHandler->getCookieParams();
58  $params['expire'] = time();
59  $params['expire'] += (isset($_REQUEST['remember_username']) && $_REQUEST['remember_username'] == 'Yes' ? 31536000 : -300);
60  \SimpleSAML\Utils\HTTP::setCookie($source->getAuthId() . '-username', $username, $params, FALSE);
61  }
62 
63  try {
65  } catch (SimpleSAML_Error_Error $e) {
66  // Login failed. Extract error code and parameters, to display the error
67  $errorCode = $e->getErrorCode();
69  }
70  }
71 }
72 
74 $t = new SimpleSAML_XHTML_Template($globalConfig, 'core:loginuserpass.php');
75 $t->data['stateparams'] = array('AuthState' => $authStateId);
76 $t->data['username'] = $username;
77 $t->data['forceUsername'] = FALSE;
78 $t->data['rememberUsernameEnabled'] = $source->getRememberUsernameEnabled();
79 $t->data['rememberUsernameChecked'] = $source->getRememberUsernameChecked();
80 $t->data['rememberMeEnabled'] = false;
81 $t->data['rememberMeChecked'] = false;
82 if (isset($_COOKIE[$source->getAuthId() . '-username'])) $t->data['rememberUsernameChecked'] = TRUE;
83 $t->data['errorcode'] = $errorCode;
85 $t->data['errorparams'] = $errorParams;
86 
87 if ($organizations !== NULL) {
88  $t->data['selectedOrg'] = $organization;
89  $t->data['organizations'] = $organizations;
90 }
91 
92 if (isset($state['SPMetadata'])) {
93  $t->data['SPMetadata'] = $state['SPMetadata'];
94 } else {
95  $t->data['SPMetadata'] = NULL;
96 }
97 
98 $t->show();
99 exit();
100 
$params
Definition: disable.php:11
Add rich text string
$_COOKIE['client_id']
Definition: server.php:9
static handleLogin($authStateId, $username, $password, $organization)
Handle login request.
if($organizations===NULL||!empty($organization)) $globalConfig
const AUTHID
The key of the AuthId field in the state.
if($source===NULL) $organizations
static getAllErrorCodeMessages()
Get a map of both errorcode titles and descriptions.
Definition: ErrorCodes.php:135
$password
Definition: pwgen.php:17
static listOrganizations($authStateId)
Get available organizations.
static setCookie($name, $value, $params=null, $throw=true)
Set a cookie.
Definition: HTTP.php:1107
if(!array_key_exists('AuthState', $_REQUEST)) $authStateId
static loadState($id, $stage, $allowMissing=false)
Retrieve saved state.
Definition: State.php:259
Create styles array
The data for the language used.
static getSessionHandler()
This function retrieves the current instance of the session handler.
$errorCode
getParameters()
Retrieve the error parameters given when throwing this error.
Definition: Error.php:140
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
static getById($authId, $type=null)
Retrieve authentication source.
Definition: Source.php:324
$errorParams
getErrorCode()
Retrieve the error code given when throwing this error.
Definition: Error.php:129
static getInstance($instancename='simplesaml')
Get a configuration file by its instance name.
const STAGEID
The string used to identify our states.