Apache Form Based Authentication with LDAP
I have Apache 2.4 (httpd) on Red Hat 9.0. I have basic authentication working with ldap. It gives popup box that asks for username and password. Users log in and can browse the protected folder, /var/www/html/private. This is good. So now I want to change that so that I can present a custom login form.
This what I currently have.
<Directory /var/www/html/private>
AuthType Basic
AuthName "Login"
AuthBasicAuthoritative off
AuthBasicProvider ldap
AuthLDAPURL "ldap://DC:389/OU=Users,dc=x,dc=com?sAMAccountName?sub?(objectClass=*)"
Require valid-user
AuthLDAPBindDN username
AuthLDAPBindPassword pAsSwOrD
</Directory>
I am trying to follow:
https://blog.sensecodons.com/2023/01/use-custom-login-page-when-using-apache.html
This is what I tried to add
<Directory "/do-login.html">
SetHandler form-login-handler
AuthFormLoginRequiredLocation "login.html"
AuthFormLoginSuccessLocation "/admin/index.html"
AuthFormProvider ldap
AuthUserFile /dev/null
AuthType form
AuthName "Admin"
Session On
SessionCookieName session path=/
</Directory>
and I changed AuthType in my first directive to 'Form'
I have a form:
<form method="POST" action="/do-login.html">
Username: <input type="text" name="httpd_username" value="" />
Password: <input type="password" name="httpd_password" value="" />
<input type="submit" name="login" value="Login" />
</form>
This is not working for me, it keeps sending me back to the login.html .
What is do-login.html supposed to look like?
How can I make this custom login form work?
thanks.