I'm running Apache 2.4.6-93 on a CentOS 7. What I need is: each user should have their own home directory (achieved via UserDir), but the directories need to be password protected. One user should not be able to see another user's directory.
I was able to setup an authentication using AD this way:
<Directory "/mnt/shared/apache_userdir/*/private_html">
AllowOverride FileInfo AuthConfig Limit Indexes
Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
Require method GET POST OPTIONS
AuthName "Please Login"
AuthBasicProvider ldap
AuthType Basic
AuthLDAPGroupAttribute member
AuthLDAPGroupAttributeIsDN On
AuthLDAPURL ldap://x.x.x.x:389/DC=example,DC=org?sAMAccountName?sub?(objectClass=*)
AuthLDAPBindDN CN=binduser,OU=someou,OU=anotherou,DC=example,DC=org
AuthLDAPBindPassword somepassword
Require ldap-group CN=group-test-1-,OU=someou,OU=anotherou,DC=example,DC=org
This is working. The user can access their home directory using: https://example.com/~username
But the authentication is point to a hardcoded group (in this case: group-test-1). Any user which is member of this group will access other user directories. I could also hardcode some user using Require ldap-user foobar
, but I want this requirement to be dynamic for the user who is accessing the website.
Something like: Require ldap-user %username
Is there a way to get the username in the URL and use it as a variable on this parameter?
Thanks.