The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Catalyst::Controller::RateLimit - Protect your site from robots

VERSION

See $VERSION

SYNOPSIS

Protects your site from flood, robots and spam.

Checks, if user made more than 30 posts for 30 seconds.

    package MyApp::Controller::Post;
    use parent qw/Catalyst::Controller::RateLimit Catalyst::Controller/; 
        # Catalyst::Controller is not required, but i think, it will look better if you include it
    __PACKAGE__->config(
        rate_limit => {
            max_requests => 30,
            period => 30,
            ban_time => 3600
        }
    );

    sub login_form : Local { #Only check
        my ( $self, $c ) = @_;
        my $is_overrated = $self->is_user_overrated( $c->user->login || $c->request->address );
        if ( $is_overrated ) {
            $c->forward( 'show_captcha' );
        }
        #...
    }

    sub login : Local { #Check and register attempt
        my ( $self, $c ) = @_;
        if ( $self->register_attempt( $c->user->login || $c->request->address ) ) {
            # checking for CAPTCHA
        }
        #...
    }

    sub show_captcha : Local { # If user have reached his limits, it is called
        ... code to add captcha to page ...
    }

DESCRIPTION

Protects critical parts of your site from robots.

NOTES

METHODS

new

is_user_overrated( identifier )

Returns true if user have reached his limits.

register_attempt( identifier )

Returns true if user have reached his limits. And increments number of his attempts.

ACCEPT_CONTEXT

setup

AUTHOR

Andrey Kostenko, <andrey at kostenko.name>

BUGS

Please report any bugs or feature requests to bug-catalyst-plugin-stoprobots at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Catalyst-Plugin-StopRobots. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc Catalyst::Plugin::StopRobots

You can also look for information at:

ACKNOWLEDGEMENTS

COPYRIGHT & LICENSE

Copyright 2008 Andrey Kostenko.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.