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:
- implement missing algos yourself: apr1-md5, sha
- use
shell_exec("htpasswd -nb $user $password")generate hash , check in .htpasswd file - 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
Post a Comment