I want to limit access to certain directories served by Apache. I want the client to have to type a username and password, but then I want Apache to take the username and password that the person typed and pass them as arguments to a python script that I wrote to do the authentication. Then, based on the output of said script, I want Apache to either allow or deny access. Is this possible?
The only way I know of to do this is using
the easiest would be to simply have your authentication system update the password list that Apache uses. Apache comes with all the tools you need to add/update/delete users from either an .htpasswd or .htdigest file (it should be trivial to hook the
Or, you can have
I would personally go this route, as it's more elegant than duplicating your user password hashes (hopefully you're not storing the passwords themselves) in a separate text file, and creating a new authentication system seems like reinventing the wheel.
You can use .htaccess to limit access to certain directories.
You need to create a htpasswd file which you refer to from the .htaccess file
Python: there seems to be a library that can handle htpasswd files:
More about python and htpasswd:
I'm not familiar with python, and I can't give you a complete solution. I think however that it's possible, and probably not too complicated if you're familiar with python, with a bit of googling.