There are a number of ways of implementing users and groups in Perl scripts. By using Lincoln Stein's
user_manage you can tie it into Apache's authentication system, and use .htpasswd files or a database as a backend, among other options. In this way you get the following benefits:
1) You get one user management system valid both for cgi<->database scripts and html files (with .htaccess files in the protected directories for html files)
2) You get a ready-made management user interface in user_manage to manage users and groups, user_manage also allows you to store more items for each user than name and passwd.
Here is some code, taken largely from the POD, that implements an authentication system with Apache's htpasswd system in a perl script. (I'm working on it right now so /msg me if you want some session handling code, how to get groups, etc..).
#!/usr/bin/perl
use HTTPD::Authen;
print qq§Content-type: text/plain\n\n§;
$auth = new HTTPD::Authen(DBType=>"Text",DB=>"/path/to/passwd_file/use
+r_manage/users/passwd", Server=>"Apache");
$authen = new HTTPD::Authen::Basic($auth);
if($authen->check("jeorgen", "foo")) {
print "Well, the passwords match at least\n";
}
else {
print "Password mismatch! Intruder alert! Intruder alert!\n";
}
/jeorgen
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.