Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
apache authentication with active directory
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
mstamat
Tux's lil' helper
Tux's lil' helper


Joined: 09 May 2002
Posts: 130
Location: Greece

PostPosted: Fri Jun 01, 2007 3:28 pm    Post subject: apache authentication with active directory Reply with quote

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
View user's profile Send private message
keyson
l33t
l33t


Joined: 10 Jun 2003
Posts: 830
Location: Sweden

PostPosted: Fri Jun 01, 2007 3:35 pm    Post subject: Reply with quote

Hi

To read:
http://www.trustix.org/wiki/index.php/Active_Directory_Authentication_with_Apache
that ref to this:
http://thomas-howard.com/Reference/Articles/Apache+AD/
Back to top
View user's profile Send private message
mstamat
Tux's lil' helper
Tux's lil' helper


Joined: 09 May 2002
Posts: 130
Location: Greece

PostPosted: Fri Jun 01, 2007 3:47 pm    Post subject: Reply with quote

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
View user's profile Send private message
keyson
l33t
l33t


Joined: 10 Jun 2003
Posts: 830
Location: Sweden

PostPosted: Fri Jun 01, 2007 4:27 pm    Post subject: Reply with quote

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
View user's profile Send private message
mstamat
Tux's lil' helper
Tux's lil' helper


Joined: 09 May 2002
Posts: 130
Location: Greece

PostPosted: Wed Jun 06, 2007 11:52 am    Post subject: Reply with quote

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
View user's profile Send private message
keyson
l33t
l33t


Joined: 10 Jun 2003
Posts: 830
Location: Sweden

PostPosted: Wed Jun 06, 2007 9:32 pm    Post subject: Reply with quote

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
View user's profile Send private message
keyson
l33t
l33t


Joined: 10 Jun 2003
Posts: 830
Location: Sweden

PostPosted: Thu Jun 07, 2007 11:55 am    Post subject: Reply with quote

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
View user's profile Send private message
mstamat
Tux's lil' helper
Tux's lil' helper


Joined: 09 May 2002
Posts: 130
Location: Greece

PostPosted: Thu Jun 07, 2007 12:15 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum