-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
Per feedback from @joepie91 -- anyone worried about large volumes of session disk space usage can turn this feature on and turn the number down
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,9 +26,10 @@ class AntiCSRF | |
const FORM_TOKEN = '_CSRF_TOKEN'; | ||
const SESSION_INDEX = 'CSRF'; | ||
const HASH_ALGO = 'sha256'; | ||
const RECYCLE_AFTER = 100; | ||
const RECYCLE_AFTER = 65535; | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
sarciszewski
Author
Contributor
|
||
|
||
public static $hmac_ip = true; | ||
public static $expire_old = false; | ||
|
||
/** | ||
* Insert a CSRF token to a form | ||
|
@@ -188,6 +189,10 @@ private static function generateToken($lockto) | |
*/ | ||
private static function recycleTokens() | ||
{ | ||
if (!self::$expire_old) { | ||
// This is turned off. | ||
return; | ||
} | ||
// Sort by creation time | ||
\uasort($_SESSION[self::SESSION_INDEX], function($a, $b) { | ||
return $a['created'] - $b['created']; | ||
|
I'm not worried about disk space for sessions, however Slim's SessionCookie saves $_SESSION data in an encrypted cookie. That would blow up in your face.
Why set such a high number and disable it? If you've generated more than a 100 new tokens, I doubt the user would miss having the 101th token around.
I know I can change it, just wondering though.