paranoid acl -> no permission checks inside of controllers :)
[blog.pm.git] / lib / Catalyst / Plugin / Authorization / ACL / Paranoid.pm
blobd36d24509e61b681b59a74238f6820c3ab25a59e
1 package Catalyst::Plugin::Authorization::ACL::Paranoid;
2 use base qw/Class::Data::Inheritable/;
4 # based upon Catalyst::Plugin::Authorization::ACL;
6 use strict;
7 use warnings;
9 #use NEXT;
10 use Catalyst::Plugin::Authorization::ACL::Paranoid::Engine;
12 use Scalar::Util();
14 BEGIN { __PACKAGE__->mk_classdata( '_acl_engine' ) }
16 sub setup_actions {
17 my $c = shift;
18 my $ret = $c->NEXT::setup_actions( @_ );
20 $c->_acl_engine(
21 Catalyst::Plugin::Authorization::ACL::Paranoid::Engine->new( $c ) );
23 return $ret;
26 sub execute {
27 my ( $c, $class, $action ) = @_;
29 local $NEXT::NEXT{ $c, "execute" };
31 if ( Scalar::Util::blessed( $action ) ) {
32 unless ( $c->_acl_engine->is_allowed( $c, $class, $action ) ) {
33 $c->res->status( 403 );
34 $c->error( 'Access denied' );
35 return;
39 $c->NEXT::execute( $class, $action );
42 sub acl {
43 my ( $c ) = shift;
44 my %rules = @_;
46 use Data::Dumper;
48 $c->_acl_engine->rules( \%rules );
51 =head1 AUTHOR
53 vti
55 =head1 COPYRIGHT
57 This program is free software, you can redistribute it and/or modify it under
58 the same terms as Perl itself.
60 =cut