From e7ebd552997a78f11fc77fbba5cb89b596dfc7ec Mon Sep 17 00:00:00 2001 From: Olivier PEREZ <olivier@olivierperez.fr> Date: Fri, 9 Jan 2015 09:22:31 +0100 Subject: [PATCH] WIP Start implmenting CSRF --- app/classes/Framadate/Security/Token.php | 21 +++++++++++++++++++ .../Framadate/Services/SecurityService.php | 20 ++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 app/classes/Framadate/Security/Token.php create mode 100644 app/classes/Framadate/Services/SecurityService.php diff --git a/app/classes/Framadate/Security/Token.php b/app/classes/Framadate/Security/Token.php new file mode 100644 index 00000000..2f06afca --- /dev/null +++ b/app/classes/Framadate/Security/Token.php @@ -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 + } + +} + \ No newline at end of file diff --git a/app/classes/Framadate/Services/SecurityService.php b/app/classes/Framadate/Services/SecurityService.php new file mode 100644 index 00000000..ea570e01 --- /dev/null +++ b/app/classes/Framadate/Services/SecurityService.php @@ -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(); + } + +} + \ No newline at end of file -- GitLab