Dancer2-Plugin-CSRFI

 view release on metacpan or  search on metacpan

lib/Dancer2/Plugin/CSRFI.pm  view on Meta::CPAN


=head3 refresh

If true, token will be refreshed on each hit.
This makes your applications more secure, but in many cases, is too strict.

=head3 template_token

If provided, template token with csrf token will be set.

=head3 validate_post

If true, token will be automatically validates each post request with
content-types application/x-www-form-urlencoded or multipart/form-data.

=head3 field_name

Filed name in body-parameters sent with post request, where this module will try
to find csrf token, when validate_post is enabled.

=head3 error_status

Error with this status will be send if validate_post is enabled.

=head3 error_message

Error with this message will be send if validate_post is enabled.

=head1 HOOKS

=head3 after_validate_csrf

Fires if validate_post is enabled. After validating the token but before sending the error.

    # Two arguments: Dancer2 app + module args.
    hook after_validate_csrf => sub {
        my ($app, $args) = @_;
        log $args;
        redirect '/error';
    };

    # Args structure.
    $args = {
        success       => $success,
        referer       => $referer,
        error_status  => $error_status,
        error_message => $error_message,
    };

You could change $args values by ref, then module will continue to operate with the changed values.

=head1 OTHER USEFUL PLUGINS

=over 4

=item *
L<Dancer2::Plugin::FormValidator|https://metacpan.org/pod/Dancer2::Plugin::FormValidator>

=back

=head1 BUGS AND LIMITATIONS

If you find one, please let me know.

=head1 SOURCE CODE REPOSITORY

L<https://github.com/AlexP007/dancer2-plugin-csrfi|https://github.com/AlexP007/dancer2-plugin-csrfi>.

=head1 AUTHOR

Alexander Panteleev <alexpan at cpan dot org>.

=head1 LICENSE AND COPYRIGHT

This software is copyright (c) 2022 by Alexander Panteleev.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.

=cut



( run in 1.487 second using v1.01-cache-2.11-cpan-39bf76dae61 )