> In my PerlAuthenHandler I need to send back the WWW-Authenticate-line.
> I use $r->headers_out("WWW-Authenticate" => 'basic realm => "MyName"').
> But if i returned from the Handler with "return AUTH_REQUIRED" , Apache
> doesn't send this line in the header.

This is (one of) the relevant sections in *my* AuthenHandler:

    unless (length $acctid) {
        # no auth information
        $r->note_basic_auth_failure;
        $r->log_reason("no user provided", $r->filename);
        return AUTH_REQUIRED;
    }

It actually has several sections like that, for different criteria.  But
what is important here is the Apache method call
$r->note_basic_auth_failure().  This is the method that is responsible for
setting the right WWW-Authenticate header.  If your AuthHandler is for Basic
Auth (with the prompting from the browser), then the Realm should already be
configured in the httpd.conf, e.g.

<Location /stats>
  AuthName "Stats"
  AuthType Basic
  PerlAuthenHandler       +Stat::Auth
</Location>

Just to pick a tiny nit, the header you are providing is incorrect:

WWW-Authenticate: basic realm => "MyName"   # <-- yours
WWW-Authenticate: Basic realm="Stats"       # <-- just pulled this off of a
server

Hope this helps!

L8r,
Rob

Reply via email to