Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apache authentication: Redirect on failure, reliably?

I've set my ErrorDocument 401 to point to my website's account creation page, but not all browsers seem to honor this redirect (Safari).

Also, other browsers (Firefox, Chrome) never quit asking for the password and show the ErrorDocument. This causes a good number of users to give up trying after many password attempts without seeing the account creation page.

Is there any way to make the redirect more reliable, without trashing basic authentication altogether?

like image 717
bukzor Avatar asked Nov 13 '09 03:11

bukzor


People also ask

Is Apache authentication secure?

Apache supports one other authentication method: AuthType Digest . This method is implemented by mod_auth_digest and is much more secure. Most recent browsers support Digest authentication. The AuthName directive sets the Realm to be used in the authentication.

How many types of HTTP authentications are used in the Apache server?

Introduction. HttpClient supports three different types of http authentication schemes: Basic, Digest and NTLM. These can be used to authenticate with http servers or proxies.


1 Answers

The simple answer to your question is no, you can't make this more reliable without implementing custom authentication.

The only way that Firefox and Chrome will display page that you specified in the ErrorDocument 401 directive is if you click cancel button. Also, there is no redirect sent with the 401 HTTP code; rather, it is a content of the document specified with ErrorDocument 401 directive. You can do redirect using HTML meta tag:

<Location "/protected">
    AuthUserFile /path/to/users
    AuthName "This is protected area"
    AuthGroupFile /dev/null
    AuthType Basic
    Require valid-user

    #ErrorDocument 401 /register.html
    ErrorDocument 401 "<html><meta http-equiv=\"refresh\" content=\"0;url=/register.html\"></html>"
</Location>

Possible solutions to your problem are to create custom basic HTTP authentication module or to use language like php that supports basic HTTP authentication hooks

http://php.net/manual/en/features.http-auth.php

like image 180
Boris Avatar answered Oct 10 '22 03:10

Boris