18 include_once (
'WHAT/Class.Authenticator.php');
27 private $username =
'';
36 $this->username = $session->read(
'username');
42 $this->username =
getHttpVars($this->parms[
'username']);
43 if (is_callable(array(
47 if (!$this->provider->validateCredential(
getHttpVars($this->parms[
'username']) ,
getHttpVars($this->parms{
'password'}))) {
56 $session->register(
'username',
getHttpVars($this->parms[
'username']));
57 $session->setuid(
getHttpVars($this->parms[
'username']));
61 error_log(__CLASS__ .
"::" . __FUNCTION__ .
" " .
"Error: " . get_class($this->provider) .
" must implement function validateCredential()");
70 if (!$this->auth_session) {
75 $this->auth_session->Set();
88 if (is_callable(array(
90 'validateAuthorization'
92 return $this->provider->validateAuthorization($opt);
106 $session->register(
'username',
'');
108 if (!isset(
$args[
'redirect_uri'])) {
123 if (empty($this->parms[
'auth'][
'app'])) {
124 throw new \Dcp\Exception(
"Missing html/auth/app config.");
127 $location.=
'authent.php?app=' . $this->parms[
'auth'][
'app'];
128 if (!empty($this->parms[
'auth'][
'action'])) {
129 $location.=
'&action=' . $this->parms[
'auth'][
'action'];
131 if (!empty($this->parms[
'auth'][
'args'])) {
132 $location.=
'&' . $this->parms[
'auth'][
'args'];
135 foreach ($extendedArg as $k => $v) {
136 $sargs.= sprintf(
"&%s=%s", $k, urlencode($v));
147 header(sprintf(
'Location: %s',
$location));
158 $username = $session_auth->read(
'username');
159 if ($username !=
'') {
162 return $this->username;
180 include_once (
'WHAT/Class.Session.php');
183 $session_auth->close();
185 if ($redir_uri ==
"") {
186 if (isset($this->parms[
'auth'][
'app'])) {
190 $redir_uri = GetParam(
"CORE_BASEURL");
192 header(
'Location: ' . $redir_uri);
203 $session_auth->register($name,
$value);
205 return $session_auth->read($name);
215 return $session_auth->read($name);
220 include_once (
'WHAT/Class.ActionRouter.php');
221 include_once (
'WHAT/Class.Account.php');
225 throw new \Dcp\Exception(
"Missing or empty auth app definition.");
229 if (
$account->setLoginName(
"anonymous") ===
false) {
230 throw new \Dcp\Exception(sprintf(
"anonymous account not found."));
240 'action' =>
'CORE_CSS'
246 foreach ($allowList as $allow) {
247 if (isset($allow[
'app']) && $allow[
'app'] ==
$app->name) {
248 if (!isset($allow[
'action']) || $allow[
'action'] ==
$action->name) {
255 throw new \Dcp\Exception(sprintf(
"Unauthorized app '%s' with action '%s' for authentication with '%s'.",
$action->parent->name,
$action->name, get_class($this)));
if(substr($wsh, 0, 1)!= '/') $args
getAuthUrl(array $extendedArg=array())
tryInitializeUser($username)
static getWebRootPath($default=false)
if($account->setLoginName("anonymous")===false) $actionRouter
getHttpVars($name, $def="", $scope="all")
static freedomUserExists($username)
setSessionVar($name, $value)