Jaap has asked for the wisdom of the Perl Monks concerning the following question:

Would it be possible to use Apache's mod_auth but with a default, anonymous user?
I now have this in my .htaccess:
AuthType Basic AuthName "Formula Student Wiki" AuthUserFile /home/formulas/.htpasswd require valid-user
But what if i want to allow a normal, anonymous, not-logged-in user to access my Perl wiki too (which is the same executable)? Is that possible?

Replies are listed 'Best First'.
Re: [OT] apache authentication default user?
by Golo (Friar) on Oct 24, 2004 at 20:30 UTC
    you could limit the "require valid-user" to some methods only by putting it into a <limit> section:
    <Limit POST> Require valid-user </Limit>
    This should prevent unauthenticated users from posting (if you make sure posting is only doable via POST and not via GET of course ;)
    Or you could simply create a guest account (e.g. user guest with pw guest).

    Update see http://httpd.apache.org/docs-2.0/mod/core.html#limit for more details
    Update 2: mod_auth_anon could be of particular interrest for you
      Hmm thanks... that helps. Here's a follow-up question: How do i override the
      HTTP/1.1 200 OK
      That apache sends? I want to send a 401.
Re: [OT] apache authentication default user?
by dws (Chancellor) on Oct 25, 2004 at 03:22 UTC
    But what if i want to allow a normal, anonymous, not-logged-in user to access my Perl wiki too (which is the same executable)? Is that possible?

    It is certainly possible to do something like giving write access to logged-in users while allowing anonymous users only read access. Try

    <Files "login.cgi"> <Limit GET> require valid-user </Limit> </Files>
    The login CGI merely redirects back to the referrer, since Apache will have done the grunt work of checking passwords. Then, in your Wiki scripts, require a logged-in user before allowing write operations.