Lines Matching +full:update +full:- +full:user +full:- +full:info -(+path:inc +path:lang) -(+path:lib +path:plugins +path:lang) -(+path:lib +path:tpl +path:dokuwiki +path:lang)

7  * a user by calling auth_login()
52 if ($INPUT->server->str('REMOTE_USER') === '') {
53 $INPUT->server->remove('REMOTE_USER');
59 foreach ($plugin_controller->getList('auth') as $plugin) {
61 $auth = $plugin_controller->load('auth', $plugin);
67 msg($lang['authtempfail'], -1);
71 if ($auth->success == false) {
72 // degrade to unauthenticated user
75 msg($lang['authtempfail'], -1);
80 $INPUT->set('http_credentials', false);
81 if (!$conf['rememberme']) $INPUT->set('r', false);
83 // Populate Basic Auth user/password from Authorization header
85 …$header = $INPUT->server->str('HTTP_AUTHORIZATION') ?: $INPUT->server->str('REDIRECT_HTTP_AUTHORIZ…
86 if (preg_match('~^Basic ([a-z\d/+]*={0,2})$~i', $header, $matches)) {
92 …if (!$INPUT->str('u') && empty($_COOKIE[DOKU_COOKIE]) && !empty($INPUT->server->str('PHP_AUTH_USER…
93 $INPUT->set('u', $INPUT->server->str('PHP_AUTH_USER'));
94 $INPUT->set('p', $INPUT->server->str('PHP_AUTH_PW'));
95 $INPUT->set('http_credentials', true);
98 // apply cleaning (auth specific user names, remove control chars)
99 if (true === $auth->success) {
100 $INPUT->set('u', $auth->cleanUser(stripctl($INPUT->str('u'))));
101 $INPUT->set('p', stripctl($INPUT->str('p')));
107 if ($auth->canDo('external')) {
108 $ok = $auth->trustExternal($INPUT->str('u'), $INPUT->str('p'), $INPUT->bool('r'));
115 'user' => $INPUT->str('u'),
116 'password' => $INPUT->str('p'),
117 'sticky' => $INPUT->bool('r'),
118 'silent' => $INPUT->bool('http_credentials')
131 * Loads the ACL setup and handle user wildcards
154 // substitute user wildcard first (its 1:1)
155 if (strstr($line, '%USER%')) {
156 // if user is not logged in, this ACL line is meaningless - skip it
157 if (!$INPUT->server->has('REMOTE_USER')) continue;
159 $id = str_replace('%USER%', cleanID($INPUT->server->str('REMOTE_USER')), $id);
160 … $rest = str_replace('%USER%', auth_nameencode($INPUT->server->str('REMOTE_USER')), $rest);
165 // if user is not logged in, grps is empty, no output will be added (i.e. skipped)
219 // check x-dokuwiki-token header
220 if (isset($headers['x-dokuwiki-token'])) {
221 $token = $headers['x-dokuwiki-token'];
230 msg(hsc($e->getMessage()), -1);
234 // fetch user info from backend
235 $user = $authtoken->getUser();
236 $USERINFO = $auth->getUserData($user);
239 // the code is correct, set up user
240 $INPUT->server->set('REMOTE_USER', $user);
241 $_SESSION[DOKU_COOKIE]['auth']['user'] = $user;
243 $_SESSION[DOKU_COOKIE]['auth']['info'] = $USERINFO;
259 $evdata['user'],
267 * This tries to login the user based on the sent auth credentials
270 * a new login is assumed and user/password are checked. If they
272 * together with the username in a cookie - the same info is stored
278 * no further testing is done and the user is accepted
280 * If a cookie was found but no session info was availabe the
287 * @param string $user Username
296 function auth_login($user, $pass, $sticky = false, $silent = false) argument
308 if (!empty($user)) {
311 if (!empty($pass) && $auth->checkPass($user, $pass)) {
313 $INPUT->server->set('REMOTE_USER', $user);
314 $secret = auth_cookiesalt(!$sticky, true); //bind non-sticky to session
315 auth_setCookie($user, auth_encrypt($pass, $secret), $sticky);
318 //invalid credentials - log off
321 msg($lang['badlogin'], -1);
328 [$user, $sticky, $pass] = auth_getCookie();
329 if ($user && $pass) {
330 // we got a cookie - see if we can trust it
332 // get session info
336 isset($session['user']) &&
338 $auth->useSessionCache($user) &&
339 ($session['time'] >= time() - $conf['auth_security_timeout']) &&
340 ($session['user'] === $user) &&
344 // he has session, cookie and browser right - let him in
345 $INPUT->server->set('REMOTE_USER', $user);
346 $USERINFO = $session['info']; //FIXME move all references to session
350 // no we don't trust it yet - recheck pass but silent
351 $secret = auth_cookiesalt(!$sticky, true); //bind non-sticky to session
353 return auth_login($user, $pass, $sticky, true);
364 * This is neither unique nor unfakable - still it adds some
382 $INPUT->server->str('HTTP_USER_AGENT'),
383 $INPUT->server->str('HTTP_ACCEPT_LANGUAGE'),
469 $cipher->setPassword($secret, 'pbkdf2', 'sha1', 'phpseclib');
470 $cipher->setIV($iv);
474 http://csrc.nist.gov/publications/nistpubs/800-38a/sp800-38a.pdf, Appendix C
478 return $cipher->encrypt($iv . $data);
494 $cipher->setPassword($secret, 'pbkdf2', 'sha1', 'phpseclib');
495 $cipher->setIV($iv);
498 return $cipher->decrypt(substr($ciphertext, 16));
506 * Log out the current user
508 * This clears all authentication data and thus log the user
513 * @param bool $keepbc - when true, the breadcrumb data is not cleared
527 if (isset($_SESSION[DOKU_COOKIE]['auth']['user']))
528 unset($_SESSION[DOKU_COOKIE]['auth']['user']);
531 if (isset($_SESSION[DOKU_COOKIE]['auth']['info']))
532 unset($_SESSION[DOKU_COOKIE]['auth']['info']);
535 $INPUT->server->remove('REMOTE_USER');
540 'expires' => time() - 600000,
548 $auth->logOff();
553 * Check if a user is a manager
556 * user.
558 * The info is available through $INFO['ismanager'], too
560 * @param string $user Username
561 * @param array $groups List of groups the user is in
562 * @param bool $adminonly when true checks if user is admin
569 function auth_ismanager($user = null, $groups = null, $adminonly = false, $recache = false) argument
580 if (is_null($user)) {
581 if (!$INPUT->server->has('REMOTE_USER')) {
584 $user = $INPUT->server->str('REMOTE_USER');
588 // checking the logged in user, or another one?
589 if ($USERINFO && $user === $INPUT->server->str('REMOTE_USER')) {
592 $groups = $auth->getUserData($user);
599 $cachekey = serialize([$user, $adminonly, $groups]);
602 $ok = auth_isMember($conf['superuser'], $user, $groups);
606 $ok = auth_isMember($conf['manager'], $user, $groups);
616 * Check if a user is admin
620 * The info is available through $INFO['isadmin'], too
622 * @param string $user Username
623 * @param array $groups List of groups the user is in
630 function auth_isadmin($user = null, $groups = null, $recache = false) argument
632 return auth_ismanager($user, $groups, true, $recache);
636 * Match a user and his groups against a comma separated list of
642 * @param string $user user to match against
643 * @param array $groups groups the user is member of
646 function auth_isMember($memberlist, $user, array $groups) argument
652 // clean user and groups
653 if (!$auth->isCaseSensitive()) {
654 $user = PhpString::strtolower($user);
657 $user = $auth->cleanUser($user);
658 $groups = array_map($auth->cleanGroup(...), $groups);
669 if (!$auth->isCaseSensitive()) $member = PhpString::strtolower($member);
671 $member = $auth->cleanGroup(substr($member, 1));
674 $member = $auth->cleanUser($member);
675 if ($member == $user) return true;
686 * This checks the permissions for the current user
701 …return auth_aclcheck($id, $INPUT->server->str('REMOTE_USER'), is_array($USERINFO) ? $USERINFO['grp…
705 * Returns the maximum rights a user has for the given ID or its namespace
711 * @param string $user Username
712 * @param array|null $groups Array of groups the user is in
715 function auth_aclcheck($id, $user, $groups) argument
719 'user' => $user,
739 $user =& $data['user'];
755 //if user is superuser or in superusergroup return 255 (acl_admin)
756 if (auth_isadmin($user, $groups)) {
760 if (!$auth->isCaseSensitive()) {
761 $user = PhpString::strtolower($user);
764 $user = auth_nameencode($auth->cleanUser($user));
765 $groups = array_map($auth->cleanGroup(...), $groups);
773 $perm = -1;
778 //add User
779 if ($user) $groups[] = $user;
787 if (!$auth->isCaseSensitive() && $acl[1] !== '@ALL') {
798 if ($perm > -1) {
799 //we had a match - return it
817 if (!$auth->isCaseSensitive() && $acl[1] !== '@ALL') {
828 //we had a match - return it
829 if ($perm != -1) {
853 * Some auth backends allow special chars in their user and groupnames
855 * are encoded UTF-8 multibyte are left as is (different from usual
874 if ($name == '%USER%') return $name;
880 '/([\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f])/',
886 '/([\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f])/',
904 return '%' . dechex(ord(substr($matches[1], -1)));
930 if ($evt->advise_before(true)) {
934 $s = '!$%&?+*~#-_:.;,'; // specials
938 $data['password'] .= $c[auth_random(0, strlen($c) - 1)];
939 $data['password'] .= $v[auth_random(0, strlen($v) - 1)];
940 $data['password'] .= $a[auth_random(0, strlen($a) - 1)];
943 $data['password'] .= $s[auth_random(0, strlen($s) - 1)] . auth_random(10, 99);
945 $evt->advise_after();
951 * Sends a password to the given user
955 * @param string $user Login name of the user
959 function auth_sendPassword($user, $password) argument
966 $user = $auth->cleanUser($user);
967 $userinfo = $auth->getUserData($user, false);
974 'LOGIN' => $user,
979 $mail->to($mail->getCleanName($userinfo['name']) . ' <' . $userinfo['mail'] . '>');
980 $mail->subject($lang['regpwmail']);
981 $mail->setBody($text, $trep);
982 return $mail->send();
986 * Register a new user
988 * This registers a new user - Data is read directly from $_POST
1003 if (!$INPUT->post->bool('save')) return false;
1007 $login = trim($auth->cleanUser($INPUT->post->str('login')));
1008 $fullname = trim(preg_replace('/[\x00-\x1f:<>&%,;]+/', '', $INPUT->post->str('fullname')));
1009 $email = trim(preg_replace('/[\x00-\x1f:<>&%,;]+/', '', $INPUT->post->str('email')));
1010 $pass = $INPUT->post->str('pass');
1011 $passchk = $INPUT->post->str('passchk');
1014 msg($lang['regmissing'], -1);
1021 msg($lang['regmissing'], -1); // complain about missing passwords
1024 msg($lang['regbadpass'], -1); // complain about misspelled passwords
1030 msg($lang['regbadmail'], -1);
1034 //okay try to create the user
1035 if (!$auth->triggerUserMod('create', [$login, $pass, $fullname, $email])) {
1036 msg($lang['regfail'], -1);
1040 // send notification about the new user
1042 $subscription->sendRegister($login, $fullname, $email);
1050 // autogenerated password? then send password to user
1055 msg($lang['regmailfail'], -1);
1061 * Update user profile
1076 if (!$INPUT->post->bool('save')) return false;
1080 msg($lang['profna'], -1);
1085 $changes['pass'] = $INPUT->post->str('newpass');
1086 $changes['name'] = $INPUT->post->str('fullname');
1087 $changes['mail'] = $INPUT->post->str('email');
1090 if ($changes['pass'] != $INPUT->post->str('passchk')) {
1091 msg($lang['regbadpass'], -1);
1096 $changes['name'] = trim(preg_replace('/[\x00-\x1f:<>&%,;]+/', '', $changes['name']));
1097 $changes['mail'] = trim(preg_replace('/[\x00-\x1f:<>&%,;]+/', '', $changes['mail']));
1101 (empty($changes['name']) && $auth->canDo('modName')) ||
1102 (empty($changes['mail']) && $auth->canDo('modMail'))
1104 msg($lang['profnoempty'], -1);
1107 if (!mail_isvalid($changes['mail']) && $auth->canDo('modMail')) {
1108 msg($lang['regbadmail'], -1);
1115 if (!$auth->canDo('modName')) unset($changes['name']);
1116 if (!$auth->canDo('modMail')) unset($changes['mail']);
1117 if (!$auth->canDo('modPass')) unset($changes['pass']);
1121 msg($lang['profnochange'], -1);
1126 if (!$auth->checkPass($INPUT->server->str('REMOTE_USER'), $INPUT->post->str('oldpass'))) {
1127 msg($lang['badpassconfirm'], -1);
1132 if (!$auth->triggerUserMod('modify', [$INPUT->server->str('REMOTE_USER'), &$changes])) {
1133 msg($lang['proffail'], -1);
1138 // update cookie and session with the changed data
1139 [/* user */, $sticky, /* pass */] = auth_getCookie();
1141 auth_setCookie($INPUT->server->str('REMOTE_USER'), $pass, (bool) $sticky);
1154 * Delete the current logged-in user
1167 if (!$INPUT->post->bool('delete')) return false;
1171 if (!actionOK('profile_delete') || !$auth->canDo('delUser')) {
1172 msg($lang['profnodelete'], -1);
1176 if (!$INPUT->post->bool('confirm_delete')) {
1177 msg($lang['profconfdeletemissing'], -1);
1182 if (!$auth->checkPass($INPUT->server->str('REMOTE_USER'), $INPUT->post->str('oldpass'))) {
1183 msg($lang['badpassconfirm'], -1);
1189 $deleted[] = $INPUT->server->str('REMOTE_USER');
1190 if ($auth->triggerUserMod('delete', [$deleted])) {
1204 * - handling the first request of password reset
1205 * - validating the password reset auth token
1211 * @author Benoit Chesneau <benoit@bchesneau.info>
1224 msg($lang['resendna'], -1);
1228 $token = preg_replace('/[^a-f0-9]+/', '', $INPUT->str('pwauth'));
1231 // we're in token phase - get user info from token
1235 msg($lang['resendpwdbadauth'], -1);
1236 $INPUT->remove('pwauth');
1240 if ((time() - filemtime($tfile)) > (3 * 60 * 60 * 24)) {
1241 msg($lang['resendpwdbadauth'], -1);
1242 $INPUT->remove('pwauth');
1247 $user = io_readfile($tfile);
1248 $userinfo = $auth->getUserData($user, false);
1250 msg($lang['resendpwdnouser'], -1);
1254 if (!$conf['autopasswd']) { // we let the user choose a password
1255 $pass = $INPUT->str('pass');
1259 if ($pass != $INPUT->str('passchk')) {
1260 msg($lang['regbadpass'], -1);
1265 if (!$auth->triggerUserMod('modify', [$user, ['pass' => $pass]])) {
1266 msg($lang['proffail'], -1);
1270 $pass = auth_pwgen($user);
1271 if (!$auth->triggerUserMod('modify', [$user, ['pass' => $pass]])) {
1272 msg($lang['proffail'], -1);
1276 if (auth_sendPassword($user, $pass)) {
1279 msg($lang['regmailfail'], -1);
1288 if (!$INPUT->post->bool('save')) return false;
1290 if (!$INPUT->post->str('login')) {
1291 msg($lang['resendpwdmissing'], -1);
1294 $user = trim($auth->cleanUser($INPUT->post->str('login')));
1297 $userinfo = $auth->getUserData($user, false);
1299 msg($lang['resendpwdnouser'], -1);
1308 io_saveFile($tfile, $user);
1311 $trep = ['FULLNAME' => $userinfo['name'], 'LOGIN' => $user, 'CONFIRM' => $url];
1314 $mail->to($userinfo['name'] . ' <' . $userinfo['mail'] . '>');
1315 $mail->subject($lang['regpwmail']);
1316 $mail->setBody($text, $trep);
1317 if ($mail->send()) {
1320 msg($lang['regmailfail'], -1);
1356 msg("Unsupported crypt method $method", -1);
1360 return $pass->$call($clear, $salt);
1380 return $pass->verify_hash($clear, $crypt);
1384 * Set the authentication cookie and add user identification data to the session
1386 * @param string $user username
1391 function auth_setCookie($user, $pass, $sticky) argument
1399 $USERINFO = $auth->getUserData($user);
1402 $cookie = base64_encode($user) . '|' . ((int) $sticky) . '|' . base64_encode($pass);
1414 $_SESSION[DOKU_COOKIE]['auth']['user'] = $user;
1417 $_SESSION[DOKU_COOKIE]['auth']['info'] = $USERINFO;
1424 * Returns the user, (encrypted) password and sticky bit from cookie
1433 [$user, $sticky, $pass] = sexplode('|', $_COOKIE[DOKU_COOKIE], 3, '');
1436 $user = base64_decode($user);
1437 return [$user, $sticky, $pass];