Custom Authentication handler for mod_auth_form

apache-2.4authentication

Apache 2.3/2.4 has mod_auth_form that allows to display a HTML form for users to login. Can I, instead of using a plain HTML form use an application server to provide the form (J2EE, node.js, PHP, Vert.x etc) and the authentication logic and just return the session cookie (how would that need to look like?)

Best Answer

Yes. But you need to use input fields with name = httpd_username and httpd_password (and .htaccess rights as well)

/secret/path/.htaccess

AuthFormLoginRequiredLocation /login.html
AuthFormLoginSuccessLocation /secret/path/
AuthFormProvider file
AuthUserFile /before/www/root/.htpasswd
AuthType form
AuthName "My server!"
Session On
SessionCookieName session path=/secret/path/
SessionCryptoPassphrase SomEtH1n9

/logout/.htaccess

AuthName "My server!"
AuthFormLogoutLocation /logout/
Session On
SessionCookieName session path=/secret/path/
SessionCryptoPassphrase SomEtH1n9

p.s.: don't use "secret" word from Apache Docs as a passphrase ;)

Related Topic