mirror of
https://framagit.org/framasoft/framadate/framadate
synced 2026-07-20 16:48:47 +00:00
WIP Start implmenting CSRF
This commit is contained in:
parent
8f0e27cb86
commit
e7ebd55299
2 changed files with 41 additions and 0 deletions
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…
Add table
Add a link
Reference in a new issue