WIP Start implmenting CSRF
This commit is contained in:
parent
8f0e27cb86
commit
e7ebd55299
21
app/classes/Framadate/Security/Token.php
Normal file
21
app/classes/Framadate/Security/Token.php
Normal 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
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
20
app/classes/Framadate/Services/SecurityService.php
Normal file
20
app/classes/Framadate/Services/SecurityService.php
Normal 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();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user