CatalystX::Usul::Plugin::Controller::TokenValidation - CSRF form tokens


CatalystX-Usul documentation  | view source Contained in the CatalystX-Usul distribution.

Index


Name

Top

CatalystX::Usul::Plugin::Controller::TokenValidation - CSRF form tokens

Version

Top

0.3.$Revision: 576 $

Synopsis

Top

   # In controller base class
   sub end {
      my ($self, $c) = @_;

      if ($c->stash->{token} && $self->can( q(add_token) )) {
         $self->add_token( $c );
      }

      $c->forward( q(render) );
      return;
   }

   # In custom action class
   if ($controller->can( q(validate_token) ) && _should_validate( $c )) {
      unless ($controller->validate_token( $c )) {
         return $self->_invalid_token( @args )
            ? $self->next::method( @rest ) : undef;
      }

      $controller->remove_token( $c );
   }

Description

Top

Generates and validates CSRF form tokens

Subroutines/Methods

Top

add_token

Adds a CSRF token to the form

end

Called by the end method in the base controller, this method calls add_token if the current page should contain a token

remove_token

Removes the validated token from the form so that it is not mistaken for a regular input field

validate_token

Checks to see if the token stored in the session matches the one posted back in the form

Diagnostics

Top

None

Configuration and Environment

Top

None

Dependencies

Top

CatalystX::Usul

Incompatibilities

Top

There are no known incompatibilities in this module

Bugs and Limitations

Top

There are no known bugs in this module. Please report problems to the address below. Patches are welcome

Author

Top

Peter Flanigan, <Support at RoxSoft.co.uk>

License and Copyright

Top


CatalystX-Usul documentation  | view source Contained in the CatalystX-Usul distribution.