CGI-Plus
view release on metacpan or search on metacpan
A Cross-site request forgery
<http://en.wikipedia.org/wiki/Cross-site_request_forgery> (CSRF) is a
technique for breaching a web site's security. CSRF is one of the most
common web-site vulnerabilities. CGI::Plus provides a technique for
protecting
$cgi->csrf_value()
Returns the string used in CSRF checks. This value must be included in
an HTML form (see "$cgi->csrf_value()")
$cgi->csrf_field()
Returns a hidden HTML field with the CSRF check value in it. This field
must be included in HTML forms if you do a CSRF check. The string will
look something like this:
<input type="hidden" name="csrf" value="8hFnVjSr25">
$cgi->csrf_param()
Returns the URL parameter to use in a URL. The return value will look
something like this:
csrf=8hFnVjSr25
The string will never contain HTML or URL meta characters, so it does
not need to be HTML or URL escaped.
$cgi->csrf_check()
Checks if a CSRF check value was sent and that it matches the CSRF
check cookie. CSRF checks must be turned on or this method will croak.
The following code is a typical usage of csrf checking:
$cgi->csrf(1);
if (! $cgi->csrf_check) {
die 'security error';
}
TERMS AND CONDITIONS
Copyright (c) 2012 by Miko O'Sullivan. All rights reserved. This
program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself. This software comes with NO
WARRANTY of any kind.
AUTHOR
Miko O'Sullivan miko@idocs.com
VERSION
Version 0.10 November 22, 2012
Initial release
Version 0.12 November 28, 2012
Fixing prerequisite lists in CPAN upload.
Version 0.13 April 25, 2014
Fixed error in META.yml.
Version 0.14 May 23, 2014
Fixed bugs in test script.
Version 0.15 January 4, 2015
Gave tests names.
( run in 0.709 second using v1.01-cache-2.11-cpan-b16cb0d3907 )