CGI::Application::Plugin::Authorization::Driver::SimpleGroup(3pm)

CGI::Application::Plugin::Authorization::Driver::SimpleGroup3pm

Simple group based authorization driver

Usage

 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') },
 );

Overview

This driver achieves simplicity by assuming that the "username" method of 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 authorize

Examples

 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
 }

Methods

authorize_user

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.

Releases

10 releases since Debian 4.0 (Etch); the text changed 5 times.

  1. 4.0
  2. 5.0
  3. 6.0
  4. 7–8
  5. 9–10
  6. 11–13

From libcgi-application-plugin-authorization-perl 0.07+~cs0.1-1 in Debian 13 (Trixie). Parsed by carta from the page's man source.