-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#172 Fix 'Page Expired' errors keep occurring after 30 minutes due to…
… default timeout by CBCSRF module
- Loading branch information
1 parent
be3105e
commit 2fa5a70
Showing
4 changed files
with
67 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
component singleton { | ||
|
||
property name="wirebox" inject="wirebox"; | ||
property name="settings" inject="coldbox:moduleSettings:cbwire"; | ||
|
||
/** | ||
* Generate a CSRF token. | ||
* | ||
* @return string | ||
*/ | ||
function generate() { | ||
var csrf = hash( createUUID(), "SHA-256" ); | ||
getCSRFStorage().set( "CBWIRE_CSRF", csrf ); | ||
return csrf; | ||
} | ||
|
||
/** | ||
* Verify a CSRF token. | ||
* | ||
* @token string | ||
* | ||
* @return boolean | ||
*/ | ||
function verify( token ) { | ||
if ( !getCSRFStorage().exists( "CBWIRE_CSRF" ) ) { | ||
throw( type="CSRF Expired", message="Page expired" ); | ||
} | ||
return true; | ||
} | ||
|
||
/** | ||
* Get the CSRF storage object. | ||
* | ||
* @return any | ||
*/ | ||
function getCSRFStorage() { | ||
return wirebox.getInstance( settings.csrfStorage ); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters