Securing sections of web sites (htaccess, etc.)

Miscellaneous Forums/General Discussion/Securing sections of web sites (htaccess, etc.)

I'm having trouble password protecting the administration section for a web site :(

For some reason, my attempts at htaccess / htpasswd are not working!
I am getting the login window asking me for a username / password, but it does not seem to be reading my .htpasswd file; typing the correct password does not let me enter! (The login window just pops up again).

First off here is the .htaccess file. Seems to be in working order...
AuthUserFile /home/mysite/.htpasswd
AuthName "admin"
AuthType Basic
require valid-user

And here is that .htpasswd file
dhs:myencryptedpassword


If any errors jump out at you, please let me know!

So I gave up on the whole htpasswd end of things and went with PHP sessions instead.
However, it is horrible to work with; I have to go through every single file which I want protected and add a little bit of code to the top. If I don't, that page is open for anyone to mess with. Big problem, since there are /a lot/ of files, and a good chance that some of them will be later replaced by others. (Which do not have the added check).

So, both solutions are bad.
-Is there perhaps a way to tell the server to add a bit to the top of every file within a directory (probably via .htaccess), without me manually making any changes to the actual files?

-Also, a bit less importantly, do you know of a PHP-powered secure login system? I've seen a few, but they tend to be really 'fancy', and they also generally require a MySQL database. (I would be very happy with one that interfaced directly with the web server's htaccess authentication stuff instead of using a bloody database to hold about 3 user accounts). All it really needs is changing passwords / adding users, which I expect exists in just about any such account system.

My wife said she prefers 'Mr Picklesworth'

I presume you're manually doing this because you have no URL security features in the control panel of your hosting package?

Mine works this way:

AuthType Basic
AuthName "Restricted Area"
AuthUserFile "/home/MySite/.htpasswds/MyFolder/passwd"
require valid-user


Could people please at the very least use MD5 Auth?

I'd guess that "/home/mysite/.htpasswd" isn't the proper path.

Maybe check the following:

-is the path to .htpasswd correct?
-is the user running the webservice (httpuser or such) allowed to read the .htpasswd file?
-did you created the encrypted password with the right command?

Should work then...


I'd guess that "/home/mysite/.htpasswd" isn't the proper path.



Correct, that is not the actual path.

:/
I solved it!
My web host was using Frontpage Extensions (duh!), which I have now disabled because I dislike anything with Frontpage in the name.
That shows me, I guess: Know thy web host.
:(

Thanks for the help, though. I did forget to have quote marks around my path to .htpasswd, which I bet Apache would moan about.

Anyhow, the second line of thought still exists. Are there any nice, simple PHP user management systems that tie in to htaccess / htpasswd?