Apache...::User(3pm)

πŸ“¦
version 1.05 Β· 2 versions
, in debian trixie, ubuntu jammy, ubuntu noble, ubuntu resolute

πŸ’– Apache2::SiteControl::User β€” the manual, but make it make sense πŸ’–

okay bestie, gather round, because we're talking about Apache2::SiteControl::User from the User Contributed Perl Documentation (that's the 3pm family, iykyk) and honestly? it's giving user representation and we're obsessed. ✨


🌸 NAME 🌸

Apache2::SiteControl::User β€” user representations. literally the whole vibe is "who even is this person and what do they get to do". πŸ‘‘


πŸ¦‹ SYNOPSIS πŸ¦‹

my $user = Apache2::SiteControl->getCurrentUser($r);

# $r is the apache request object

# Checking out the user's name:
if($user->getUsername eq 'sam') { ... }

...

# Working with attributes (session persistent data)
my $ssn = $user->getAttribute('ssn');
$user->setAttribute($r, 'ssn', '333-555-6666');

# Removing/invalidating session for the user
$user->logout($r);

see how clean that is?? no notes. πŸ’…


πŸŽ€ DESCRIPTION πŸŽ€

so the SiteControl system has this base concept of a user, and that concept comes with three things, periodt:

  • the user's name
  • persistent attributes (and by persistent we mean persistent via session, bestie, not just vibes)
  • support for user logout

it is assumed that you'll be working from mod_perl, and some of the methods are gonna need an Apache request object. what's the request object even doing there? good question, love that for you β€” some methods use it to coordinate access to the actual session info living in the underlying system. that's how we store attributes and how we implement logout. 🫢

user objects are created by a factory (by default that's Apache2::SiteControl::UserFactory), so heads up: if you subclass User, you absolutely must understand the complete interaction between the factory (which is the one responsible for interfacing with persistence), the SiteControl, etc. like, the whole web of it. no skimming. 😭

the default implementation of User and UserFactory uses AuthCookie to manage the sessions, and Apache::Session::File to store the various details about a user to disk. iconic combo honestly.

if you're using Apache2::SiteControl::User and Apache::SiteControl::UserFactory (which is the default and recommended, so like, do that), then you should configure the following parameters in your apache configuration file:

# This is where the session data files will be stored
SiteControlSessions directory_name
# This is where the locks will be stored
SiteControlLocks directory_name

these two directories should be different, and they should be readable and writable by the apache daemon only. and they must exist before you even try to use SiteControl. like, exist first, ask questions later. πŸ™ˆ


✨ METHODS ✨

  • getUsername β€” get the name that the current user used to log in. that's it, that's the whole thing. πŸ’–
  • getAttribute($name) β€” get the value of a previously stored attribute. returns undef is there is no value. (yes, "is", that's what it says, we're keeping it exactly as it is, no cap.)
  • setAttribute($request, $name, $value) β€” add an attribute (scalar data only, bestie, don't get creative) to the current session. the current apache request object is required here, because that's how we figure out the session. future versions may support more complex storage in the session β€” but that's a future-version problem, not a you problem. this attribute will stay associated with this user until they log out. πŸ¦‹
  • logout($request) β€” log the user out. now listen: if you do not pass the current apache request, then this method will log an error to the apache error logs, and the user's session will continue to exist. so like. pass the request. please. 😭

🌈 SEE ALSO 🌈

  • Apache2::SiteControl::UserFactory
  • Apache::SiteControl::ManagerFactory
  • Apache2::SiteControl::PermissionManager
  • Apache::SiteControl

go read them, they're all part of the same little family. 🧚


πŸ‘‘ AUTHOR πŸ‘‘

this module was written by Tony Kay, <tkay@uoregon.edu>. legend behavior, fr fr. 🌟


this modules is covered by the GNU public license. (and yes, we said "this modules", because that's what it says, and we do not edit the ancestors. πŸ’…)


okay that's the whole page bestie!! this was perl v5.26.2, dated 2018-08-31, and it's the Apache...::User(3pm) page β€” you've officially read the whole thing, I'm so proud of you. go forth and manage your users. slay. πŸŽ€βœ¨πŸ¦‹πŸŒΈ