Validates a Cookie Token

@param string $strCookieToken
@param string $strSalt Token salt
@return array|bool The username or FALSE
13589
public function validateCookieToken($strCookieToken, $strSalt=false) {
		$t = Cryptastic::decrypt($strCookieToken, ($strSalt ? $strSalt : $this->salt));

		if (isset($t['username']) && isset($t['expiration']) && $t['expiration'] > time())
			return $t['username'];

		return false;
	}
365652
public GitkitUser validateTokenInRequest(HttpServletRequest request)
      throws GitkitClientException {
    Cookie[] cookies = request.getCookies();
    if (cookieName == null || cookies == null) {
      return null;
    }

    for (Cookie cookie : cookies) {
      if (cookieName.equals(cookie.getName())) {
        return validateToken(cookie.getValue());
      }
    }
    return null;
  }
827936
public static function validateToken(User $user, PasswordResetToken $token): bool
    {
        if ($user->getPasswordResetToken()->equals($token)) {
            return true;
        }

        throw new InvalidPasswordResetTokenException('The given token is not valid.');
    }
931609
private function cookieLogin()
    {
        $read = new Read();
        $prazoTokenExpira = date('Y-m-d H:i:s', strtotime("-2 months", strtotime(date("Y-m-d H:i:s"))));
        $read->exeRead("usuarios", "WHERE token = :to", "to={$_COOKIE['token']}");

        if ($read->getResult() && $read->getResult()[0]['status'] === 1 && $read->getResult()[0]['token_expira'] > $prazoTokenExpira) {
            $login = new Login();
            $login->setLogin(["user" => $read->getResult()[0]['nome'], "password" => $read->getResult()[0]['password']]);
        } else {
            new Logout();
        }
    }
577662
function verifyToken(token) {
    var decodedToken = jwt.decode(token)
    return userdb.users.filter(user => user.name == decodedToken).length > 0;
}
1150744
def parse_cookie(name, seed, kaka):
    
    if not kaka:
        return None

    cookie_obj = SimpleCookie(kaka)
    morsel = cookie_obj.get(name)

    if morsel:
        parts = morsel.value.split("|")
        if len(parts) != 3:
            return None
            # verify the cookie signature
        sig = cookie_signature(seed, parts[0], parts[1])
        if sig != parts[2]:
            raise SAMLError("Invalid cookie signature")

        try:
            return parts[0].strip(), parts[1]
        except KeyError:
            return None
    else:
        return None
425034
public function strCookie($key, $minLength = 0, $maxLength = false, $default = false)
	{
		return $this->str($this->cookie($key), $minLength, $maxLength, $default);
	}
1269452
public function verifyResponse( $sResponseString, $sSignature )
    {
        $hPublicKey = openssl_get_publickey(
            oxRegistry::get( 'OxpsPaymorrowSettings' )->getPaymorrowKey()
        );

        return ( openssl_verify( $sResponseString, hex2bin( $sSignature ), $hPublicKey ) === 1 );
    }
1300152
def validate_cookie     
      if cookies[:caboose_user_id]
        user = User.where(:id => cookies[:caboose_user_id]).first
        if user        
          login_user(user)
          return true
        end
      end
      return false
    end
402576
public function setPersistToken($set = true)
	{
		$this->debug->groupCollapsed(__METHOD__);
		$cookieParams = $this->cfg['persistCookie'];
		$return = null;
		if ($set) {
			$token = $this->genToken();	// raw binary
			$cookieParams['value'] = array(
				'username'	=> $this->user['username'],
				'token'		=> $token,
			);
			#$this->debug->log('value', $cookie['value']);
			Cookie::set($cookieParams);
			// store cookie / username combo in db
			$values = array(
				'userid'		=> $this->userid,
				'token_hash'	=> sha1($token),
			);
			$this->db->rowMan('persist_tokens', $values);
			$return = $cookieParams['value'];
		} elseif (isset($_COOKIE[ $cookieParams['name'] ])) {
			$vals = Cookie::get($cookieParams['name']);
			if (is_array($vals) && isset($vals['username']) && isset($vals['token'])) {
				// remove token from db
				// determine userid
				$userid = null;
				if (isset($this->user['username']) && $this->user['username'] === $vals['username']) {
					$userid = $this->userid;
				} else {
					$users = $this->search(array('username'=>$vals['username']));
					if ($users) {
						$userid = $users[0]['userid'];
					}
				}
				if ($userid) {
					$where = array(
						'userid'		=> $userid,
						'token_hash'	=> sha1($vals['token']),
					);
					$this->db->rowMan('persist_tokens', null, $where);
				}
				// remove cookie
				$cookieParams['value'] = null;
				Cookie::set($cookieParams);
			}
		}
		$this->debug->groupEnd();
		return $return;
	}
944075
public function isValidLoginToken(string $loginToken) : bool {
		$hashes = $this->getTokenHashes();

		if ($hashes === null) {
			return false;
		} else {
			return password_verify($loginToken, $hashes["login_hash"]);
		}
	}
742657
private function isToken($token, $typeMask = null)
    {
        if (!$token instanceof Token) {
            return false;
        }

        if (null === $typeMask || $token->type & $typeMask) {
            return true;
        }

        return false;
    }
938725
protected function _isValidRemoteAccessToken()
    {
        $inputToken = \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter('rtoken');
        $token = $this->getRemoteAccessToken(false);

        return !empty($inputToken) ? ($token === $inputToken) : false;
    }
42535
function checkIsHttpToken(val) {
  if (typeof val !== 'string' || val.length === 0)
    return false;
  if (!isValidTokenChar(val.charCodeAt(0)))
    return false;
  const len = val.length;
  if (len > 1) {
    if (!isValidTokenChar(val.charCodeAt(1)))
      return false;
    if (len > 2) {
      if (!isValidTokenChar(val.charCodeAt(2)))
        return false;
      if (len > 3) {
        if (!isValidTokenChar(val.charCodeAt(3)))
          return false;
        for (var i = 4; i < len; i++) {
          if (!isValidTokenChar(val.charCodeAt(i)))
            return false;
        }
      }
    }
  }
  return true;
}
200732
public function validateCookie(WebRequest $request)
    {
        if ($request->cookie(self::TOKEN_COOKIE_NAME) != $request->post(self::TOKEN_COOKIE_NAME)) {
            throw new CsrfViolationException();
        }
    }
848395
function getCSRFToken() {
		if (typeof document === "undefined") return null;
		var cookies = document.cookie.split(";");//$NON-NLS-0$

		var i,n,v;
		for(i = 0; i<cookies.length; i++) {
			n = cookies[i].substr(0, cookies[i].indexOf("=")).trim();//$NON-NLS-0$
			v = cookies[i].substr(cookies[i].indexOf("=") + 1).trim();//$NON-NLS-0$

			if(n.endsWith(XSRF_TOKEN)) {
				return v;
			}
		}
	}
1179032
public function withRespondWithCookieToken($cookieName = 'XSRF-TOKEN', callable $modify = null)
    {
        return $this->add(new RespondWithCookieToken([$this->tokenService, 'generate'], $cookieName, $modify));
    }