WIP Start implmenting CSRF

This commit is contained in:
Olivier PEREZ 2015-01-09 09:22:31 +01:00
parent 8f0e27cb86
commit e7ebd55299
2 changed files with 41 additions and 0 deletions

View File

@ -0,0 +1,21 @@
<?php
namespace Framadate\Security;
class Token {
private $tokan_name;
private $time;
private $value;
function __construct($tokan_name, $time) {
$this->tokan_name = $tokan_name;
$this->time = $time;
$this->value = $this->generate();
}
private function generate() {
// TODO
}
}

View File

@ -0,0 +1,20 @@
<?php
namespace Framadate\Services;
use Framadate\Security\Token;
class SecurityService {
function __construct() {
}
function getToken($tokan_name) {
if (!isset($_SESSION['token']) || !isset($_SESSION['token'][$tokan_name])) {
$_SESSION['token'][$tokan_name] = new Token($tokan_name, 60*5);
}
return $_SESSION['token'][$tokan_name]->getValue();
}
}