View previous topic :: View next topic |
Author |
Message |
mstamat Tux's lil' helper
Joined: 09 May 2002 Posts: 130 Location: Greece
|
Posted: Fri Jun 01, 2007 3:28 pm Post subject: apache authentication with active directory |
|
|
Hi folks,
I'd like to setup apache2 to authenticate users from an existing active directory.
My server has already joined the active directory domain. i.e., I can see all the users using "wbinfo -u" and without being prompted for a password.
Unfortunately, I haven't managed to make Apache authenticate users without entering my username and password (plaintext!) in the .htaccess file. Is there a way to achieve this?
Configuration snippets are most welcome
Cheers _________________ Manolis |
|
Back to top |
|
|
keyson l33t
Joined: 10 Jun 2003 Posts: 830 Location: Sweden
|
|
Back to top |
|
|
mstamat Tux's lil' helper
Joined: 09 May 2002 Posts: 130 Location: Greece
|
Posted: Fri Jun 01, 2007 3:47 pm Post subject: |
|
|
Thanks for the answer keyson, but I've already checked this. It wouldn't work for me because it requires a password in the .htaccess file:
Code: |
...
AuthLDAPBindPassword LDAP_Password
...
|
I have already thought of creating a dummy user with a password that I wouldn't mind to expose in the .htaccess file. Unfortunately, this isn't possible because we have a policy that requires accounts to be associated with a physical person.
However, I noticed this in the first URL you mentioned:
Quote: |
IMPORTANT NOTE: You don't need to use samba. Authentication is performed w/ standard LDAP queries.
|
So, I probably need a way to have Apache use samba (that is already allowed to query the AD) to perform the user authentication. Any ideas (with or without using samba) are welcome.
Cheers _________________ Manolis |
|
Back to top |
|
|
keyson l33t
Joined: 10 Jun 2003 Posts: 830 Location: Sweden
|
Posted: Fri Jun 01, 2007 4:27 pm Post subject: |
|
|
OK.
Then you use winbind and then it should be possible to use mod_auth_pam
to authenticate apache users.
Have tested it but my memory is not so good, i think the mod_auth_pam config is something
like /etc/pam.d/httpd.
What you have to put in this should be something like
auth required /lib/security/pam_winbind.so
account required /lib/security/pam_winbind.so
Check google for any information regarding mod_auth_pam apache and samba
Then you could use a .htaccess with something like.
AuthPAM_Enablead On
require group "DOMAIN\Apacheuser" |
|
Back to top |
|
|
mstamat Tux's lil' helper
Joined: 09 May 2002 Posts: 130 Location: Greece
|
Posted: Wed Jun 06, 2007 11:52 am Post subject: |
|
|
Thanks for your help so far keyson! Now the my setup is almost working, with the exception of checking group membership.
The steps required were:
- Enable mod_auth_pam on apache
- Edit /etc/pam.d/apache2:
Code: |
#%PAM-1.0
auth required pam_winbind.so
account required pam_winbind.so
|
Create an appropriate .htaccess file:
Code: |
# Setup basic authentication with an empty password file.
# Using /dev/null as the authentication file saves us from
# annoying error messages in the Apache error log.
AuthType Basic
AuthName "Top Secret"
AuthUserFile "/dev/null"
# Allow Apache to try other authentication methods if Basic fails.
AuthBasicAuthoritative Off
# Enable PAM authentication.
# Edit /etc/pam.d/apache2 to define what this includes.
AuthPAM_Enabled on
Require valid-user
|
However, using the line you mentioned to require membership to a specific domain group won't work:
Code: |
...
require group "DOMAIN\Apacheuser"
...
|
Do you have any insights on what additional steps might be required for successfully checking group membership? ?
Cheers, _________________ Manolis |
|
Back to top |
|
|
keyson l33t
Joined: 10 Jun 2003 Posts: 830 Location: Sweden
|
Posted: Wed Jun 06, 2007 9:32 pm Post subject: |
|
|
Hi.
You can authenticate by user as I understand.
If i remember right the group must be seen as a local group.
Check by getent group DOMAIN\Apacheuser if it see the group.
If it don't, then:
Check if you have winbind in the /etc/nsswitch.conf for the group.
Like this:
group: files winbind
Don't run any setup like this at the moment, so i can't test it.
Regards |
|
Back to top |
|
|
keyson l33t
Joined: 10 Jun 2003 Posts: 830 Location: Sweden
|
Posted: Thu Jun 07, 2007 11:55 am Post subject: |
|
|
OK
I had to test it. I have a samba server acting as PDC for some students.
I run a separat LDAP server to administrate the users. As I have apache on the
PDC I installed the mod_auth_pam and set it up with your .htaccess.
But i use LDAP to authenticate my users instead of winbind.
Now i noticed something. If i have the line
AuthUserFile "/dev/null"
inside the .htaccess it would not work with 'Require group testgroup'
But if i comment this out, it would grant access to a user in the testgroup.
I made a testgroup in the ldap and added some users to that group and it worked.
So try to comment out the line AuthUserFile "/dev/null" in the .htaccess
Regards |
|
Back to top |
|
|
mstamat Tux's lil' helper
Joined: 09 May 2002 Posts: 130 Location: Greece
|
Posted: Thu Jun 07, 2007 12:15 pm Post subject: |
|
|
Thanks again keyson.
I'm afraid the problem lies with our Active Directory. The group memberships do not seem to be coherent.
Code: |
myserver:~# wbinfo -r mstamat
10002
10003
10004
10001
myserver:~# getent group mygroup
mygroup:x:10002:user1,user2,user3
myserver:~#
|
I.e., while "mygroup" (10002) is listed in my account's entry, my account is not listed in "mygroup"'s entry. So, my current options to overcome this situation are:
- Find a way to update the group members in the Active Directory and persuade its administrators to do it.
- Use require valid-user in the .htaccessUse the require_membership_of option of pam_winbind in /etc/pam.d/apache2 to enforce group membership. In the .htaccess file only a valid-user will be required:
Code: |
#%PAM-1.0
auth required pam_winbind.so require_membership_of=MYDOMAIN\mygroup
account required pam_winbind.so require_membership_of=MYDOMAIN\mygroup
|
I have tested this and it works. However this will work only in the simplest of cases. If you have to check for membership in one of many groups, you just can't do it.
Create a script that does wbinfo -r for all users and then rebuilds the groups locally as text files. The script would run daily as a cron job. (I haven't tested this yet, but I am confident that it would work.)
If anyone familiar with Active Directory reads this, let me know if the first option is possible and how.
Cheers, _________________ Manolis |
|
Back to top |
|
|
|