27 $context [
'HOST'] = $_SERVER [
'HTTP_HOST'];
28 $context [
'REQUEST_URI'] = $_SERVER [
'REQUEST_URI'];
29 $context [
'REQUEST_METHOD'] = $_SERVER [
'REQUEST_METHOD'];
30 $context [
'cookie'] = $_COOKIE;
31 Logger::error (
'Session',
'CSRF protector validation failure!',
'startSession', $context );
34 public function init(): void {
36 $this->sessionInstance->set ( self::TOKEN_KEY, $token );
37 UCookie::set ( $token->getName (), $token->getValue (),
null );
41 $token = $this->sessionInstance->get ( self::TOKEN_KEY );
42 $this->sessionInstance->delete ( self::TOKEN_KEY );
43 if (isset ( $token )) {
49 $token = $this->sessionInstance->get ( self::TOKEN_KEY );
50 if (isset ( $token )) {
51 if (! $token instanceof
CsrfToken || ! hash_equals ( $token->getValue (),
'' . UCookie::get ( $token->getName () ) )) {
52 if (Logger::isActive ()) {
53 $this->csrfErrorLog ();
56 $this->sessionInstance->terminate ();
Abstract class for logging Ubiquity\log$Logger This class is part of Ubiquity.
Http Cookies utilities Ubiquity\utils\http$UCookie This class is part of Ubiquity.
static set($name, $value, $duration=60 *60 *24, $path='/', $secure=false, $httpOnly=false)
Sends a cookie.
static delete($name, $path='/')
Removes the cookie with the name $name.
Ubiquity\utils\http\session$AbstractSession This class is part of Ubiquity.
Ubiquity\utils\http\session\protection$CsrfToken This class is part of Ubiquity.
Ubiquity\utils\http\session\protection$VerifyCsrfToken This class is part of Ubiquity.
init()
Creates the Csrf token and adds it to the session.
AbstractSession $sessionInstance
clear()
Removes the actual csrftoken.
__construct(AbstractSession $sessionInstance)
static getLevel()
Get security level.
start()
Called wjen the session is started.
Ubiquity\utils\http\session\protection$VerifyCsrfInterface This class is part of Ubiquity.