Core  3.2
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
checkauth.php
Go to the documentation of this file.
1 <?php
2 /*
3  * @author Anakeen
4  * @package FDL
5 */
6 /**
7  * PHP Authentification control
8  *
9  * @author Anakeen
10  * @package FDL
11  * @subpackage CORE
12  * @deprecated since HTTP Authentification
13  */
14 
16 {
17 
18  include_once ('WHAT/Lib.Common.php');
19  include_once ('WHAT/Class.AuthenticatorManager.php');
20  include_once ('WHAT/Class.htmlAuthenticator.php');
21  include_once ('WHAT/Class.User.php');
22  include_once ('WHAT/Class.Log.php');
23 
24  $redirect_uri = GetHttpVars('redirect_uri', '');
25 
26  $status = AuthenticatorManager::checkAccess();
27  //error_log("checkauth: AuthenticatorManager::checkAccess() = {$status}");
28  switch ($status) {
29  case AuthenticatorManager::AccessOk: // it'good, user is authentified, just log the connexion
30  AuthenticatorManager::secureLog("success", "welcome", AuthenticatorManager::$auth->provider->parms['type'] . "/" . AuthenticatorManager::$auth->provider->parms['provider'], $_SERVER["REMOTE_ADDR"], AuthenticatorManager::$auth->getAuthUser() , $_SERVER["HTTP_USER_AGENT"]);
31  break;
32 
34  // User must change his password
35  $action->session->close();
36  global $_POST;
37  Redirect($action, 'AUTHENT', 'ERRNO_BUG_639');
38  exit(0);
39  break;
40 
41  default:
42  AuthenticatorManager::$auth->askAuthentication(array(
43  'error' => $status,
44  'auth_user' => $_POST['auth_user'],
45  'redirect_uri' => $redirect_uri
46  ));
47  exit(0);
48  }
49 
50  if (($redirect_uri == "") || (preg_match('/app=AUTHENT/', $redirect_uri))) {
51  $redirect_uri = ".";
52  } else if ($redirect_uri[0] != '/') {
53  /*
54  * $redirect_uri is normally constructed from REQUEST_URI, so
55  * it should start with "/" and be a local absolute pathname.
56  *
57  * If it does not start with a "/", then it might indicate a
58  * malicious manipulation to perform a cross-site redirect.
59  */
60  $redirect_uri = ".";
61  }
62  $lang = array();
63  include_once ('CORE/lang.php');
64  $core_lang = getHttpVars('CORE_LANG');
65  if ($core_lang != "" && array_key_exists($core_lang, $lang)) {
66  // error_log(__CLASS__."::".__FUNCTION__." "."Registering vaviable CORE_LANG = '".$core_lang."' in session_auth");
67  AuthenticatorManager::$session->register('CORE_LANG', $core_lang);
68  }
69  $redirect_uri = preg_replace('!//+!', '/', $redirect_uri);
70  $redirect_uri = preg_replace('!&&+!', '&', $redirect_uri);
71  // Redirect to initial page
72  header('Location: ' . $redirect_uri);
73  exit(0);
74 }
$status
Definition: index.php:30
static secureLog($status="", $additionalMessage="", $provider="", $clientIp="", $account="", $userAgent="")
global $action
global $_POST
Definition: chgpasswd.php:17
Redirect($action, $appname, $actionname, $otherurl="", $httpparamredirect=false)
Definition: Lib.Http.php:21
$lang
Definition: lang.php:18
checkauth(Action &$action)
Definition: checkauth.php:15
getHttpVars($name, $def="", $scope="all")
Definition: Lib.Http.php:124
global $_SERVER
switch($command) exit
Definition: checkVault.php:46
← centre documentaire © anakeen