Apache...Factory(3pm)
π Apache2::SiteControl::UserFactory π
ok so bestie, welcome to the UserFactory page β this is part of the User Contributed Perl Documentation and it's fr fr one of the load-bearing pieces of Apache2::SiteControl. let's get into it π«Ά
β¨ NAME β¨
Apache2::SiteControl::UserFactory β user factory/persistence, aka the place where user objects get born and where their little souls get saved π
πΈ DESCRIPTION πΈ
so this class has two jobs and it does them both: it creates user objects (peep Apache2::SiteControl::User for those) and it handles all the interfacing between those objects and a persistent session store. the default implementation is out here using Apache::Session::File to write all the user's various attributes to disk. slay.
now, if you wanna do your own user management? iconic. then you leave the User class alone, and you subclass only this factory. but listen, there are methods you must implement, no skipping, this is the vibe check:
makeUser($$)β this one gets called with the Apache Request object, the username, the password, and every othercredential_#field from the login form. it has to create and return an instance ofApache2::SiteControl::User(usingnew... seeUser), and store that info β plus the session key stored in cookie format in the request β in some kind of permanent storage. this gets called in response to a login, so it should invalidate any existing session for the given user name (that way a user can only be logged in once). and it must return the key to use as the browser session key, orundefif it couldn't create the user. no key, no vibes πfindUser($$)β this one gets handed the apache request and the session key (the one you defined inmakeUser). it's called every single time a "logged in" user makes a request. in other words: the user objects are not persistent in memory, every request gets a brand new "copy" of the state, it's giving amnesia but make it security β¨. so this method takes that session key (which was stored in a browser cookie) and figures out which user to restore. your implementation is required to look up the user by the session key, recreate anApache2::SiteControl::Userobject and return it. and it must restore all user attributes that have been saved viasaveAttribute(below). all of them bestie. all.invalidate($$)β this one gets the apache request object and a previously created user object. it should delete the user object from permanent store so that a future request to find that user fails unlessmakeUserhas been called to recreate it. the session ID (which you made up inmakeUser) is available from$user->{sessionid}.saveAttribute($$$)β this one is automatically called whenever a user has a new attribute value. the incoming arguments are the apache request, the user object, and the name of the attribute to save (you can read it with$user->getAttribute($name)). this method must save the attribute in such a way that later calls tofindUserwill be able to restore the attribute to the user object that is created. the session id you created for this user (inmakeUser) is available in$user->{sessionid}. write it down, keep it safe, periodt πΎ
π Apache Config Directives π
here's the list of configuration variables you can set with apache's PerlSetVar to configure the behavior of this class. so many knobs, we love options π
SiteControlDebug(default0) β debug mode. turn it on when things are weird.SiteControlLocks(default/tmp) β where the locks are stored.SiteControlSessions(default/tmp) β where the session data is stored.SiteControlUsermap(defaultnone) β where the usernames are mapped to session files. required if you want multiple session detection. if it's unset, a single userid can be used to log in multiple times simultaneously. iykyk.SiteControlUserFactory(default:Apache2::SiteControl::UserFactory) β an implementation like this module.UserObjectSaveOtherCredentials(default:0) β indicates that other form data from the login screen (credential_2,credential_3, etc.) should be saved in the session data. the keys will becredential_2, etc. name of the user factory to use when making user objects. these are useful if your web application has other login choices (i.e. service, database, etc.) that you need to know about at login.UserObjectSavePassword(default0) β indicates that the password should be saved in the local session data, so that it's available to other parts of the web app (and not just the auth system). this might be necessary if you're logging the user in and out of services on the back end (like in webmail and database apps). πUserObjectPasswordCipher(defaultCAST5) β the CBC cipher used for encrypting the user passwords in the session files (seeCrypt::CBCfor info on allowed ciphers... this value is passed directly toCrypt::CBC->new). if you're saving user passwords, they will be encrypted when stored in the apache session files. this gives a little bit of added security, and makes the apache config the only sensitive file (since that's where you configure the key itself) instead of every random session file that's laying around on disk. iconic security behavior, honestly.
there's a global variable in this package called $encryption_key, which will be used if this variable is not set. the suggested method is to set the encryption key during server startup using a random value (i.e. from /dev/random), so that all server forks will inherit the value. cute AND smart π§
UserObjectPasswordKeyβ the key to use for encryption of the passwords in the session files. seeUserObjectPasswordCipherabove.
π₯ little reminder: the encryption stuff above only matters when you're actually saving passwords. if you're not, congrats, less to worry about.
π¦ SEE ALSO π¦
Apache2::SiteControl::UserApache::SiteControl::PermissionManagerApache2::SiteControl::RuleApache::SiteControl
go read those too bestie, they're the whole friend group π«Ά
π AUTHOR π
this module was written by Tony Kay, <tkay@uoregon.edu>. legend behavior.
π COPYRIGHT AND LICENSE π
Apache2::SiteControl is covered by the GPL. that's the whole license section, short and sweet π
and that's a wrap!! this page came from the perl docs, perl v5.26.2, dated 2018-08-31 β shoutout to the version and the date for holding it down. now go build something cute β¨ππ
π¦ where this page comes from
- debian trixie: libapache2-sitecontrol-perl 1.05-2 Β· GPL-1.0-or-later
- ubuntu jammy: libapache2-sitecontrol-perl 1.05-2 Β· GPL-1.0-or-later
- ubuntu noble: libapache2-sitecontrol-perl 1.05-2 Β· GPL-1.0-or-later
- ubuntu resolute: libapache2-sitecontrol-perl 1.05-2 Β· 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