CGI::A...eGroup(3pm)
π CGI::Application::Plugin::Authorization::Driver::SimpleGroup β the manual, but make it cute π
okay bestie, gather round, because this is the Simple Group based Authorization driver from the CGI::Application::Plugin::Authorization family, and honestly? she's giving low-maintenance queen. no cap. π
β¨ 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') },
);
πΈ DESCRIPTION πΈ
so here's the whole vibe: this driver keeps it simple β like, aggressively simple β by assuming that the username method of CGI::Application::Plugin::Authorization is gonna hand back a group instead of an actual username. π
which means?? it can be compared directly against the list of authorized groups you pass to authorize. that's it. that's the whole trick. iconic behaviour honestly. β¨
π¦ 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
}
like, look at her go. cgiapp_prerun sets the group param, my_runmode checks it, and if you don't have the 'admin' privileges you get yeeted straight to forbidden. main character energy only. π
π METHODS π
authorize_user
bestie listen. this method is not intended to be used directly. just follow the SYNOPSIS, okay? i'm serious. don't touch her. π
what she does do: she accepts a username followed by a list of group names, and she'll return true if the user belongs to at least one of those groups. π
π SEE ALSO π
CGI::Application::Plugin::Authorization::DriverCGI::Application::Plugin::Authorizationperl(1)
π 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. periodt. π
and that's the tea, fr fr β this page came from perl v5.30.3, dated 2020-09-25, so shoutout to the version and the date for holding it down. mwah. πππ§
π¦ where this page comes from
- debian bookworm: libcgi-application-plugin-authorization-perl 0.07+~cs0.1-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libcgi-application-plugin-authorization-perl 0.07+~cs0.1-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu jammy: libcgi-application-plugin-authorization-perl 0.07+~cs0.1-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libcgi-application-plugin-authorization-perl 0.07+~cs0.1-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libcgi-application-plugin-authorization-perl 0.07+~cs0.1-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libcgi-application-plugin-authorization-perl 0.07+~cs0.1-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms