NAME
Plack::Middleware::Access - don't allow to open your app depending on the remote ip and other parameters
SYNOPSIS
# in your app.psgi
use Plack::Builder;
builder {
enable "Access" rules => [ allow => "goodhost.com",
allow => sub { <some code that returns true or false> },
allow => "192.168.1.5",
deny => "192.168.1.0/24",
allow => "192.0.0.10",
deny => "all" ];
$app;
};
DESCRIPTION
This middleware intended for restricting access to your app by some users. It is very similar with allow/deny directives in web-servers.
CONFIGURATION
- rules
-
rules
is an ARRAYREF of rules. Each rule consists of directiveallow
ordeny
and their argument. Rules are checked in the order of their record to the first match. If no rule matched then user have access to app.Argument for the rule is a one of four possibilites:
- "all"
-
Always matched. Typical use-case is a deny => "all" in the end of rules.
- remote_host
-
Matches on domain or subdomain of remote_host if it can be resolved.
- ip
-
Matches on one ip or ip range. See Net::IP for detailed description of possible variants.
- code
-
You can pass an arbitrary coderef for checking some specific params of request such as user browser and so on. This function takes
$env
as parameter.
- deny_page
-
It is a CODEREF to function that accepts an
$env
and returns PSGI-compliant response. By default middleware returns page with 403 status.
AUTHORS
Yury Zavarin yury.zavarin@gmail.com
.
LICENSE
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.