ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
loginuserpass.php
Go to the documentation of this file.
1<?php
2
12// Retrieve the authentication state
13if (!array_key_exists('AuthState', $_REQUEST)) {
14 throw new SimpleSAML_Error_BadRequest('Missing AuthState parameter.');
15}
16$authStateId = $_REQUEST['AuthState'];
18
20if ($source === NULL) {
21 throw new Exception('Could not find authentication source with id ' . $state[sspmod_core_Auth_UserPassBase::AUTHID]);
22}
23
24
25if (array_key_exists('username', $_REQUEST)) {
26 $username = $_REQUEST['username'];
27} elseif ($source->getRememberUsernameEnabled() && array_key_exists($source->getAuthId() . '-username', $_COOKIE)) {
28 $username = $_COOKIE[$source->getAuthId() . '-username'];
29} elseif (isset($state['core:username'])) {
30 $username = (string)$state['core:username'];
31} else {
32 $username = '';
33}
34
35if (array_key_exists('password', $_REQUEST)) {
36 $password = $_REQUEST['password'];
37} else {
38 $password = '';
39}
40
43
44if (!empty($_REQUEST['username']) || !empty($password)) {
45 // Either username or password set - attempt to log in
46
47 if (array_key_exists('forcedUsername', $state)) {
48 $username = $state['forcedUsername'];
49 }
50
51 if ($source->getRememberUsernameEnabled()) {
53 $params = $sessionHandler->getCookieParams();
54 $params['expire'] = time();
55 $params['expire'] += (isset($_REQUEST['remember_username']) && $_REQUEST['remember_username'] == 'Yes' ? 31536000 : -300);
56 \SimpleSAML\Utils\HTTP::setCookie($source->getAuthId() . '-username', $username, $params, FALSE);
57 }
58
59 if ($source->isRememberMeEnabled()) {
60 if (array_key_exists('remember_me', $_REQUEST) && $_REQUEST['remember_me'] === 'Yes') {
61 $state['RememberMe'] = TRUE;
63 }
64 }
65
66 try {
68 } catch (SimpleSAML_Error_Error $e) {
69 /* Login failed. Extract error code and parameters, to display the error. */
72 }
73}
74
76$t = new SimpleSAML_XHTML_Template($globalConfig, 'core:loginuserpass.php');
77$t->data['stateparams'] = array('AuthState' => $authStateId);
78if (array_key_exists('forcedUsername', $state)) {
79 $t->data['username'] = $state['forcedUsername'];
80 $t->data['forceUsername'] = TRUE;
81 $t->data['rememberUsernameEnabled'] = FALSE;
82 $t->data['rememberUsernameChecked'] = FALSE;
83 $t->data['rememberMeEnabled'] = $source->isRememberMeEnabled();
84 $t->data['rememberMeChecked'] = $source->isRememberMeChecked();
85} else {
86 $t->data['username'] = $username;
87 $t->data['forceUsername'] = FALSE;
88 $t->data['rememberUsernameEnabled'] = $source->getRememberUsernameEnabled();
89 $t->data['rememberUsernameChecked'] = $source->getRememberUsernameChecked();
90 $t->data['rememberMeEnabled'] = $source->isRememberMeEnabled();
91 $t->data['rememberMeChecked'] = $source->isRememberMeChecked();
92 if (isset($_COOKIE[$source->getAuthId() . '-username'])) $t->data['rememberUsernameChecked'] = TRUE;
93}
94$t->data['links'] = $source->getLoginLinks();
95$t->data['errorcode'] = $errorCode;
97$t->data['errorparams'] = $errorParams;
98
99if (isset($state['SPMetadata'])) {
100 $t->data['SPMetadata'] = $state['SPMetadata'];
101} else {
102 $t->data['SPMetadata'] = NULL;
103}
104
105$t->show();
106exit();
107
$_COOKIE['client_id']
Definition: server.php:9
exit
Definition: backend.php:16
An exception for terminatinating execution or to throw for unit testing.
static getAllErrorCodeMessages()
Get a map of both errorcode titles and descriptions.
Definition: ErrorCodes.php:135
static getSessionHandler()
This function retrieves the current instance of the session handler.
static setCookie($name, $value, $params=null, $throw=true)
Set a cookie.
Definition: HTTP.php:1104
static getById($authId, $type=null)
Retrieve authentication source.
Definition: Source.php:340
static saveState(&$state, $stage, $rawId=false)
Save the state.
Definition: State.php:194
static loadState($id, $stage, $allowMissing=false)
Retrieve saved state.
Definition: State.php:259
static getInstance($instancename='simplesaml')
Get a configuration file by its instance name.
getParameters()
Retrieve the error parameters given when throwing this error.
Definition: Error.php:131
getErrorCode()
Retrieve the error code given when throwing this error.
Definition: Error.php:120
static handleLogin($authStateId, $username, $password)
Handle login request.
const AUTHID
The key of the AuthId field in the state.
const STAGEID
The string used to identify our states.
$password
Definition: cron.php:14
if(!empty($_REQUEST['username'])||!empty($password)) $globalConfig
$errorCode
$errorParams
if(!array_key_exists('AuthState', $_REQUEST)) $authStateId
$source
$state