Any-Daemon-HTTP
view release on metacpan or search on metacpan
lib/Any/Daemon/HTTP/Source.pod view on Meta::CPAN
=back
=head2 Actions
=head1 DETAILS
=head2 Resource restrictions
=head3 Allow access
The L<allow()|Any::Daemon::HTTP::Source/"Permissions"> method handles access rights. When a trueth value is
produced, then access is permitted.
The base class implements access rules via the C<allow> or C<deny> option
of L<new()|Any::Daemon::HTTP::Source/"Constructors">. These parameters are exclusive (which is slightly different
from Apache); you can either allow or deny, but not both at the same time.
B<Be warned> that the access rights are also not inherited from directory
configurations encapsulating this one.
The parameters to C<allow> or C<deny> are an ARRAY with any combination of
=over 4
=item IPv4 and IPv6 address ranges in CIDR notation
=item hostname
=item domain name (leading dot)
=item your own CODE reference, which will be called with the IP address,
the hostname, the session, and the rewritten URI.
=back
B<. Example: new(allow) parameters>
my $vhost = My::VHOST::Class->new( allow =>
[ '192.168.2.1/32 # IPv4 CIDR, single address
, '10/8' # IPv4 CIDR
, '10.0.0.0-10.3.255.255' # IPv4 range
, '::dead:beef:0:0/110' # IPv6 range
, 'www.example.com' # hostname
, '.example.com' # domain and subdomains
, 'example.com' # only this domain
], ...
B<. Example: create own access rules>
If you have an ::VirtualHost extension class, you do this:
sub allow($$$)
{ my ($self, $session, $request, $uri) = @_;
# General rules may refuse access already
$self->SUPER::allow($session, $request, $uri)
or return 0;
# here your own checks
# $session is a Any::Daemon::HTTP::Session
# $request is a HTTP::Request
# $uri is a URI::
1;
}
You may also pass a code-ref to L<new(allow)|Any::Daemon::HTTP::Source/"Constructors">:
my $vhost = Any::Daemon::HTTP::VirtualHost
->new(allow => \&my_rules, ...);
sub my_rules($$$$) # called before each request
{ my ($ip, $host, $session, $uri) = @_;
# return true if access is permitted
}
=head1 SEE ALSO
This module is part of Any-Daemon-HTTP distribution version 0.30,
built on April 06, 2020. Website: F<http://perl.overmeer.net/any-daemon/>
=head1 LICENSE
Copyrights 2013-2020 by [Mark Overmeer]. For other contributors see ChangeLog.
This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
See F<http://dev.perl.org/licenses/>
( run in 0.551 second using v1.01-cache-2.11-cpan-d8267643d1d )