21 include_once (
'WHAT/Lib.Common.php');
22 include_once (
'WHAT/Class.Authenticator.php');
23 include_once (
'WHAT/Class.Session.php');
24 include_once (
'WHAT/Class.User.php');
25 include_once (
'WHAT/Class.Log.php');
37 self::$provider_errno = 0;
43 if (!preg_match(
'/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/',
$authtype)) {
44 print sprintf(
"Invalid authtype '%s'",
$authtype);
47 $authClass = strtolower(
$authtype) .
"Authenticator";
48 if (!@include_once (
'WHAT/Class.' . $authClass .
'.php')) {
49 print
"Unknown authtype " .
$_GET[
'authtype'];
56 foreach ($authProviderList as $authProvider) {
57 self::$auth =
new $authClass(
$authtype, $authProvider);
58 $status = self::$auth->checkAuthentication();
63 self::$auth->askAuthentication();
74 $providerErrno = self::$auth->getProviderErrno();
75 if ($providerErrno != 0) {
76 self::$provider_errno = $providerErrno;
77 switch ($providerErrno) {
84 self::secureLog(
"failure",
"invalid credential", self::$auth->provider->parms[
'type'] .
"/" . self::$auth->provider->parms[
'provider'],
$_SERVER[
"REMOTE_ADDR"], $_REQUEST[
"auth_user"],
$_SERVER[
"HTTP_USER_AGENT"]);
86 if (
getParam(
"AUTHENT_FAILURECOUNT") > 0) {
88 if ($wu->SetLoginName(self::$auth->getAuthUser())) {
90 include_once (
"FDL/freedom_util.php");
93 $du->disableEditControl();
94 $du->increaseLoginFailure();
95 $du->enableEditControl();
104 $login = self::$auth->getAuthUser();
107 if ($wu->SetLoginName($login)) {
112 self::secureLog(
"failure",
"login have no Dynacase account", self::$auth->provider->parms[
'type'] .
"/" . self::$auth->provider->parms[
'provider'],
$_SERVER[
"REMOTE_ADDR"], $login,
$_SERVER[
"HTTP_USER_AGENT"]);
118 include_once (
"FDL/freedom_util.php");
121 if ($du->isAccountInactive()) {
122 self::secureLog(
"failure",
"inactive account", self::$auth->provider->parms[
'type'] .
"/" . self::$auth->provider->parms[
'provider'],
$_SERVER[
"REMOTE_ADDR"], $login,
$_SERVER[
"HTTP_USER_AGENT"]);
127 if ($du->accountHasExpired()) {
128 self::secureLog(
"failure",
"account has expired", self::$auth->provider->parms[
'type'] .
"/" . self::$auth->provider->parms[
'provider'],
$_SERVER[
"REMOTE_ADDR"], $login,
$_SERVER[
"HTTP_USER_AGENT"]);
133 $maxfail =
getParam(
"AUTHENT_FAILURECOUNT");
134 if ($maxfail > 0 && $du->getValue(
"us_loginfailure", 0) >= $maxfail) {
135 self::secureLog(
"failure",
"max connection (" . $maxfail .
") attempts exceeded", self::$auth->provider->parms[
'type'] .
"/" . self::$auth->provider->parms[
'provider'],
$_SERVER[
"REMOTE_ADDR"], $login,
$_SERVER[
"HTTP_USER_AGENT"]);
140 $du->disableEditControl();
141 $du->resetLoginFailure();
142 $du->enableEditControl();
147 if (method_exists(self::$auth,
'getAuthSession')) {
148 self::$session = self::$auth->getAuthSession();
149 if (self::$session->read(
'username') ==
"") {
150 self::secureLog(
"failure",
"username should exists in session", $authprovider,
$_SERVER[
"REMOTE_ADDR"], $login,
$_SERVER[
"HTTP_USER_AGENT"]);
168 $rurl =
GetHttpVars(
"rurl", $action->GetParam(
"CORE_ROOTURL"));
173 redirect($action,$rapp,$raction,$rurl);
178 $authClass = strtolower(
$authtype).
"Authenticator";
179 if (! @include_once(
'WHAT/Class.'.$authClass.
'.php')) {
180 print
"Unknown authtype ".$_GET[
'authtype'];
191 header(
'HTTP/1.0 500 Internal Error');
192 print sprintf(
"logout method not supported by authtype '%s'",
$authtype);
205 header(
'WWW-Authenticate: Basic realm="' .
getParam(
"CORE_REALM",
"Dynacase Platform connection") .
'"');
206 header(
'HTTP/1.0 401 Unauthorized');
208 echo _(
"Vous devez entrer un nom d'utilisateur valide et un mot de passe correct pour acceder a cette ressource");
212 public function secureLog($status =
"", $additionalMessage =
"", $provider =
"", $clientIp =
"", $account =
"", $userAgent =
"")
215 $log =
new Log(
"",
"Session",
"Authentication");
216 $facility = constant(
getParam(
"AUTH_LOGFACILITY",
"LOG_AUTH"));
217 $log->wlog(
"S", sprintf(
"[%s] [%s] [%s] [%s] [%s] [%s]", $status, $additionalMessage, $provider, $clientIp, $account, $userAgent) , NULL, $facility);
221 private static function clearGDocs()