I am converting some scripts over from cgi to mod_perl with the help of Lincoln/Doug's book. Also doing some hacking to do with user authentication.

From what I can work out, if I make scripts run by giving them a Location directive and providing a handler, I then get the option of authenticating with:

my ($res, $sentPw) = $r->get_basic_auth_pw;

which is neat, as I can then control access to content on any basis I want (rather than per dirctory as with .htaccess). I like it.

But it's actually much easier to port my scripts using Apache::Registry - partly because it fakes the CGI environment, but also because I can just invent a new file extension for my scripts, then rename and retest them one by one - instead of needing to make a <Location> directive per script. Is there then any way to get access back to the request object in the scripts to do basic auth at will?

mod_perl is pretty neat stuff, but it takes some figuring at first ...


In reply to basic auth under Apache::Registry by danmcb

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.