php - HTTP-Authentication with .htpasswd file -


php offers possibility use http-authentication.

however, difficult use .htpasswd-files.

there scripts check .htpasswd file within php (for example this one). however, these scripts quite complex , of them don't support relevant encryption types (like md5 default used program htpasswd).

with standard .htaccess file easier (just authuserfile <.htpasswd-file> needed).

however, avoid explicit .htaccess file , use php instead.

is there easy way check .htpasswd-file using php? can php perhaps "ask" apache if access should granted?

i doubt there direct way ask apache authenticating user, there few workarounds it:

  1. implement missing algos yourself: apr1-md5, sha
  2. use shell_exec("htpasswd -nb $user $password") generate hash , check in .htpasswd file
  3. setup virtual server on internal interface uses .htpasswd file authenticate , perform curl call (with user credentials) it, checking response header (200 authorized, 4xx not authorized)

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -