CGI-Application-Plugin-Authorization-0.07/0000755000175000017500000000000010762435304017021 5ustar ceesceesCGI-Application-Plugin-Authorization-0.07/META.yml0000644000175000017500000000244710762435304020301 0ustar ceescees--- name: CGI-Application-Plugin-Authorization version: 0.07 author: - 'Cees Hek ' abstract: |- Authorization framework for CGI::Application license: perl requires: CGI::Application: 4 Class::ISA: 0 UNIVERSAL::require: 0 recommends: Apache::Htgroup: 0 CGI::Application::Plugin::Authentication: 0 build_requires: Test::Exception: 0 Test::More: 0 Test::Warn: 0 provides: CGI::Application::Plugin::Authorization: file: lib/CGI/Application/Plugin/Authorization.pm version: 0.07 CGI::Application::Plugin::Authorization::Driver: file: lib/CGI/Application/Plugin/Authorization/Driver.pm CGI::Application::Plugin::Authorization::Driver::DBI: file: lib/CGI/Application/Plugin/Authorization/Driver/DBI.pm CGI::Application::Plugin::Authorization::Driver::Dummy: file: lib/CGI/Application/Plugin/Authorization/Driver/Dummy.pm CGI::Application::Plugin::Authorization::Driver::Generic: file: lib/CGI/Application/Plugin/Authorization/Driver/Generic.pm CGI::Application::Plugin::Authorization::Driver::HTGroup: file: lib/CGI/Application/Plugin/Authorization/Driver/HTGroup.pm CGI::Application::Plugin::Authorization::Driver::SimpleGroup: file: lib/CGI/Application/Plugin/Authorization/Driver/SimpleGroup.pm generated_by: Module::Build version 0.26 CGI-Application-Plugin-Authorization-0.07/Changes0000644000175000017500000000274210762435304020321 0ustar ceesceesRevision history for Perl extension CGI::Application::Plugin::Authorization. 0.07 - Allow for code-refs to be provided to 'authz_runmodes', so that you can create more elaborate authorization restrictions. - Rebuilt/simplified test suite for 'authz_runmodes'. - squelch 'uninitialized value' warnings in SimpleGroup Driver (matt -at- summersault.com) 0.06 - Add 'authz_runmodes' method which can register runmodes that should be protected (George Hartzell) - Perform redirection the same way that CAP::Authentication does. (Graham TerMarsch) 0.05 Fri Jun 16 19:48:43 EDT 2006 - Fix caching of named configs (reported by Michael Petnuch) 0.04 Wed Mar 29 21:03:24 EST 2006 - New SimpleGroup driver provided by Mark Stosberg (See docs for usage) - Implemented the __USERNAME__ and __GROUP__ constraint variables in the DBI driver which were already documented in the examples given in the Authorization module docs - the DBI driver was assuming that a USERNAME option was being passed in, which could result in an invalid SQL statement (Hugh Esco) 0.03 Sun Feb 5 18:10:30 EST 2006 - Lots of doc patches (Mark Stosberg) - Remove the DSN option in the DBI driver and suggest that users us the CGI::Application::Plugin::DBH module instead (Mark Stosberg) 0.02 Mon Oct 31 11:56:09 EST 2005 - Add DBI Driver - updated examples to conform to the new DBI driver 0.01 - original version CGI-Application-Plugin-Authorization-0.07/Build.PL0000644000175000017500000000117410762435304020320 0ustar ceesceesuse Module::Build; Module::Build->new( module_name => 'CGI::Application::Plugin::Authorization', license => 'perl', requires => { 'CGI::Application' => 4, 'Class::ISA' => 0, 'UNIVERSAL::require' => 0, }, recommends => { 'CGI::Application::Plugin::Authentication' => 0, 'Apache::Htgroup' => 0, }, build_requires => { 'Test::More' => 0, 'Test::Warn' => 0, 'Test::Exception' => 0, }, create_makefile_pl => 'traditional', dist_author => 'Cees Hek ', add_to_cleanup => [qw(t/sqlite.db)], )->create_build_script; CGI-Application-Plugin-Authorization-0.07/MANIFEST0000644000175000017500000000133310762435304020152 0ustar ceesceesBuild.PL Changes lib/CGI/Application/Plugin/Authorization.pm lib/CGI/Application/Plugin/Authorization/Driver.pm lib/CGI/Application/Plugin/Authorization/Driver/DBI.pm lib/CGI/Application/Plugin/Authorization/Driver/Dummy.pm lib/CGI/Application/Plugin/Authorization/Driver/Generic.pm lib/CGI/Application/Plugin/Authorization/Driver/HTGroup.pm lib/CGI/Application/Plugin/Authorization/Driver/SimpleGroup.pm Makefile.PL MANIFEST This list of files META.yml README t/01_basic.t t/02_config.t t/03_username.t t/04_forbidden.t t/05_authz_runmodes.t t/50_driver.t t/50_driver_dbi.t t/50_driver_generic.t t/50_driver_htgroup.t t/50_driver_simplegroup.t t/98_pod.t t/99_pod_coverage.t t/htgroup t/htgroup2 t/Invalid.pm t/TestAppDriver.pm CGI-Application-Plugin-Authorization-0.07/t/0000755000175000017500000000000010762435304017264 5ustar ceesceesCGI-Application-Plugin-Authorization-0.07/t/04_forbidden.t0000644000175000017500000000434410762435304021715 0ustar ceescees#!/usr/bin/perl use Test::More tests => 3; use Test::Exception; use Scalar::Util; use strict; use warnings; use lib './t'; { { package TestAppForbidden; use base qw(CGI::Application); use CGI::Application::Plugin::Authorization; sub setup { my $self = shift; $self->start_mode('one'); $self->run_modes([qw(one)]); } sub one { my $self = shift; return $self->authz->forbidden; } } $ENV{CGI_APP_RETURN_ONLY} = 1; my $cgiapp = TestAppForbidden->new(); my $results = $cgiapp->run; like($results, qr/Forbidden<\/title>/, "authz_forbidden worked correctly"); } { { package TestAppForbiddenRunmode; use base qw(CGI::Application); use CGI::Application::Plugin::Authorization; __PACKAGE__->authz->config( FORBIDDEN_RUNMODE => 'myforbidden', ); sub setup { my $self = shift; $self->start_mode('one'); $self->run_modes([qw(one myforbidden)]); } sub one { my $self = shift; return $self->authz->forbidden; } sub myforbidden { return 'myforbidden runmode'; } } $ENV{CGI_APP_RETURN_ONLY} = 1; my $cgiapp = TestAppForbiddenRunmode->new(); my $results = $cgiapp->run; like($results, qr/myforbidden runmode/, "forbidden returned the custom runmode"); } { { package TestAppForbiddenURL; use base qw(CGI::Application); use CGI::Application::Plugin::Authorization; __PACKAGE__->authz->config( FORBIDDEN_URL => '/myforbidden.html', ); sub setup { my $self = shift; $self->start_mode('one'); $self->run_modes([qw(one)]); } sub one { my $self = shift; return $self->authz->forbidden; } sub myforbidden { return 'myforbidden runmode'; } } $ENV{CGI_APP_RETURN_ONLY} = 1; my $cgiapp = TestAppForbiddenURL->new(); my $results = $cgiapp->run; like($results, qr/Location:\s+\/myforbidden\.html/, "forbidden returned the custom URL"); } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������CGI-Application-Plugin-Authorization-0.07/t/htgroup2������������������������������������������������0000644�0001750�0001750�00000000077�10762435304�020765� 0����������������������������������������������������������������������������������������������������ustar �cees����������������������������cees�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������othergroup2: testuser otheruser testgroup2: otheruser testuser �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������CGI-Application-Plugin-Authorization-0.07/t/50_driver_dbi.t�����������������������������������������0000644�0001750�0001750�00000007616�10762435304�022100� 0����������������������������������������������������������������������������������������������������ustar �cees����������������������������cees�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������#!/usr/bin/perl use Test::More; use lib qw(t); eval "use DBD::SQLite"; plan skip_all => "DBD::SQLite required for this test" if $@; plan tests => 22; use strict; use warnings; our $DBNAME = 't/sqlite.db'; unlink $DBNAME if -e $DBNAME; my $dbh = DBI->connect( "dbi:SQLite:dbname=$DBNAME", "", "" ); $dbh->do(<<""); CREATE TABLE account ( id INTEGER, name VARCHAR(20) ) $dbh->do(<<""); INSERT INTO account VALUES (1, 'testuser'); $dbh->do(<<""); CREATE TABLE task ( id INTEGER, userid INTEGER, name VARCHAR(20) ) $dbh->do(<<""); INSERT INTO task VALUES (1, 1, 'task1'); $dbh->do(<<""); INSERT INTO task VALUES (2, 1, 'task2'); $dbh->do(<<""); CREATE TABLE ip ( id INTEGER, userid INTEGER, address VARCHAR(20) ) $dbh->do(<<""); INSERT INTO ip VALUES (1, 1, '10.0.0.1'); $dbh->do(<<""); INSERT INTO ip VALUES (2, 1, '10.0.0.2'); { package TestAppDriverDBISimple; use base qw(TestAppDriver); __PACKAGE__->authz->config( DRIVER => [ 'DBI', DBH => $dbh, TABLE => ['account A', 'task T'], JOIN_ON => 'A.id = T.userid', USERNAME => 'A.name', CONSTRAINTS => { 'T.name' => '__PARAM_1__' }, ], GET_USERNAME => sub { 'testuser' }, ); } my $cgiapp = TestAppDriverDBISimple->new; my $authz = $cgiapp->authz; my ($driver) = $authz->drivers; isa_ok($driver, 'CGI::Application::Plugin::Authorization::Driver::DBI'); can_ok($driver, 'authorize_user'); ok($driver->authorize_user('testuser', 'task1'), 'Successful authorization'); ok(! $driver->authorize_user('testuser', 'bastask'), 'Failed authorization'); ok(! $driver->authorize_user('baduser', 'task1'), 'Failed authorization'); TestAppDriverDBISimple->run_authz_success_tests( [qw(task1)], [qw(task2)] ); TestAppDriverDBISimple->run_authz_failure_tests( [qw(badtask)], [qw(badtask otherbadtask)] ); { package TestAppDriverDBIGroup; use base qw(TestAppDriver); __PACKAGE__->authz->config( DRIVER => [ 'DBI', DBH => $dbh, TABLE => ['account A', 'task T'], JOIN_ON => 'A.id = T.userid', CONSTRAINTS => { 'A.name' => '__USERNAME__', 'T.name' => '__GROUP__' }, ], GET_USERNAME => sub { 'testuser' }, ); } TestAppDriverDBIGroup->run_authz_success_tests( [qw(task1)], [qw(task2)] ); TestAppDriverDBIGroup->run_authz_failure_tests( [qw(badtask)], [qw(badtask otherbadtask)] ); { package TestAppDriverDBISQL; use base qw(TestAppDriver); __PACKAGE__->authz->config( DRIVER => [ 'DBI', DBH => $dbh, SQL => 'SELECT count(*) FROM account JOIN task ON (account.id = task.userid) WHERE account.name = ? AND task.name = ? ', ], GET_USERNAME => sub { 'testuser' }, ); } TestAppDriverDBISQL->run_authz_success_tests( [qw(task1)], [qw(task2)] ); TestAppDriverDBISQL->run_authz_failure_tests( [qw(badtask)], [qw(otherbadtask)] ); { package TestAppDriverDBIComplex; use base qw(TestAppDriver); __PACKAGE__->authz->config( DRIVER => [ 'DBI', DBH => $dbh, TABLE => [qw(account task ip)], JOIN_ON => 'account.id = task.userid AND account.id = ip.userid', USERNAME => 'account.name', CONSTRAINTS => { 'task.name' => '__PARAM_2__', 'ip.address' => '__PARAM_1__', }, ], GET_USERNAME => sub { 'testuser' }, ); } TestAppDriverDBIComplex->run_authz_success_tests( [qw(10.0.0.1 task1)], [qw(10.0.0.2 task2)] ); TestAppDriverDBIComplex->run_authz_failure_tests( [qw(badip task1)], [qw(10.0.0.1 badtask)], [qw(task1)] ); ������������������������������������������������������������������������������������������������������������������CGI-Application-Plugin-Authorization-0.07/t/01_basic.t����������������������������������������������0000644�0001750�0001750�00000006146�10762435304�021041� 0����������������������������������������������������������������������������������������������������ustar �cees����������������������������cees�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������#!/usr/bin/perl use Test::More tests => 18; use Test::Exception; use Scalar::Util; BEGIN { require_ok('CGI::Application::Plugin::Authorization') }; use lib './t'; use strict; use warnings; { package TestAppBasic; use base qw(CGI::Application); use CGI::Application::Plugin::Authorization; } { package TestAppBasicNOTCA; use Test::More; sub new { return bless {}, 'TestAppBasicNOTCA'; } SKIP: { eval "use Test::Warn"; skip "Test::Warn required for this test", 1 if $@; #### Disable since Sub::Uplevel 0.09 spits out useless warnings under perl 5.8.8 #warning_like( sub { CGI::Application::Plugin::Authorization->import() }, # qr/Calling package is not a CGI::Application module so not setting up the prerun hook/, # "warning when the plugin is used in a non-CGIApp module"); }; { local $SIG{__WARN__} = sub {}; # supress all warnings for the next line CGI::Application::Plugin::Authorization->import(); }; Test::Exception::throws_ok( sub { TestAppBasicNOTCA->new->authz }, qr/CGI::Application::Plugin::Authorization->instance must be called with a CGI::Application object/, "instance dies when called passed non CGI::App module" ); } { my $authz = TestAppBasic->authz; isa_ok($authz, "CGI::Application::Plugin::Authorization"); my $authz2 = TestAppBasic->authz; isa_ok($authz2, "CGI::Application::Plugin::Authorization"); ok($authz ne $authz2, "calling ->authz as a class method multiple times gives different objects"); my $authz3 = TestAppBasic->authz('named'); isa_ok($authz3, "CGI::Application::Plugin::Authorization"); like($authz3->{name}, qr/named/, "returned object has a unique name"); my $authz4 = TestAppBasic->authz('named'); isa_ok($authz4, "CGI::Application::Plugin::Authorization"); ok($authz3 ne $authz4, "calling ->authz('named') as a class method multiple times gives different objects"); } my $t1_obj = TestAppBasic->new(); my $authz = $t1_obj->authz; my $authz_again = $t1_obj->authz; my $authz_named = $t1_obj->authz('named'); isa_ok($authz, 'CGI::Application::Plugin::Authorization'); ok(Scalar::Util::refaddr($authz) != Scalar::Util::refaddr($authz_named), "Named objects have different address"); ok(Scalar::Util::refaddr($t1_obj->authz) != Scalar::Util::refaddr($authz_named), "Caching named objects works correctly"); my $t2_obj = TestAppBasic->new(); my $authz2 = $t2_obj->authz; isa_ok($authz2, 'CGI::Application::Plugin::Authorization'); ok(Scalar::Util::refaddr($authz) != Scalar::Util::refaddr($authz2), "Objects have different address"); is(Scalar::Util::refaddr($authz), Scalar::Util::refaddr($authz_again), "Objects have same address"); throws_ok(sub { CGI::Application::Plugin::Authorization->instance }, qr/CGI::Application::Plugin::Authorization->instance must be called with a CGI::Application object/, "instance dies when called incorrectly"); # Check default Dummy driver isa_ok($authz->drivers, 'CGI::Application::Plugin::Authorization::Driver::Dummy'); ok($authz->authorize, 'Dummy authorizes everything'); ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������CGI-Application-Plugin-Authorization-0.07/t/TestAppDriver.pm����������������������������������������0000644�0001750�0001750�00000001357�10762435304�022364� 0����������������������������������������������������������������������������������������������������ustar �cees����������������������������cees�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������package TestAppDriver; use base qw(CGI::Application); use CGI::Application::Plugin::Authorization; use Test::More; # # These tests should pass with the parameters that were passed # sub run_authz_success_tests { my $class = shift; my @testdata = @_; my $cgiapp = $class->new(); foreach my $data (@testdata) { # Successful authz ok($cgiapp->authz->authorize(@$data), 'successful authz'); } } # # These tests should fail with the parameters that were passed # sub run_authz_failure_tests { my $class = shift; my @testdata = @_; my $cgiapp = $class->new(); foreach my $data (@testdata) { # Failed authz ok(!$cgiapp->authz->authorize(@$data), 'failed authz'); } } 1; ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������CGI-Application-Plugin-Authorization-0.07/t/50_driver_generic.t�������������������������������������0000644�0001750�0001750�00000002762�10762435304�022753� 0����������������������������������������������������������������������������������������������������ustar �cees����������������������������cees�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������#!/usr/bin/perl use Test::More; use Test::Exception; use lib qw(t); plan tests => 6; use strict; use warnings; { package TestAppDriverGeneric; use base qw(TestAppDriver); my %groupmap = ( testuser => 'testgroup', ); __PACKAGE__->authz->config( DRIVER => [ 'Generic', sub { return $groupmap{ $_[0] } eq $_[1] ? 1 : 0 } ], GET_USERNAME => sub { 'testuser' }, ); } TestAppDriverGeneric->run_authz_success_tests( [qw(testgroup)], [qw(othertestgroup testgroup)] ); TestAppDriverGeneric->run_authz_failure_tests( [qw(badgroup)], [qw(badgroup otherbadgroup)] ); { package TestAppDriverGenericBadSub; use base qw(TestAppDriver); my %groupmap = ( testuser => 'testgroup', ); __PACKAGE__->authz->config( DRIVER => [ 'Generic' ], GET_USERNAME => sub { 'testuser' }, ); } throws_ok { TestAppDriverGenericBadSub->authz->authorize('testgroup') } qr/The Generic driver requires a subroutine reference as its only option/, "Generic driver dies with non CODE driver option"; { package TestAppDriverGenericNoSub; use base qw(TestAppDriver); my %groupmap = ( testuser => 'testgroup', ); __PACKAGE__->authz->config( DRIVER => [ 'Generic', 'BADVALUE' ], GET_USERNAME => sub { 'testuser' }, ); } throws_ok { TestAppDriverGenericNoSub->authz->authorize('testgroup') } qr/The Generic driver requires a subroutine reference as its only option/, "Generic driver dies with non CODE driver option"; ��������������CGI-Application-Plugin-Authorization-0.07/t/50_driver.t���������������������������������������������0000644�0001750�0001750�00000003274�10762435304�021256� 0����������������������������������������������������������������������������������������������������ustar �cees����������������������������cees�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������#!/usr/bin/perl use Test::More; use Test::Exception; use lib qw(t); plan tests => 8; use strict; use warnings; { package TestAppDriverBasic; use base qw(TestAppDriver); __PACKAGE__->authz->config( DRIVER => [ [ 'Dummy', PARAM1 => 'param1', PARAM2 => 'param2' ], [ 'Generic', sub { 1 } ], ], ); } my $cgiapp = TestAppDriverBasic->new; my @drivers = $cgiapp->authz->drivers; isa_ok($drivers[0], 'CGI::Application::Plugin::Authorization::Driver::Dummy'); isa_ok($drivers[1], 'CGI::Application::Plugin::Authorization::Driver::Generic'); is($drivers[0]->find_option('PARAM2'), 'param2', 'find_option returns correct parameter'); is($drivers[0]->find_option('PARAM1'), 'param1', 'find_option returns correct parameter'); is($drivers[0]->find_option('PARAM'), undef, 'find_option returns undef when parameter not found'); throws_ok { CGI::Application::Plugin::Authorization::Driver->authorize_user } qr/authorize_user must be implemented in the subclass/, "authorize_user dies unless overriden in a subclass"; { package TestAppDriverInvalid; use base qw(TestAppDriver); __PACKAGE__->authz->config( DRIVER => [ [ 'Invalid' ], ], ); } throws_ok { TestAppDriverInvalid->new->authz->authorize('testgroup') } qr/Could not create new Invalid object/, "die with invalid driver"; { package TestAppDriverNonExistant; use base qw(TestAppDriver); __PACKAGE__->authz->config( DRIVER => [ [ 'NonExistant::Driver' ], ], ); } throws_ok { TestAppDriverNonExistant->new->authz->authorize('testgroup') } qr/Driver NonExistant::Driver can not be found/, "die with invalid driver"; ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������CGI-Application-Plugin-Authorization-0.07/t/50_driver_simplegroup.t���������������������������������0000644�0001750�0001750�00000001205�10762435304�023674� 0����������������������������������������������������������������������������������������������������ustar �cees����������������������������cees�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������#!/usr/bin/perl use Test::More; use Test::Exception; use lib qw(t); plan tests => 4; use strict; use warnings; { package TestAppDriverSimpleGroup; use base qw(TestAppDriver); __PACKAGE__->authz->config( DRIVER => 'SimpleGroup', GET_USERNAME => sub { return $_[0]->cgiapp->param('group') }, ); sub cgiapp_init { my $self = shift; $self->param('group' => 'testgroup'); } } TestAppDriverSimpleGroup->run_authz_success_tests( [qw(testgroup)], [qw(othertestgroup testgroup)] ); TestAppDriverSimpleGroup->run_authz_failure_tests( [qw(badgroup)], [qw(badgroup otherbadgroup)] ); �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������CGI-Application-Plugin-Authorization-0.07/t/05_authz_runmodes.t�������������������������������������0000644�0001750�0001750�00000017476�10762435304�023043� 0����������������������������������������������������������������������������������������������������ustar �cees����������������������������cees�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������#!/usr/bin/perl use Test::More tests => 15; use Test::Exception; use Scalar::Util; use strict; use warnings; use lib './t'; $ENV{CGI_APP_RETURN_ONLY} = 1; ############################################################################### # Define a test application package. # # Using this test package still requires that: # - we call 'start_mode()' explicitly to set the initial run-mode # - we call 'authz->authz_runmodes()' to set the authorization rules ############################################################################### { package TestApp; use base qw(CGI::Application); use CGI::Application::Plugin::Authorization; sub setup { my $self = shift; $self->run_modes( [qw( test_regexp test_coderef test_string test_all )] ); $self->authz->config( DRIVER => [ 'Generic', sub { my ($username, $group) = @_; return ($group eq 'ok'); }, ] ); } sub test_regexp { return 'test_regexp' }; sub test_coderef { return 'test_coderef' }; sub test_string { return 'test_string' }; sub test_all { return 'test_all' }; } ############################################################################### # Make sure that "authz_runmodes()" sets up the runmodes consistently, # regardless of whether we pass in a list of entries or a list of list-refs. # # If this works, we only need to concern ourselves with testing the interface # in one fashion from here on out. authz_runmodes_sets_up_consistently: { my $app = TestApp->new(); $app->authz->authz_runmodes( ['listref' => 'for'], ['compatibility' => 'with'], ['0.06' => 'interface'], ); $app->authz->authz_runmodes( 'newer' => 'interface', 'allows' => 'for', 'listrefs' => 'to', 'be' => 'absent', ); my @authz = $app->authz->authz_runmodes(); my @expect = ( ['listref' => 'for'], ['compatibility' => 'with'], ['0.06' => 'interface'], ['newer' => 'interface'], ['allows' => 'for'], ['listrefs' => 'to'], ['be' => 'absent'], ); is_deeply \@authz, \@expect, 'authz_runmodes() is consistent'; } ############################################################################### # Authz runmode definition: string authz_runmode_string: { test_allow: { my $app = TestApp->new(); $app->start_mode( 'test_string' ); $app->authz->authz_runmodes( 'test_string' => 'ok', ':all' => 'fail', ); my $res = $app->run(); like $res, qr/test_string/, 'runmode definition: string (allow)'; } test_forbid: { my $app = TestApp->new(); $app->start_mode( 'test_string' ); $app->authz->authz_runmodes( 'test_string' => 'fail', ':all' => 'ok', ); my $res = $app->run(); like $res, qr/Forbidden/, 'runmode definition: string (forbid)'; } } ############################################################################### # Authz runmode definition: regexp authz_runmode_regexp: { test_allow: { my $app = TestApp->new(); $app->start_mode( 'test_regexp' ); $app->authz->authz_runmodes( qr/regexp/ => 'ok', ':all' => 'fail', ); my $res = $app->run(); like $res, qr/test_regexp/, 'runmode definition: regexp (allow)'; } test_allow: { my $app = TestApp->new(); $app->start_mode( 'test_regexp' ); $app->authz->authz_runmodes( qr/regexp/ => 'fail', ':all' => 'ok', ); my $res = $app->run(); like $res, qr/Forbidden/, 'runmode definition: regexp (forbid)'; } } ############################################################################### # Authz runmode definition: coderef authz_runmode_coderef: { test_allow: { my $app = TestApp->new(); $app->start_mode( 'test_coderef' ); $app->authz->authz_runmodes( sub { $_[0] =~ /coderef/ }, 'ok', ':all' => 'fail', ); my $res = $app->run(); like $res, qr/test_coderef/, 'runmode definition: coderef (allow)'; } test_forbid: { my $app = TestApp->new(); $app->start_mode( 'test_coderef' ); $app->authz->authz_runmodes( sub { $_[0] =~ /coderef/ }, 'fail', ':all' => 'ok', ); my $res = $app->run(); like $res, qr/Forbidden/, 'runmode definition: coderef (forbid)'; } } ############################################################################### # Authz runmode definition: :all authz_runmode_all: { test_allow: { my $app = TestApp->new(); $app->start_mode( 'test_all' ); $app->authz->authz_runmodes( ':all' => 'ok', ); my $res = $app->run(); like $res, qr/test_all/, 'runmode definition: all (allow)'; } test_forbid: { my $app = TestApp->new(); $app->start_mode( 'test_all' ); $app->authz->authz_runmodes( ':all' => 'fail', ); my $res = $app->run(); like $res, qr/Forbidden/, 'runmode definition: all (forbid)'; } } ############################################################################### # Authz rules: group authz_rules_group: { test_allow: { my $app = TestApp->new(); $app->start_mode( 'test_string' ); $app->authz->authz_runmodes( 'test_string' => 'ok', ':all' => 'fail', ); my $res = $app->run(); like $res, qr/test_string/, 'authz rule: group (allow)'; } test_forbid: { my $app = TestApp->new(); $app->start_mode( 'test_string' ); $app->authz->authz_runmodes( 'test_string' => 'fail', ':all' => 'ok', ); my $res = $app->run(); like $res, qr/Forbidden/, 'authz rule: group (forbid)'; } } ############################################################################### # Authz rules: list-ref of groups authz_rules_group_list: { test_allow: { my $app = TestApp->new(); $app->start_mode( 'test_string' ); $app->authz->authz_runmodes( 'test_string' => [qw(any of these is ok)], ':all' => 'fail', ); my $res = $app->run(); like $res, qr/test_string/, 'authz rule: list-ref of groups (allow)'; } test_forbid: { my $app = TestApp->new(); $app->start_mode( 'test_string' ); $app->authz->authz_runmodes( 'test_string' => [qw(otherwise we just fail)], ':all' => 'ok', ); my $res = $app->run(); like $res, qr/Forbidden/, 'authz rule: list-ref of groups (forbid)'; } } ############################################################################### # Authz rules: coderef authz_rules_coderef: { test_allow: { my $app = TestApp->new(); $app->start_mode( 'test_string' ); $app->authz->authz_runmodes( 'test_string' => sub { 1 }, ':all' => 'fail', ); my $res = $app->run(); like $res, qr/test_string/, 'authz rule: coderef (allow)'; } test_forbid: { my $app = TestApp->new(); $app->start_mode( 'test_string' ); $app->authz->authz_runmodes( 'test_string' => sub { 0 }, ':all' => 'ok', ); my $res = $app->run(); like $res, qr/Forbidden/, 'authz rule: coderef (forbid)'; } } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������CGI-Application-Plugin-Authorization-0.07/t/03_username.t�������������������������������������������0000644�0001750�0001750�00000003366�10762435304�021602� 0����������������������������������������������������������������������������������������������������ustar �cees����������������������������cees�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������#!/usr/bin/perl use Test::More tests => 3; use Scalar::Util; use CGI; use strict; use warnings; use lib './t'; { { package TestAppUsernameSub; use base qw(CGI::Application); use CGI::Application::Plugin::Authorization; } my $cgiapp = TestAppUsernameSub->new(); $cgiapp->authz->config( DRIVER => [ 'Generic', sub { 1 } ], GET_USERNAME => sub { 'get_username' }, ); is($cgiapp->authz->username, 'get_username', 'GET_USERNAME returned the correct username'); } SKIP: { eval "require CGI::Application::Plugin::Authentication"; skip "CGI::Application::Plugin::Authentication required for this test", 1 if $@; { package TestAppUsernameAuthen; use base qw(CGI::Application); use CGI::Application::Plugin::Authorization; CGI::Application::Plugin::Authentication->import; } my $query = CGI->new( { authen_username => 'authentication', authen_password => '123' } ); my $cgiapp = TestAppUsernameAuthen->new( QUERY => $query ); $cgiapp->authen->config( DRIVER => [ 'Generic', { authentication => '123' } ], ); $cgiapp->authz->config( DRIVER => [ 'Generic', sub { 1 } ], ); is($cgiapp->authz->username, 'authentication', 'Authentication provided the correct username'); undef $cgiapp; } { { package TestAppUsernameRemoteUser; use base qw(CGI::Application); use CGI::Application::Plugin::Authorization; } $ENV{REMOTE_USER} = 'remoteuser'; my $cgiapp = TestAppUsernameRemoteUser->new(); $cgiapp->authz->config( DRIVER => [ 'Generic', sub { 1 } ], ); is($cgiapp->authz->username, 'remoteuser', 'REMOTE_USER returned the correct username'); } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������CGI-Application-Plugin-Authorization-0.07/t/Invalid.pm����������������������������������������������0000644�0001750�0001750�00000000052�10762435304�021205� 0����������������������������������������������������������������������������������������������������ustar �cees����������������������������cees�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������package Invalid; sub new { return; } 1; ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������CGI-Application-Plugin-Authorization-0.07/t/50_driver_htgroup.t�������������������������������������0000644�0001750�0001750�00000002006�10762435304�023016� 0����������������������������������������������������������������������������������������������������ustar �cees����������������������������cees�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������#!/usr/bin/perl use Test::More; use Test::Exception; use lib qw(t); eval "use Apache::Htgroup"; plan skip_all => "Apache::Htgroup required for these tests" if $@; plan tests => 6; use strict; use warnings; { package TestAppDriverHTGroup; use base qw(TestAppDriver); __PACKAGE__->authz->config( DRIVER => [ 'HTGroup', 't/htgroup', 't/htgroup2' ], GET_USERNAME => sub { 'testuser' }, ); } TestAppDriverHTGroup->run_authz_success_tests( [qw(testgroup)], [qw(othertestgroup testgroup)], [qw(testgroup2)] ); TestAppDriverHTGroup->run_authz_failure_tests( [qw(badgroup)], [qw(badgroup otherbadgroup)] ); { package TestAppDriverHTGroupNoFile; use base qw(TestAppDriver); __PACKAGE__->authz->config( DRIVER => [ 'HTGroup' ], GET_USERNAME => sub { 'testuser' }, ); } throws_ok { TestAppDriverHTGroupNoFile->authz->authorize('testgroup') } qr/The HTGroup driver requires at least one htgroup file/, "HTGroup driver dies with no htgroup filename"; ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������CGI-Application-Plugin-Authorization-0.07/t/htgroup�������������������������������������������������0000644�0001750�0001750�00000000075�10762435304�020701� 0����������������������������������������������������������������������������������������������������ustar �cees����������������������������cees�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������testgroup: testuser otheruser othergroup: otheruser testuser �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������CGI-Application-Plugin-Authorization-0.07/t/02_config.t���������������������������������������������0000644�0001750�0001750�00000007323�10762435304�021224� 0����������������������������������������������������������������������������������������������������ustar �cees����������������������������cees�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������#!/usr/bin/perl use Test::More tests => 18; use Test::Exception; use Test::Warn; use Scalar::Util; use CGI; use strict; use warnings; use lib qw(t); { package TestAppConfig; use base qw(CGI::Application); use CGI::Application::Plugin::Authorization; } my %config = ( DRIVER => [ 'Generic', sub { 1 } ], FORBIDDEN_RUNMODE => 'forbidden', GET_USERNAME => sub {'cees'}, ); my $cgiapp = TestAppConfig->new; lives_ok { $cgiapp->authz->config(%config) } 'All config parameters accepted'; isa_ok($cgiapp->authz->drivers,'CGI::Application::Plugin::Authorization::Driver::Generic'); %config = ( DRIVER => [ 'Generic', sub { 1 } ], FORBIDDEN_URL => '/forbidden.html', ); lives_ok { TestAppConfig->new->authz->config(%config) } 'All config parameters accepted'; # test DRIVER throws_ok { TestAppConfig->new->authz->config(DRIVER => { }) } qr/parameter DRIVER is not a string or arrayref/, 'config dies when DRIVER is passed a hashref'; lives_ok { TestAppConfig->new->authz->config(DRIVER => 'MODULE' ) } 'config accepts single DRIVER without options'; lives_ok { TestAppConfig->new->authz->config(DRIVER => [ 'MODULE', option => 'parameter' ] ) } 'config accepts single DRIVER with options'; lives_ok { TestAppConfig->new->authz->config(DRIVER => [ [ 'MODULE', option => 'parameter' ], [ 'MODULE', option => 'parameter' ] ] ) } 'config accepts multiple DRIVERs'; # test FORBIDDEN_RUNMODE throws_ok { TestAppConfig->new->authz->config(FORBIDDEN_RUNMODE => { }) } qr/parameter FORBIDDEN_RUNMODE is not a string/, 'config dies when FORBIDDEN_RUNMODE is passed a hashref'; lives_ok { TestAppConfig->new->authz->config(FORBIDDEN_RUNMODE => 'runmode' ) } 'config accepts FORBIDDEN_RUNMODE as a string'; # test FORBIDDEN_URL throws_ok { TestAppConfig->new->authz->config(FORBIDDEN_URL => { }) } qr/parameter FORBIDDEN_URL is not a string/, 'config dies when FORBIDDEN_URL is passed a hashref'; lives_ok { TestAppConfig->new->authz->config(FORBIDDEN_URL => '/' ) } 'config accepts FORBIDDEN_URL as a string'; #### Disable since Sub::Uplevel 0.09 spits out useless warnings under perl 5.8.8 #warning_like { TestAppConfig->new->authz->config(FORBIDDEN_URL => '/forbidden.html', FORBIDDEN_RUNMODE => 'forbidden' ) } qr/authz config warning: parameter FORBIDDEN_URL ignored since we already have FORBIDDEN_RUNMODE/, "FORBIDDEN_URL ignored when FORBIDDEN_RUNMODE is configured"; # test GET_USERNAME throws_ok { TestAppConfig->new->authz->config(GET_USERNAME => { }) } qr/parameter GET_USERNAME is not a CODE reference/, 'config dies when GET_USERNAME is passed a hashref'; lives_ok { TestAppConfig->new->authz->config(GET_USERNAME => sub { 1 } ) } 'config accepts GET_USERNAME as a CODE reference'; # authz->config as a class method lives_ok { TestAppConfig->authz->config(%config) } 'config can be called as a class method'; # authz->config as a class method with hashref lives_ok { TestAppConfig->authz->config(\%config) } 'config can be called with a hashref or hash'; # authz->config with no parameters lives_ok { TestAppConfig->authz->config() } 'current configuration returned'; # authz->config dies when passed an invalid parameter throws_ok { TestAppConfig->new->authz->config(BAD_PARAM => 'foobar' ) } qr/Invalid option\(s\)/, 'config dies when passed an invalid parameter'; # authz->config dies when it is called after the plugin has been initialized my $app = TestAppConfig->new; my $authz = $app->authz; $authz->config( \%config ); $authz->drivers; throws_ok { $authz->config( \%config ) } qr/Calling config after the Authorization object has already been created/, 'config dies when called after initialization with new configuration info'; TODO: { local $TODO = "TestAppConfig->new->authz->config not finished"; } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������CGI-Application-Plugin-Authorization-0.07/t/98_pod.t������������������������������������������������0000644�0001750�0001750�00000000201�10762435304�020544� 0����������������������������������������������������������������������������������������������������ustar �cees����������������������������cees�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������use Test::More; eval "use Test::Pod 1.00"; plan skip_all => "Test::Pod 1.00 required for testing POD" if $@; all_pod_files_ok(); �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������CGI-Application-Plugin-Authorization-0.07/t/99_pod_coverage.t���������������������������������������0000644�0001750�0001750�00000000241�10762435304�022424� 0����������������������������������������������������������������������������������������������������ustar �cees����������������������������cees�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������use Test::More; eval "use Test::Pod::Coverage 1.00"; plan skip_all => "Test::Pod::Coverage 1.00 required for testing POD coverage" if $@; all_pod_coverage_ok(); ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������CGI-Application-Plugin-Authorization-0.07/README����������������������������������������������������0000644�0001750�0001750�00000001355�10762435304�017705� 0����������������������������������������������������������������������������������������������������ustar �cees����������������������������cees�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������CGI::Application::Plugin::Authorization adds the ability to authorize users for specific tasks in your CGI::Application modules. INSTALLATION To install this module, run the following commands: perl Build.PL ./Build ./Build test ./Build install Alternatively, if you do not have Module::Build but you do have 'make', you can used the included Makefile.PL and run the following commands: perl Makefile.PL make make test make install DEPENDENCIES CGI::Application Class::ISA UNIVERSAL::require BUILD DEPENDENCIES Test::More Test::Exception COPYRIGHT AND LICENCE Copyright (C) 2005, SiteSuite This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������CGI-Application-Plugin-Authorization-0.07/lib/������������������������������������������������������0000755�0001750�0001750�00000000000�10762435304�017567� 5����������������������������������������������������������������������������������������������������ustar �cees����������������������������cees�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������CGI-Application-Plugin-Authorization-0.07/lib/CGI/��������������������������������������������������0000755�0001750�0001750�00000000000�10762435304�020171� 5����������������������������������������������������������������������������������������������������ustar �cees����������������������������cees�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������CGI-Application-Plugin-Authorization-0.07/lib/CGI/Application/��������������������������������������0000755�0001750�0001750�00000000000�10762435304�022434� 5����������������������������������������������������������������������������������������������������ustar �cees����������������������������cees�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������CGI-Application-Plugin-Authorization-0.07/lib/CGI/Application/Plugin/�������������������������������0000755�0001750�0001750�00000000000�10762435304�023672� 5����������������������������������������������������������������������������������������������������ustar �cees����������������������������cees�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������CGI-Application-Plugin-Authorization-0.07/lib/CGI/Application/Plugin/Authorization.pm���������������0000644�0001750�0001750�00000065513�10762435304�027102� 0����������������������������������������������������������������������������������������������������ustar �cees����������������������������cees�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������package CGI::Application::Plugin::Authorization; use strict; use vars qw($VERSION); $VERSION = '0.07'; our %__CONFIG; use UNIVERSAL::require; use Scalar::Util; use List::Util qw(first); use Carp; sub import { my $pkg = shift; my $callpkg = caller; { no strict qw(refs); *{ $callpkg . '::authz' } = \&CGI::Application::Plugin::_::Authorization::authz; *{ $callpkg . '::authorization' } = \&CGI::Application::Plugin::_::Authorization::authz; } if ( !UNIVERSAL::isa( $callpkg, 'CGI::Application' ) ) { warn "Calling package is not a CGI::Application module so not setting up the prerun hook. If you are using \@ISA instead of 'use base', make sure it is in a BEGIN { } block, and make sure these statements appear before the plugin is loaded"; } elsif ( !UNIVERSAL::can( $callpkg, 'add_callback' ) ) { warn "You are using an older version of CGI::Application that does not support callbacks, so the prerun method can not be registered automatically (Lookup 'CGI::Application CALLBACKS' in the docs for more info)"; } else { $callpkg->add_callback( prerun => \&prerun_callback ); } } =head1 NAME CGI::Application::Plugin::Authorization - Authorization framework for CGI::Application =head1 SYNOPSIS use base qw(CGI::Application); use CGI::Application::Plugin::Authentication; use CGI::Application::Plugin::Authorization; # default config for runmode authorization __PACKAGE__->authz->config( DRIVER => [ 'HTGroup', FILE => 'htgroup' ], ); # Using a named configuration to distinguish it from # the above configuration __PACKAGE__->authz('dbaccess')->config( DRIVER => [ 'DBI', DBH => $self->dbh, TABLES => ['user', 'access'], JOIN_ON => 'user.id = access.user_id', CONSTRAINTS => { 'user.name' => '__USERNAME__', 'access.table' => '__PARAM_1__', 'access.item_id' => '__PARAM_2__' } ], ); sub admin_runmode { my $self = shift; # User must be in the admin group to have access to this runmode return $self->authz->forbidden unless $self->authz->authorize('admin'); # rest of the runmode ... } sub update_widget { my $self = shift; my $widget = $self->query->param('widget_id'); # Can this user edit this widget in the widgets table? return $self->authz->forbidden unless $self->authz('dbaccess')->authorize(widgets => $widget); # save changes to the widget ... } =head1 DESCRIPTION CGI::Application::Plugin::Authorization adds the ability to authorize users for specific tasks. Once a user has been authenticated and you know who you are dealing with, you can then use this plugin to control what that user has access to. It imports two methods (C<authz> and C<authorization>) into your L<CGI::Application> module. Both of these methods are interchangeable, so you should choose one and use it consistently throughout your code. Through the authz method you can call all the methods of the CGI::Application::Plugin::Authorization plugin. =head2 Named Configurations There could be multiple ways that you may want to authorize actions in different parts of your code. These differences may conflict with each other. For example you may have runmode level authorization that requires that the user belongs to a certain group. But secondly, you may have row level database authorization that requires that the username column of the table contains the name of the current user. These configurations would conflict with each other since they are authorizing using different information. To solve this you can create multiple named configurations, by specifying a unique name to the c<authz> method. __PACKAGE__->authz('dbaccess')->config( DRIVER => [ 'DBI', ... ], ); # later $self->authz('dbaccess')->authorize(widgets => $widget_id); =head1 EXPORTED METHODS =head2 authz -and- authorization These methods are interchangeable and provided for users that either prefer brevity, or clarity. Everything is controlled through this method call, which will return a CGI::Application::Plugin::Authorization object, or just the class name if called as a class method. When using the plugin, you will always first call $self->authz or __PACKAGE__->authz and then the method you wish to invoke. You can create multiple named authorization modules by providing a unique name to the call to authz. This will allow you to handle different types of authorization in your modules. For example, you could use the main configuration to do runmode level authorization, and use a named configuration to manage database row level authorization. =cut { package # Hide from PAUSE CGI::Application::Plugin::_::Authorization; ############################################## ### ### authorization ### ############################################## # # Return an authorization object that can be used # for managing authorization. # # This will return a class name if called # as a class, and a singleton object # if called as an object method # sub authz { my $cgiapp = shift; my $name = shift || '__default__'; if ( ref($cgiapp) ) { return CGI::Application::Plugin::Authorization->instance( ref($cgiapp) . '-' . $name, $cgiapp ); } else { return CGI::Application::Plugin::Authorization->instance( $cgiapp . '-' . $name, $cgiapp ); } } } package CGI::Application::Plugin::Authorization; =head1 METHODS =head2 config This method is used to configure the CGI::Application::Plugin::Authorization module. It can be called as an object method, or as a class method. The following parameters are accepted: =over 4 =item DRIVER Here you can choose which authorization module(s) you want to use to perform the authorization. For simplicity, you can leave off the CGI::Application::Plugin::Authorization::Driver:: part when specifying the DRIVER parameter. If this module requires extra parameters, you can pass an array reference that contains as the first parameter the name of the module, and the required parameters as the rest of the array. You can provide multiple drivers which will be used, in order, to check the permissions until a valid response is received. DRIVER => [ 'DBI', dbh => $self->dbh ], - or - DRIVER => [ [ 'HTGroup', file => '.htgroup' ], [ 'LDAP', binddn => '...', host => 'localhost', ... ] ], =item FORBIDDEN_RUNMODE Here you can specify a runmode that the user will be redirected to if they fail the authorization checks. FORBIDDEN_RUNMODE => 'forbidden' =item FORBIDDEN_URL If your forbidden page is external to this module, then you can use this option to specify a URL that the user will be redirected to when they fail the authorization checks. If both FORBIDDEN_URL and FORBIDDEN_RUNMODE are specified, then the latter will take precedence. FORBIDDEN_URL => 'http://example.com/forbidden.html' =item GET_USERNAME This option allows you to provide a method that should return us the username of the currently logged in user. It will be passed the current authz objects as the only parameter. This is not a required option, and can be omitted if you use the Authentication plugin, or if your authentication system sets $ENV{REMOTE_USER}. GET_USERNAME => sub { my $authz = shift; return $authz->cgiapp->my_username } =back =cut sub config { my $self = shift; my $class = ref $self; die "Calling config after the Authorization object has already been created" if $self->{loaded}; my $config = $self->_config; if (@_) { my $props; if ( ref( $_[0] ) eq 'HASH' ) { my $rthash = %{ $_[0] }; $props = CGI::Application->_cap_hash( $_[0] ); } else { $props = CGI::Application->_cap_hash( {@_} ); } # Check for DRIVER if ( defined $props->{DRIVER} ) { croak "authz config error: parameter DRIVER is not a string or arrayref" if ref $props->{DRIVER} && Scalar::Util::reftype( $props->{DRIVER} ) ne 'ARRAY'; $config->{DRIVER} = delete $props->{DRIVER}; # We will accept a string, or an arrayref of options, but what we # really want is an array of arrayrefs of options, so that we can # support multiple drivers each with their own custom options no warnings qw(uninitialized); $config->{DRIVER} = [ $config->{DRIVER} ] if Scalar::Util::reftype( $config->{DRIVER} ) ne 'ARRAY'; $config->{DRIVER} = [ $config->{DRIVER} ] if Scalar::Util::reftype( $config->{DRIVER}->[0] ) ne 'ARRAY'; } # Check for FORBIDDEN_RUNMODE if ( defined $props->{FORBIDDEN_RUNMODE} ) { croak "authz config error: parameter FORBIDDEN_RUNMODE is not a string" if ref $props->{FORBIDDEN_RUNMODE}; $config->{FORBIDDEN_RUNMODE} = delete $props->{FORBIDDEN_RUNMODE}; } # Check for FORBIDDEN_URL if ( defined $props->{FORBIDDEN_URL} ) { carp "authz config warning: parameter FORBIDDEN_URL ignored since we already have FORBIDDEN_RUNMODE" if $config->{FORBIDDEN_RUNMODE}; croak "authz config error: parameter FORBIDDEN_URL is not a string" if ref $props->{FORBIDDEN_URL}; $config->{FORBIDDEN_URL} = delete $props->{FORBIDDEN_URL}; } # Check for GET_USERNAME if ( defined $props->{GET_USERNAME} ) { croak "authz config error: parameter GET_USERNAME is not a CODE reference" if ref $props->{GET_USERNAME} ne 'CODE'; $config->{GET_USERNAME} = delete $props->{GET_USERNAME}; } # If there are still entries left in $props then they are invalid croak "Invalid option(s) (" . join( ', ', keys %$props ) . ") passed to config" if %$props; } } =head2 authz_runmodes This method takes a list of runmodes that are to be authorized, and the authorization rules for said runmodes. If a user tries to access one of these runmodes, then they will be redirected to the forbidden page unless authorization is granted. The runmode names can be simple strings, regular expressions, coderefs (which are passed the name of the runmode as their only parameter), or special directives that start with a colon. The authorization rules can be simple strings representing the name of the group that the user must be a member of, as a list-ref of group names (of which the user only has to be a member of B<any one of the groups>, or as a code-ref that will be called (with I<no> parameters). This method is cumulative, so if it is called multiple times, the new values are appended to the list of existing entries. It returns a list containing all of the entries that have been configured thus far. B<NOTE:> compatibility with the interface as was defined in 0.06 B<is> preserved. 0.06 allowed for runmodes to be passed in as a list-ref of two-element lists to specify authorization rules. Although this interface is supported, the extra list-refs aren't necessary. =over 4 =item :all - All runmodes in this module will require authorization =back # match all runmodes __PACKAGE__->authz->authz_runmodes( ':all' => 'admin', ); # only protect runmodes one and two __PACKAGE__->authz->authz_runmodes( one => 'admin', two => 'admin', ); # protect only runmodes that start with auth_ __PACKAGE__->authz->authz_runmodes( qr/^authz_/ => 'admin', ); # protect all runmodes that *do not* start with public_ __PACKAGE__->authz->authz_runmodes( qr/^(?!public_)/ => 'admin', ); # preserve the interface from 0.06: __PACKAGE__->authz->authz_runmodes( [':all' => 'admin'], ); =cut sub authz_runmodes { my $self = shift; my $config = $self->_config; $config->{AUTHZ_RUNMODES} ||= []; while (@_) { my ($rm, $group); # extract next runmode/authz rule from args if (ref($_[0]) eq 'ARRAY') { # 0.06 interface; list-ref my $rule = shift @_; ($rm, $group) = @{$rule}; } else { # new interface; list $rm = shift @_; $group = shift @_; } # add authz rule to our config push( @{$config->{AUTHZ_RUNMODES}}, [$rm, $group] ); } return @{$config->{AUTHZ_RUNMODES}}; } =head2 is_authz_runmode This method accepts the name of a runmode, and if that runmode requires authorization (ie the user needs to be a member of a particular group or has to satisfy some other authorization rule) then this method returns the corresponding authorization rule which must be satisfied (which could be either a scalar, a list-ref, or a code-ref, depending on how the rules were defined). =cut sub is_authz_runmode { my $self = shift; my $runmode = shift; foreach my $runmode_info ($self->authz_runmodes) { my ($runmode_test, $rule) = @$runmode_info; if (overload::StrVal($runmode_test) =~ /^Regexp=/) { # We were passed a regular expression return $rule if $runmode =~ $runmode_test; } elsif (ref $runmode_test && ref $runmode_test eq 'CODE') { # We were passed a code reference return $rule if $runmode_test->($runmode); } elsif ($runmode_test eq ':all') { # all runmodes are protected return $rule; } else { # assume we were passed a string return $rule if $runmode eq $runmode_test; } } return undef; } =head2 new This method creates a new L<CGI::Application::Plugin::Authorization> object. It requires as it's only parameter a L<CGI::Application> object. This method should never be called directly, since the C<authz> method that is imported into the L<CGI::Application> module will take care of creating the L<CGI::Application::Plugin::Authorization> object when it is required. =cut sub new { my $class = shift; my $name = shift; my $cgiapp = shift; my $self = {}; bless $self, $class; $self->{name} = $name; $self->{cgiapp} = $cgiapp; Scalar::Util::weaken( $self->{cgiapp} ) if ref $self->{cgiapp}; # weaken circular reference return $self; } =head2 instance This method works the same way as C<new>, except that it returns the same Authorization object for the duration of the request. This method should never be called directly, since the C<authz> method that is imported into the L<CGI::Application> module will take care of creating the L<CGI::Application::Plugin::Authorization> object when it is required. =cut sub instance { my $class = shift; my $name = shift ||''; my $cgiapp = shift; die "CGI::Application::Plugin::Authorization->instance must be called with a CGI::Application object or class name" unless defined $cgiapp && UNIVERSAL::isa( $cgiapp, 'CGI::Application' ); if ( ref $cgiapp ) { # being called from a CGI::Application object $cgiapp->{__CAP_AUTHORIZATION_INSTANCE}->{$name} = $class->new( $name, $cgiapp ) unless defined $cgiapp->{__CAP_AUTHORIZATION_INSTANCE}->{$name}; return $cgiapp->{__CAP_AUTHORIZATION_INSTANCE}->{$name}; } else { # being called from a CGI::Application class return $class->new( $name, $cgiapp ); } } =head2 authorize This method will test to see if the current user has access to the given resource. It will take the given parameters and test them against the DRIVER classes that have been configured. A true return value means the user should have access to the given resource. # is the current user in the admin group if ($self->authz->authorize('admingroup')) { # perform an admin action } =cut sub authorize { my $self = shift; my @params = @_; foreach my $driver ( $self->drivers ) { return 1 if $driver->authorize(@params); } return 0; } =head2 username This method will return the name of the currently logged in user. It uses three different methods to figure out the username: =over 4 =item GET_USERNAME option Use the subroutine provided by the GET_USERNAME option to figure out the current username =item CGI::Application::Plugin::Authentication See if the L<CGI::Application::Plugin::Authentication> plugin is being used, and retrieve the username through this plugin =item REMOTE_USER See if the REMOTE_USER environment variable is set and use that value =back =cut sub username { my $self = shift; my $config = $self->_config; if ( $config->{GET_USERNAME} ) { return $config->{GET_USERNAME}->($self); } elsif ( $self->cgiapp->can('authen') ) { return $self->cgiapp->authen->username; } else { return $ENV{REMOTE_USER}; } } =head2 drivers This method will return a list of driver objects that are used for this authorization instance. =cut sub drivers { my $self = shift; if ( !$self->{drivers} ) { my $config = $self->_config; # Fetch the configuration parameters for the driver(s) my $driver_configs = defined $config->{DRIVER} ? $config->{DRIVER} : [ ['Dummy'] ]; foreach my $driver_config (@$driver_configs) { my ( $drivername, @params ) = @$driver_config; # Load the the class for this driver my $driver_class = _find_delegate_class( 'CGI::Application::Plugin::Authorization::Driver::' . $drivername, $drivername ) || die "Driver " . $drivername . " can not be found"; # Create the driver object my $driver = $driver_class->new( $self, @params ) || die "Could not create new $driver_class object"; push @{ $self->{drivers} }, $driver; } $self->{loaded} = 1; } my $drivers = $self->{drivers}; return @$drivers[ 0 .. $#$drivers ]; } =head2 cgiapp This will return the underlying CGI::Application object. =cut sub cgiapp { return $_[0]->{cgiapp}; } =head2 setup_runmodes This method is called during the prerun stage to register some custom runmodes that the Authentication plugin requires in order to function. =cut sub setup_runmodes { my $self = shift; $self->cgiapp->run_modes( authz_dummy_redirect => \&authz_dummy_redirect ); $self->cgiapp->run_modes( authz_forbidden => \&authz_forbidden ); return; } =head1 CGI::Application CALLBACKS We'll automatically add the C<authz_forbidden> run mode if you are using CGI::Application 4.0 or greater. If you are using an older version of CGI::Application you will need to add it yourself. sub cgiapp_prerun { my $self = shift; $self->run_modes( authz_forbidden => \&CGI::Application::Plugin::Authorization::authz_forbidden, ); } =cut =head2 prerun_callback This method is a CGI::Application prerun callback that will be automatically registered for you if you are using CGI::Application 4.0 or greater. If you are using an older version of CGI::Application you will have to create your own cgiapp_prerun method and make sure you call this method from there. sub cgiapp_prerun { my $self = shift; $self->CGI::Application::Plugin::Authorization::prerun_callback(); } =cut sub prerun_callback { my $self = shift; my $authz = $self->authz; my $rule = undef; # setup the default login and logout runmodes $authz->setup_runmodes; if ($rule = $authz->is_authz_runmode($self->get_current_runmode)) { # This runmode requires authorization my $authz_ok = ref($rule) eq 'CODE' ? $rule->() : ref($rule) eq 'ARRAY' ? first { $self->authz->authorize($_) } @{$rule} : $self->authz->authorize($rule); return $self->authz->redirect_to_forbidden unless ($authz_ok); } } =head2 redirect_to_forbidden This method is be called during the prerun stage if the current user is not authorized, and they are trying to access an authz runmode. It will redirect to the page that has been configured as the forbidden page, based on the value of FORBIDDEN_RUNMODE or FORBIDDEN_URL If nothing is configured then the default forbidden page will be used. =cut sub redirect_to_forbidden { my $self = shift; my $cgiapp = $self->cgiapp; my $config = $self->_config; if ($config->{FORBIDDEN_RUNMODE}) { $cgiapp->prerun_mode($config->{FORBIDDEN_RUNMODE}); } elsif ($config->{FORBIDDEN_URL}) { $cgiapp->header_add(-location => $config->{FORBIDDEN_URL}); $cgiapp->header_type('redirect'); $cgiapp->prerun_mode('authz_dummy_redirect'); } else { $cgiapp->prerun_mode('authz_forbidden'); } } =head2 forbidden This will return a forbidden page. It checks the configuration to see if there is a custom runmode or URL to redirect to, otherwise it calls the builtin authz_forbidden runmode. =cut sub forbidden { my $self = shift; my $cgiapp = $self->cgiapp; my $config = $self->_config; if ( $config->{FORBIDDEN_RUNMODE} ) { my $runmode = $config->{FORBIDDEN_RUNMODE}; return $cgiapp->$runmode(); } elsif ( $config->{FORBIDDEN_URL} ) { $cgiapp->header_add( -location => $config->{FORBIDDEN_URL} ); $cgiapp->header_type('redirect'); return; } else { return authz_forbidden( $self->cgiapp ); } } =head1 CGI::Application RUNMODES =head2 authz_forbidden This runmode is provided if you do not want to create your own forbidden runmode. It will display a simple error page to the user. =cut sub authz_forbidden { my $self = shift; my $q = $self->query; my $html = join( "\n", CGI::start_html( -title => 'Forbidden', #-style => { -code => $self->auth->styles }, ), CGI::h2('Forbidden'), CGI::p('You do not have permission to perform that action'), CGI::end_html(), ); return $html; } =head2 authz_dummy_redirect This runmode is provided for convenience when an external redirect needs to be done. It just returns an empty string. =cut sub authz_dummy_redirect { return ''; } ### ### Helper methods ### sub _find_delegate_class { foreach my $class (@_) { $class->require && return $class; } return; } sub _config { my $self = shift; my $name = $self->{name}; my $config; if ( ref $self->cgiapp ) { $config = $self->{__CAP_AUTHORIZATION_CONFIG} ||= $__CONFIG{$name} || {}; } else { $__CONFIG{$name} ||= {}; $config = $__CONFIG{$name}; } return $config; } =head1 EXAMPLE In a CGI::Application module: package MyCGIApp; use base qw(CGI::Application); use CGI::Application::Plugin::AutoRunmode; use CGI::Application::Plugin::Authentication; use CGI::Application::Plugin::Authorization; # Configure Authentication MyCGIApp->authen->config( DRIVER => 'Dummy', ); MyCGIApp->authen->protected_runmodes(qr/^admin_/); # Configure Authorization (manages runmode authorization) MyCGIApp->authz->config( DRIVER => [ 'DBI', DBH => $self->dbh, TABLES => ['user', 'usergroup', 'group'], JOIN_ON => 'user.id = usergroup.user_id AND usergroup.group_id = group.id', CONSTRAINTS => { 'user.name' => '__USERNAME__', 'group.name' => '__GROUP__', } ], ); MyCGIApp->authz->authz_runmodes( [a_runmode => 'a_group'], [qr/^admin_/ => 'admin'], [':all' => 'all_group'], [sub {my $rm = shift; return ($rm eq "dangerous_rm")} => 'super_group'], ); # Configure second Authorization module using a named configuration __PACKAGE__->authz('dbaccess')->config( DRIVER => [ 'DBI', DBH => $self->dbh, TABLES => ['user', 'access'], JOIN_ON => 'user.id = access.user_id', CONSTRAINTS => { 'user.name' => '__USERNAME__', 'access.table' => '__PARAM_1__', 'access.item_id' => '__PARAM_2__' } ], ); sub start : Runmode { my $self = shift; } sub admin_one : Runmode { my $self = shift; # The user will only get here if they are logged in and # belong to the admin group } sub admin_widgets : Runmode { my $self = shift; # The user will only get here if they are logged in and # belong to the admin group # Can this user edit this widget in the widgets table? my $widget_id = $self->query->param('widget_id'); return $self->authz->forbidden unless $self->authz('dbaccess')->authorize(widgets => $widget_id); } =head1 TODO The module is definately in a usable state, but there are still some parts missing that I would like to add in: =over 4 =item provide easy methods for authorizing runmode access automatically =item allow subroutine attributes to configure authorization for a runmode =item write a tutorial/cookbook to include with the docs =back =head1 BUGS This is alpha software and as such, the features and interface are subject to change. So please check the Changes file when upgrading. =head1 SEE ALSO L<CGI::Application::Plugin::Authentication>, L<CGI::Application>, perl(1) =head1 AUTHOR Cees Hek <ceeshek@gmail.com> =head1 CREDITS Thanks to SiteSuite (http://www.sitesuite.com.au) for funding the development of this plugin and for releasing it to the world. =head1 LICENCE AND COPYRIGHT Copyright (c) 2005, SiteSuite. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 DISCLAIMER OF WARRANTY BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. =cut 1; �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������CGI-Application-Plugin-Authorization-0.07/lib/CGI/Application/Plugin/Authorization/�����������������0000755�0001750�0001750�00000000000�10762435304�026532� 5����������������������������������������������������������������������������������������������������ustar �cees����������������������������cees�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������CGI-Application-Plugin-Authorization-0.07/lib/CGI/Application/Plugin/Authorization/Driver.pm��������0000644�0001750�0001750�00000012616�10762435304�030331� 0����������������������������������������������������������������������������������������������������ustar �cees����������������������������cees�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������package CGI::Application::Plugin::Authorization::Driver; use strict; use warnings; use UNIVERSAL::require; =head1 NAME CGI::Application::Plugin::Authorization::Driver - Base module for building driver classes for CGI::Application::Plugin::Authorization =head1 SYNOPSIS package CGI::Application::Plugin::Authorization::Driver::MyDriver; use base qw(CGI::Application::Plugin::Authorization::Driver); sub authorize_user { my $self = shift; my @params = @_; if ( >>> Valid Access Permissions <<< ) { return 1; } return; } =head1 DESCRIPTION This module is a base class for all driver classes for the L<CGI::Application::Plugin::Authorization> plugin. Each driver class is required to provide only one method to authorize the given parameters. Often this will be a list of groups that the user needs to be a part of, although it could be anything. =head1 METHODS =head2 new This is a constructor that can create a new Driver object. It requires an Authorization object as its first parameter, and any number of other parameters that will be used as options depending on which Driver object is being created. You shouldn't need to call this as the Authorization plugin takes care of creating Driver objects. =cut sub new { my $class = shift; my $self = {}; my $authz = shift; my @options = @_; bless $self, $class; $self->{authz} = $authz; Scalar::Util::weaken($self->{authz}); # weaken circular reference $self->{options} = \@options; $self->initialize; return $self; } =head2 initialize This method will be called right after a new Driver object is created. So any startup customizations can be dealt with here. =cut sub initialize { my $self = shift; # override this in the subclass if you need it return; } =head2 options This will return a list of options that were provided when this driver was configured by the user. =cut sub options { return (@{$_[0]->{options}}) } =head2 find_option This method will search the Driver options for a specific key and return the value it finds. This method assumes that the Driver configuration contains a hash of information. If it does not, then you will have to parse the option manually in the subclass. =cut sub find_option { my $self = shift; my $key = shift; my @options = $self->options; my $marker = 0; foreach my $option (@options) { if ($marker) { return $option; } elsif ($option eq $key) { # We need the next element $marker = 1; } } return; } =head2 authz This will return the underlying L<CGI::Application::Plugin::Authorization> object. In most cases it will not be necesary to access this. =cut sub authz { return $_[0]->{authz} } =head2 username This will return the name of the current logged in user by calling the C<username> method documented in L<CGI::Application::Plugin::Authorization>. =cut sub username { my $self = shift; return $self->authz->username; } =head2 authorize # User must be in the admin group to have access to this runmode return $self->authz->forbidden unless $self->authz->authorize('admin'); This method will verify that the currently logged in user (as found through L<username>) passes the authorization checks based on the given parameters, usually a list of groups. =cut sub authorize { my $self = shift; my @groups = @_; return $self->authorize_user($self->username, @groups); } =head2 authorize_user This method needs to be provided by the driver class. It needs to be an object method that accepts a username, followed by a list of parameters, and will verify that the user passes the authorization checks based on the given parameters. It should return a true value if the checks succeed. =cut sub authorize_user { die "authorize_user must be implemented in the subclass"; } =head1 SEE ALSO L<CGI::Application::Plugin::Authorization>, perl(1) =head1 AUTHOR Cees Hek <ceeshek@gmail.com> =head1 LICENCE AND COPYRIGHT Copyright (c) 2005, SiteSuite. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 DISCLAIMER OF WARRANTY BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. =cut 1; ������������������������������������������������������������������������������������������������������������������CGI-Application-Plugin-Authorization-0.07/lib/CGI/Application/Plugin/Authorization/Driver/����������0000755�0001750�0001750�00000000000�10762435304�027765� 5����������������������������������������������������������������������������������������������������ustar �cees����������������������������cees�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������././@LongLink���������������������������������������������������������������������������������������0000000�0000000�0000000�00000000151�00000000000�011562� L����������������������������������������������������������������������������������������������������ustar �root����������������������������root�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������CGI-Application-Plugin-Authorization-0.07/lib/CGI/Application/Plugin/Authorization/Driver/SimpleGroup.pm������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������CGI-Application-Plugin-Authorization-0.07/lib/CGI/Application/Plugin/Authorization/Driver/SimpleGrou0000644�0001750�0001750�00000004760�10762435304�032005� 0����������������������������������������������������������������������������������������������������ustar �cees����������������������������cees�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������package CGI::Application::Plugin::Authorization::Driver::SimpleGroup; use strict; use warnings; use base qw(CGI::Application::Plugin::Authorization::Driver); =head1 NAME CGI::Application::Plugin::Authorization::Driver::SimpleGroup - Simple Group based Authorization driver =head1 SYNOPSIS use base qw(CGI::Application); use CGI::Application::Plugin::Authorization; __PACKAGE__->authz->config( DRIVER => [ 'SimpleGroup' ], # You are responsible for setting a group param somehow! GET_USERNAME => sub { my $authz = shift; return $authz->cgiapp->session->param('group') }, ); =head1 DESCRIPTION This driver achieves simplicity by assuming that the C<username> method of L<CGI::Application::Plugin::Authorization> will return a group rather than a username. Thus it can be directly compared with the list of authorized groups passed to L<authorize> =head1 EXAMPLE use base qw(CGI::Application); use CGI::Application::Plugin::Authorization; __PACKAGE__->authz->config( DRIVER => [ 'SimpleGroup' ], # You are responsible for setting a group param somehow! GET_USERNAME => sub { my $authz = shift; return $authz->cgiapp->session->param('group'); }, ); sub cgiapp_prerun { my $self = shift; # here is an example of how you could set the # group param that will be tested later if ($ENV{REMOTE_USER} eq 'mark') { $self->session->param('group' => 'admin'); } } sub my_runmode { my $self = shift; # make sure the user has 'admin' privileges return $self->authz->forbidden unless $self->authz->authorize('admin'); # if we get here the user has 'admin' privileges } =head1 METHODS =head2 authorize_user I<This method is not intended to be used directly. Just follow the SYNOPSIS>. This method accepts a username followed by a list of group names and will return true if the user belongs to at least one of the groups. =cut sub authorize_user { my $self = shift; my $username = shift; my @groups = @_; return 0 unless defined $username; foreach my $group (@groups) { next unless defined $group; return 1 if ($username eq $group); } return 0; } =head1 SEE ALSO L<CGI::Application::Plugin::Authorization::Driver>, L<CGI::Application::Plugin::Authorization>, perl(1) =head1 LICENCE AND COPYRIGHT Copyright (c) 2006, Mark Stosberg. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut 1; ����������������CGI-Application-Plugin-Authorization-0.07/lib/CGI/Application/Plugin/Authorization/Driver/Dummy.pm��0000644�0001750�0001750�00000004315�10762435304�031421� 0����������������������������������������������������������������������������������������������������ustar �cees����������������������������cees�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������package CGI::Application::Plugin::Authorization::Driver::Dummy; use strict; use warnings; use base qw(CGI::Application::Plugin::Authorization::Driver); =head1 NAME CGI::Application::Plugin::Authorization::Driver::Dummy - Dummy Authorization driver =head1 SYNOPSIS use base qw(CGI::Application); use CGI::Application::Plugin::Authorization; __PACKAGE__->authz->config( DRIVER => 'Dummy', ); =head1 METHODS =head2 authorize_user This method authorizes always returns true, so every user will be authorized to do every task. It is really only useful for testing purposes, and should not be used in production. =cut sub authorize_user { 1; } =head1 SEE ALSO L<CGI::Application::Plugin::Authorization::Driver>, L<CGI::Application::Plugin::Authorization>, perl(1) =head1 LICENCE AND COPYRIGHT Copyright (c) 2005, SiteSuite. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 DISCLAIMER OF WARRANTY BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. =cut 1; �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������././@LongLink���������������������������������������������������������������������������������������0000000�0000000�0000000�00000000145�00000000000�011565� L����������������������������������������������������������������������������������������������������ustar �root����������������������������root�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������CGI-Application-Plugin-Authorization-0.07/lib/CGI/Application/Plugin/Authorization/Driver/Generic.pm����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������CGI-Application-Plugin-Authorization-0.07/lib/CGI/Application/Plugin/Authorization/Driver/Generic.pm0000644�0001750�0001750�00000005534�10762435304�031706� 0����������������������������������������������������������������������������������������������������ustar �cees����������������������������cees�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������package CGI::Application::Plugin::Authorization::Driver::Generic; use strict; use warnings; use base qw(CGI::Application::Plugin::Authorization::Driver); =head1 NAME CGI::Application::Plugin::Authorization::Driver::Generic - Generic Authorization driver =head1 SYNOPSIS use base qw(CGI::Application); use CGI::Application::Plugin::Authorization; my %groupmap = ( testuser => 'testgroup', ); # See docs for authorize_user below for an explanation __PACKAGE__->authz->config( DRIVER => [ 'Generic', sub { my ($username,$group) = @_; return ($groupmap{$username} eq $group); } ], ); =head1 METHODS =head2 authorize_user This method accepts a username followed by a list of group names and will return true if the user belongs to at least one of the groups. It does this by calling the provided callback with the username and a single group until a match is found. =cut sub authorize_user { my $self = shift; my $username = shift; my @groups = @_; # verify that all the options are OK my ($check) = $self->options; die "The Generic driver requires a subroutine reference as its only option" unless $check && ref $check eq 'CODE'; foreach my $group (@groups) { return 1 if $check->($username, $group); } return 0; } =head1 SEE ALSO L<CGI::Application::Plugin::Authorization::Driver>, L<CGI::Application::Plugin::Authorization>, perl(1) =head1 LICENCE AND COPYRIGHT Copyright (c) 2005, SiteSuite. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 DISCLAIMER OF WARRANTY BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. =cut 1; ��������������������������������������������������������������������������������������������������������������������������������������������������������������������././@LongLink���������������������������������������������������������������������������������������0000000�0000000�0000000�00000000145�00000000000�011565� L����������������������������������������������������������������������������������������������������ustar �root����������������������������root�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������CGI-Application-Plugin-Authorization-0.07/lib/CGI/Application/Plugin/Authorization/Driver/HTGroup.pm����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������CGI-Application-Plugin-Authorization-0.07/lib/CGI/Application/Plugin/Authorization/Driver/HTGroup.pm0000644�0001750�0001750�00000005317�10762435304�031661� 0����������������������������������������������������������������������������������������������������ustar �cees����������������������������cees�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������package CGI::Application::Plugin::Authorization::Driver::HTGroup; use strict; use warnings; use base qw(CGI::Application::Plugin::Authorization::Driver); use Apache::Htgroup; =head1 NAME CGI::Application::Plugin::Authorization::Driver::HTGroup - HTGroup Authorization driver =head1 SYNOPSIS use base qw(CGI::Application); use CGI::Application::Plugin::Authorization; __PACKAGE__->authz->config( DRIVER => [ 'HTGroup', '/etc/apache/myapp/htgroup', '/etc/apache/htgroup' ], ); =head1 METHODS =head2 authorize_user This method accepts a username followed by a list of group names and will return true if the user belongs to at least one of the groups. =cut sub authorize_user { my $self = shift; my $username = shift; my @groups = @_; # verify that all the options are OK my @files = $self->options; die "The HTGroup driver requires at least one htgroup file" unless @files; foreach my $file (@files) { my $htgroup = Apache::Htgroup->load($file); #dies if it can't load the file foreach my $group (@groups) { return 1 if $htgroup->ismember($username, $group); } } return 0; } =head1 SEE ALSO L<CGI::Application::Plugin::Authorization::Driver>, L<CGI::Application::Plugin::Authorization>, perl(1) =head1 LICENCE AND COPYRIGHT Copyright (c) 2005, SiteSuite. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 DISCLAIMER OF WARRANTY BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. =cut 1; �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������CGI-Application-Plugin-Authorization-0.07/lib/CGI/Application/Plugin/Authorization/Driver/DBI.pm����0000644�0001750�0001750�00000025227�10762435304�030731� 0����������������������������������������������������������������������������������������������������ustar �cees����������������������������cees�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������package CGI::Application::Plugin::Authorization::Driver::DBI; use strict; use warnings; use base qw(CGI::Application::Plugin::Authorization::Driver); =head1 NAME CGI::Application::Plugin::Authorization::Driver::DBI - DBI Authorization driver =head1 SYNOPSIS use base qw(CGI::Application); use CGI::Application::Plugin::Authorization; # Simple task based authentication __PACKAGE__->authz->config( DRIVER => [ 'DBI', TABLES => ['account', 'task'], JOIN_ON => 'account.id = task.accountid', USERNAME => 'account.name', CONSTRAINTS => { 'task.name' => '__PARAM_1__', } ], ); if ($self->authz->authorize('editfoo') { # User is allowed access if it can 'editfoo' } =head1 DESCRIPTION This Authorization driver uses the DBI module to allow you to gather authorization information from any database for which there is a DBD module. You can either provide an active database handle, or provide the parameters necesary to connect to the database. =head2 DBH The DBI database handle to use. Defaults to C<$self-E<gt>dbh()>, which is provided and configured through L<CGI::Application::Plugin::DBH|CGI::Application::Plugin::DBH> When describing the database structure you have two options: =over 4 =item TABLE(S), JOIN_ON, USERNAME and CONSTRAINTS: Use these values to describe the table structure, and an sql statement will be automatically generated to query the database =item SQL: just provide one SQL parameters that gives a complete sql statement that will be used to query the database =back Following is a description of all the avaliable parameters: =head2 TABLE(S) Provide either a single table name, or an array of table names. You can give the table names aliases which can be referenced in later columns. TABLE => 'group', - or - TABLES => ['user U', 'group G'], =head2 JOIN_ON If you have specified multiple tables, then you need to provide an SQL expression that can be used to join those tables. JOIN_ON => 'user.id = group.userid', - or - JOIN_ON => 'U.id = G.userid', =head2 USERNAME This should be set to the column name that contains the username. This column will be compared against the currently logged in user. USERNAME => 'name' - or - USERNAME => 'U.name' =head2 CONSTRAINTS Constraints are used to restrict the database query against the options that are passed to the C<authorize> method. In the common case, you will check these parameters against a group permission table, although there is no limit to the number of parameters that can be used. Each constraint can be set to a static value, or it can be set to '__PARAM_n__' where 'n' is the position of the parameter that is passed in to the C<authorize> method. CONSTRAINTS => { 'user.active' => 't', 'group.type' => '__PARAM_1__', 'group.name' => '__PARAM_2__', } =head2 SQL If you need to perform a complex query that can not be defined by the above syntax, then you can provide your own SQL statment where the first placeholder is used to fill in the username, and the rest of the placeholders are filled in using the parameters passed to the authorize method. SQL => 'SELECT count(*) FROM account LEFT JOIN ip ON (account.id = ip.accountid) LEFT JOIN task ON (account.id = task.accountid) WHERE account.name = ? AND (ip.address >> inet ? OR task.name = ?) ', =head1 EXAMPLE # # Example table structure (for PostgreSQL): # CREATE TABLE account ( id SERIAL NOT NULL PRIMARY KEY, name VARCHAR(50) NOT NULL ); CREATE TABLE task ( id SERIAL NOT NULL PRIMARY KEY, accountid INTEGER NOT NULL REFERENCES account(id), name VARCHAR(50) NOT NULL ); CREATE TABLE ip ( id SERIAL NOT NULL PRIMARY KEY, accountid INTEGER NOT NULL REFERENCES account(id), address INET NOT NULL ); INSERT INTO account (name) VALUES ('testuser'); INSERT INTO task (accountid, name) VALUES (1, 'editfoo'); INSERT INTO ip (accountid, address) VALUES (1, '192.168.1.0/24'); # Simple task based authentication __PACKAGE__->authz->config( DRIVER => [ 'DBI', # the handle comes from $self->dbh, via the "DBH" plugin. TABLES => ['account', 'task'], JOIN_ON => 'account.id = task.accountid', USERNAME => 'account.name', CONSTRAINTS => { 'task.name' => '__PARAM_1__', 'task.active' => 't' } ], ); if ($self->authz->authorize('editfoo') { # User is allowed access if they can 'editfoo' } # IP address configuration __PACKAGE__->authz('byIP')->config( DRIVER => [ 'DBI', SQL => 'SELECT count(*) FROM account JOIN ip ON (account.id = ip.accountid) WHERE account.name = ? AND ip.address >> inet ? ', ], ); if ($self->authz('byIP')->authorize($ENV{REMOTE_ADDR}) { # User is allowed to connect from this address } # both together in one test # IP address configuration __PACKAGE__->authz->config( DRIVER => [ 'DBI', SQL => 'SELECT count(*) FROM account JOIN ip ON (account.id = ip.accountid) JOIN task ON (account.id = task.accountid) WHERE account.name = ? AND task.name = ? AND ip.address >> inet ? ', ], ); if ($self->authz->authorize('editfoo', $ENV{REMOTE_ADDR}) { # User is allowed to connect from this address if they can # also 'editfoo' } =head1 METHODS =head2 authorize_user This method accepts a username followed by a list of parameters and will return true if the configured query returns at least one row based on the given parameters. =cut sub authorize_user { my $self = shift; my $username = shift; my @params = @_; # verify that all the options are OK my @_options = $self->options; die "The DBI driver requires a hash of options" if @_options % 2; my %options = @_options; # Get a database handle either one that is given to us, or connect using # the information given in the configuration my $dbh; if ( $options{DBH} ) { $dbh = $options{DBH}; } elsif ( $self->authen->_cgiapp->can('dbh') ) { $dbh = $self->authen->_cgiapp->dbh; } else { die "No DBH or passed to the DBI Driver, and no dbh() method detected"; } # See if the user provided an SQL option if ( $options{SQL} ) { # prepare and execute the SQL my $sth = $dbh->prepare_cached( $options{SQL} ) || die "Failed to prepare SQL statement: " . $dbh->errstr; $sth->execute( $username, @params ) or die $dbh->errstr; # Since we are not pulling specific columns we just check # to see if we matched at least one row my ($count) = $sth->fetchrow_array; $sth->finish; return $count ? 1 : 0; } # Grab the database table names (TABLE and TABLES are synonymous) my $tables = $options{TABLES} || $options{TABLE}; $tables = [$tables] unless ref $tables eq 'ARRAY'; # Process the constraints. # We need to check for values indicate they should be replaced by # a parameter (__PARAM_\d+__) my %constraints; my $used_username = 0; if ( $options{CONSTRAINTS} ) { die "CONSTRAINTS must be a hashref" unless ref $options{CONSTRAINTS} eq 'HASH'; while ( my ( $column, $value ) = each %{ $options{CONSTRAINTS} } ) { if ( $value =~ /^__PARAM_(\d+)__$/ ) { $value = $params[ $1 - 1 ]; } elsif ( $value =~ /^__USERNAME__$/ ) { $value = $username; $used_username = 1; } elsif ( $value =~ /^__GROUP__$/ ) { $value = $params[ 0 ]; } $constraints{$column} = $value; } } # Add in the username constraint if it was provided if ($options{USERNAME}) { $constraints{$options{USERNAME}} = $username; } elsif ( ! $used_username && ! $options{NO_USERNAME} ) { warn "Your configuration did not provide for a match against a username column, make sure to provide the USERNAME option, or use the special __USERNAME__ variable in your CONSTRAINTS"; } # If we have multiple tables, then we need a join constraint my $join_on = $options{JOIN_ON}; # Build the SQL statement my $sql = 'SELECT count(*) FROM ' . join( ', ', @$tables ) . ' WHERE '; my @where; push @where, $join_on if $join_on; push @where, map { $_ . ' = ?' } keys %constraints; $sql .= join( ' AND ', @where ); my @db_values = values %constraints; # prepare and execute the SQL my $sth = $dbh->prepare_cached($sql) || die "Failed to prepare SQL statement: " . $dbh->errstr; $sth->execute(@db_values) or die $dbh->errstr; # Since we are not pulling specific columns we just check # to see if we matched at least one row my ($count) = $sth->fetchrow_array; $sth->finish; return $count ? 1 : 0; } =head1 SEE ALSO L<CGI::Application::Plugin::Authorization::Driver>, L<CGI::Application::Plugin::Authorization>, perl(1) =head1 LICENCE AND COPYRIGHT Copyright (c) 2005, SiteSuite. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 DISCLAIMER OF WARRANTY BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. =cut 1; �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������CGI-Application-Plugin-Authorization-0.07/Makefile.PL�����������������������������������������������0000644�0001750�0001750�00000001245�10762435304�020775� 0����������������������������������������������������������������������������������������������������ustar �cees����������������������������cees�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������# Note: this file was auto-generated by Module::Build::Compat version 0.03 use ExtUtils::MakeMaker; WriteMakefile ( 'PL_FILES' => {}, 'INSTALLDIRS' => 'site', 'NAME' => 'CGI::Application::Plugin::Authorization', 'VERSION_FROM' => 'lib/CGI/Application/Plugin/Authorization.pm', 'PREREQ_PM' => { 'Test::More' => 0, 'CGI::Application' => 4, 'Test::Warn' => 0, 'Test::Exception' => 0, 'Class::ISA' => 0, 'UNIVERSAL::require' => 0 } ) ; �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������