home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / xampp / xampp-perl-addon-1.4.9-installer.exe / AuthzLDAP.pm < prev    next >
Encoding:
Text File  |  2002-06-13  |  26.5 KB  |  700 lines

  1. # $Id: AuthzLDAP.pm,v 1.16 2001/07/12 14:18:52 cgilmore Exp $
  2. #
  3. # Author          : Jason Bodnar, Christian Gilmore
  4. # Created On      : Apr 04 12:04:00 CDT 2000
  5. # Status          : Functional
  6. #
  7. # PURPOSE
  8. #    LDAP Group Authentication
  9. #
  10. ###############################################################################
  11. #
  12. # IBM Public License Version 1.0
  13. #
  14. # THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS IBM
  15. # PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR
  16. # DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF
  17. # THIS AGREEMENT.
  18. #
  19. # 1. DEFINITIONS
  20. #
  21. # "Contribution" means:
  22. #
  23. #   a) in the case of International Business Machines Corporation
  24. #   ("IBM"), the Original Program, and
  25. #
  26. #   b) in the case of each Contributor,
  27. #
  28. #   i) changes to the Program, and
  29. #
  30. #   ii) additions to the Program;
  31. #
  32. #   where such changes and/or additions to the Program originate from
  33. #   and are distributed by that particular Contributor. A Contribution
  34. #   'originates' from a Contributor if it was added to the Program by
  35. #   such Contributor itself or anyone acting on such Contributor's
  36. #   behalf. Contributions do not include additions to the Program
  37. #   which: (i) are separate modules of software distributed in
  38. #   conjunction with the Program under their own license agreement,
  39. #   and (ii) are not derivative works of the Program.
  40. #
  41. # "Contributor" means IBM and any other entity that distributes the
  42. # Program.
  43. #
  44. # "Licensed Patents " mean patent claims licensable by a Contributor
  45. # which are necessarily infringed by the use or sale of its
  46. # Contribution alone or when combined with the Program.
  47. #
  48. # "Original Program" means the original version of the software
  49. # accompanying this Agreement as released by IBM, including source
  50. # code, object code and documentation, if any.
  51. #
  52. # "Program" means the Original Program and Contributions.
  53. #
  54. # "Recipient" means anyone who receives the Program under this
  55. # Agreement, including all Contributors.
  56. #
  57. # 2. GRANT OF RIGHTS
  58. #
  59. #   a) Subject to the terms of this Agreement, each Contributor hereby
  60. #   grants Recipient a non-exclusive, worldwide, royalty-free
  61. #   copyright license to reproduce, prepare derivative works of,
  62. #   publicly display, publicly perform, distribute and sublicense the
  63. #   Contribution of such Contributor, if any, and such derivative
  64. #   works, in source code and object code form.
  65. #
  66. #   b) Subject to the terms of this Agreement, each Contributor hereby
  67. #   grants Recipient a non-exclusive, worldwide, royalty-free patent
  68. #   license under Licensed Patents to make, use, sell, offer to sell,
  69. #   import and otherwise transfer the Contribution of such
  70. #   Contributor, if any, in source code and object code form. This
  71. #   patent license shall apply to the combination of the Contribution
  72. #   and the Program if, at the time the Contribution is added by the
  73. #   Contributor, such addition of the Contribution causes such
  74. #   combination to be covered by the Licensed Patents. The patent
  75. #   license shall not apply to any other combinations which include
  76. #   the Contribution. No hardware per se is licensed hereunder.
  77. #
  78. #   c) Recipient understands that although each Contributor grants the
  79. #   licenses to its Contributions set forth herein, no assurances are
  80. #   provided by any Contributor that the Program does not infringe the
  81. #   patent or other intellectual property rights of any other entity.
  82. #   Each Contributor disclaims any liability to Recipient for claims
  83. #   brought by any other entity based on infringement of intellectual
  84. #   property rights or otherwise. As a condition to exercising the
  85. #   rights and licenses granted hereunder, each Recipient hereby
  86. #   assumes sole responsibility to secure any other intellectual
  87. #   property rights needed, if any. For example, if a third party
  88. #   patent license is required to allow Recipient to distribute the
  89. #   Program, it is Recipient's responsibility to acquire that license
  90. #   before distributing the Program.
  91. #
  92. #   d) Each Contributor represents that to its knowledge it has
  93. #   sufficient copyright rights in its Contribution, if any, to grant
  94. #   the copyright license set forth in this Agreement.
  95. #
  96. # 3. REQUIREMENTS
  97. #
  98. # A Contributor may choose to distribute the Program in object code
  99. # form under its own license agreement, provided that:
  100. #
  101. #   a) it complies with the terms and conditions of this Agreement;
  102. #
  103. # and
  104. #
  105. #   b) its license agreement:
  106. #
  107. #   i) effectively disclaims on behalf of all Contributors all
  108. #   warranties and conditions, express and implied, including
  109. #   warranties or conditions of title and non-infringement, and
  110. #   implied warranties or conditions of merchantability and fitness
  111. #   for a particular purpose;
  112. #
  113. #   ii) effectively excludes on behalf of all Contributors all
  114. #   liability for damages, including direct, indirect, special,
  115. #   incidental and consequential damages, such as lost profits;
  116. #   iii) states that any provisions which differ from this Agreement
  117. #   are offered by that Contributor alone and not by any other party;
  118. #   and
  119. #
  120. #   iv) states that source code for the Program is available from such
  121. #   Contributor, and informs licensees how to obtain it in a
  122. #   reasonable manner on or through a medium customarily used for
  123. #   software exchange.
  124. #
  125. # When the Program is made available in source code form:
  126. #
  127. #   a) it must be made available under this Agreement; and
  128. #
  129. #   b) a copy of this Agreement must be included with each copy of the
  130. #   Program.
  131. #
  132. # Each Contributor must include the following in a conspicuous
  133. # location in the Program:
  134. #
  135. #   Copyright ⌐ {date here}, International Business Machines
  136. #   Corporation and others. All Rights Reserved.
  137. #
  138. # In addition, each Contributor must identify itself as the originator
  139. # of its Contribution, if any, in a manner that reasonably allows
  140. # subsequent Recipients to identify the originator of the
  141. # Contribution.
  142. #
  143. # 4. COMMERCIAL DISTRIBUTION
  144. #
  145. # Commercial distributors of software may accept certain
  146. # responsibilities with respect to end users, business partners and
  147. # the like. While this license is intended to facilitate the
  148. # commercial use of the Program, the Contributor who includes the
  149. # Program in a commercial product offering should do so in a manner
  150. # which does not create potential liability for other Contributors.
  151. # Therefore, if a Contributor includes the Program in a commercial
  152. # product offering, such Contributor ("Commercial Contributor") hereby
  153. # agrees to defend and indemnify every other Contributor ("Indemnified
  154. # Contributor") against any losses, damages and costs (collectively
  155. # "Losses") arising from claims, lawsuits and other legal actions
  156. # brought by a third party against the Indemnified Contributor to the
  157. # extent caused by the acts or omissions of such Commercial
  158. # Contributor in connection with its distribution of the Program in a
  159. # commercial product offering. The obligations in this section do not
  160. # apply to any claims or Losses relating to any actual or alleged
  161. # intellectual property infringement. In order to qualify, an
  162. # Indemnified Contributor must: a) promptly notify the Commercial
  163. # Contributor in writing of such claim, and b) allow the Commercial
  164. # Contributor to control, and cooperate with the Commercial
  165. # Contributor in, the defense and any related settlement negotiations.
  166. # The Indemnified Contributor may participate in any such claim at its
  167. # own expense.
  168. #
  169. # For example, a Contributor might include the Program in a commercial
  170. # product offering, Product X. That Contributor is then a Commercial
  171. # Contributor. If that Commercial Contributor then makes performance
  172. # claims, or offers warranties related to Product X, those performance
  173. # claims and warranties are such Commercial Contributor's
  174. # responsibility alone. Under this section, the Commercial Contributor
  175. # would have to defend claims against the other Contributors related
  176. # to those performance claims and warranties, and if a court requires
  177. # any other Contributor to pay any damages as a result, the Commercial
  178. # Contributor must pay those damages.
  179. #
  180. # 5. NO WARRANTY
  181. #
  182. # EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS
  183. # PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
  184. # ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION,
  185. # ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
  186. # MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient
  187. # is solely responsible for determining the appropriateness of using
  188. # and distributing the Program and assumes all risks associated with
  189. # its exercise of rights under this Agreement, including but not
  190. # limited to the risks and costs of program errors, compliance with
  191. # applicable laws, damage to or loss of data, programs or equipment,
  192. # and unavailability or interruption of operations.
  193. #
  194. # 6. DISCLAIMER OF LIABILITY
  195. #
  196. # EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT
  197. # NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT,
  198. # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  199. # (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON
  200. # ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  201. # TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  202. # THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS
  203. # GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
  204. # DAMAGES.
  205. #
  206. # 7. GENERAL
  207. #
  208. # If any provision of this Agreement is invalid or unenforceable under
  209. # applicable law, it shall not affect the validity or enforceability
  210. # of the remainder of the terms of this Agreement, and without further
  211. # action by the parties hereto, such provision shall be reformed to
  212. # the minimum extent necessary to make such provision valid and
  213. # enforceable.
  214. #
  215. # If Recipient institutes patent litigation against a Contributor with
  216. # respect to a patent applicable to software (including a cross-claim
  217. # or counterclaim in a lawsuit), then any patent licenses granted by
  218. # that Contributor to such Recipient under this Agreement shall
  219. # terminate as of the date such litigation is filed. In addition, If
  220. # Recipient institutes patent litigation against any entity (including
  221. # a cross-claim or counterclaim in a lawsuit) alleging that the
  222. # Program itself (excluding combinations of the Program with other
  223. # software or hardware) infringes such Recipient's patent(s), then
  224. # such Recipient's rights granted under Section 2(b) shall terminate
  225. # as of the date such litigation is filed.
  226. #
  227. # All Recipient's rights under this Agreement shall terminate if it
  228. # fails to comply with any of the material terms or conditions of this
  229. # Agreement and does not cure such failure in a reasonable period of
  230. # time after becoming aware of such noncompliance. If all Recipient's
  231. # rights under this Agreement terminate, Recipient agrees to cease use
  232. # and distribution of the Program as soon as reasonably practicable.
  233. # However, Recipient's obligations under this Agreement and any
  234. # licenses granted by Recipient relating to the Program shall continue
  235. # and survive.
  236. #
  237. # IBM may publish new versions (including revisions) of this Agreement
  238. # from time to time. Each new version of the Agreement will be given a
  239. # distinguishing version number. The Program (including Contributions)
  240. # may always be distributed subject to the version of the Agreement
  241. # under which it was received. In addition, after a new version of the
  242. # Agreement is published, Contributor may elect to distribute the
  243. # Program (including its Contributions) under the new version. No one
  244. # other than IBM has the right to modify this Agreement. Except as
  245. # expressly stated in Sections 2(a) and 2(b) above, Recipient receives
  246. # no rights or licenses to the intellectual property of any
  247. # Contributor under this Agreement, whether expressly, by implication,
  248. # estoppel or otherwise. All rights in the Program not expressly
  249. # granted under this Agreement are reserved.
  250. #
  251. # This Agreement is governed by the laws of the State of New York and
  252. # the intellectual property laws of the United States of America. No
  253. # party to this Agreement will bring a legal action under this
  254. # Agreement more than one year after the cause of action arose. Each
  255. # party waives its rights to a jury trial in any resulting litigation.
  256. #
  257. ###############################################################################
  258.  
  259.  
  260. # Package name
  261. package Apache::AuthzLDAP;
  262.  
  263.  
  264. # Required libraries
  265. use strict;
  266. use mod_perl ();
  267. use Apache::Constants ':common';
  268. use Apache::Log ();
  269. use Net::LDAP qw(:all);
  270. use String::ParseWords;
  271.  
  272.  
  273. # Global variables
  274. $Apache::AuthzLDAP::VERSION = '0.61';
  275.  
  276.  
  277. ###############################################################################
  278. ###############################################################################
  279. # check_group: check user membership in group
  280. ###############################################################################
  281. ###############################################################################
  282. sub check_group {
  283.   my ($r, $ld, $basedn, $groupattrtype, $memberattrtype,
  284.       $userinfo, $groups, $nested_groups) = @_;
  285.   my ($group, $grouplist, $member) = undef;
  286.  
  287.   $r->log->debug("check_group: Parsing on $groups");
  288.   $grouplist = String::ParseWords::parse($groups);
  289.  
  290.   foreach $group (@$grouplist) {
  291.     # Look up the group
  292.     my $filter = qq(($groupattrtype=$group));
  293.     $r->log->debug("check_group: Iterating over group $group");
  294.     $r->log->debug("check_group: Using filter: $filter");
  295.     my $msg = $ld->search(base => $basedn, filter => $filter);
  296.     unless ($msg->code == LDAP_SUCCESS) {
  297.       $r->note_basic_auth_failure;
  298.       $r->log_reason("user $userinfo: Could not search for $group: " .
  299.              $msg->code . " " . $msg->error, $r->uri);
  300.       return SERVER_ERROR;
  301.     }
  302.  
  303.     # Did we get any entries?
  304.     unless ($msg->count) {
  305.       $r->log->debug("check_group: user $userinfo: could not find $group");
  306.       next;
  307.     }
  308.  
  309.     # Check the group
  310.     my $entry = $msg->first_entry; # Only want one
  311.     my $dn = $entry->dn;
  312.     next unless ($dn =~ /ou=group/);
  313.     $r->log->debug("check_group: Checking group $dn for $userinfo");
  314.     $msg = $ld->compare($dn, attr => $memberattrtype, value => $userinfo);
  315.     return (OK, $group) if $msg->code == LDAP_COMPARE_TRUE;
  316.  
  317.     # Return undef if nested groups is not set
  318.     $r->log->debug("check_group: Could not find $userinfo in $group");
  319.     next unless $nested_groups =~ /on/i;
  320.  
  321.     # If we did not find the person in the group let's check the groups members
  322.     foreach $member ($entry->get($memberattrtype)) {
  323.       if ($member =~ /ou=group/) {
  324.         # We just want the group's name
  325.         $member =~ s/^[^=]+=([^,]+).*/$1/;
  326.         my ($result, $group) = check_group($r, $ld, $basedn,
  327.                                            $groupattrtype, $memberattrtype,
  328.                                            $userinfo,
  329.                                            "\"$member\"", $nested_groups);
  330.         return (OK, $group) if $result == OK;
  331.       } elsif (!($member =~ /ou=/)) {
  332.         my ($result, $group) = check_group($r, $ld, $basedn,
  333.                                            $groupattrtype, $memberattrtype,
  334.                                            $userinfo,
  335.                                            "\"$member\"", $nested_groups);
  336.         return (OK, $group) if $result == OK;
  337.       }
  338.     }
  339.   }
  340.  
  341.   # We've fallen through without finding the user in the group
  342.   $r->log_reason("Could not find $userinfo in $groups", $r->uri);
  343.   return AUTH_REQUIRED;
  344. }
  345.  
  346.  
  347. ###############################################################################
  348. ###############################################################################
  349. # handler: hook into Apache/mod_perl API
  350. ###############################################################################
  351. ###############################################################################
  352. sub handler {
  353.   my $r = shift;
  354.   return OK unless $r->is_initial_req; # only the first internal request
  355.   my $requires = $r->requires;
  356.   return OK unless $requires;
  357.  
  358.   my $username = $r->connection->user;
  359.  
  360.   # The required patch was not introduced in 1.26. It is no longer
  361.   # promised to be included in any timeframe. Commenting out.
  362.   # if ($mod_perl::VERSION < 1.26) {
  363.     # I shouldn't need to use the below lines as this module
  364.     # should never be called if there was a cache hit.  Since
  365.     # set_handlers() doesn't work properly until 1.26 (according
  366.     # to Doug MacEachern) I have to work around it by cobbling
  367.     # together cheat sheets for the previous and subsequent
  368.     # handlers in this phase. I get the willies about the
  369.     # security implications in a general environment where you
  370.     # might be using someone else's handlers upstream or
  371.     # downstream...
  372.   my $group_sent = $r->subprocess_env("REMOTE_GROUP");
  373.   my $cache_result = $r->notes('AuthzCache');
  374.   if ($group_sent && $cache_result eq 'hit') {
  375.     $r->log->debug("handler: upstream cache hit for ",
  376.            "user=$username, group=$group_sent");
  377.     return OK;
  378.   # }
  379.   }
  380.  
  381.   # Clear for paranoid security precautions
  382.   $r->subprocess_env(REMOTE_GROUP => undef);
  383.  
  384.   my $basedn = $r->dir_config('AuthzBaseDN');
  385.   my $groupattrtype = $r->dir_config('AuthzGroupAttrType') ||
  386.     $r->dir_config('GroupAttrType') || 'cn';
  387.   my $authzldapserver = $r->dir_config('AuthzLDAPServer') ||
  388.     $r->dir_config('LDAPServer') || "localhost";
  389.   my $authzldapport = $r->dir_config('AuthzLDAPPort') ||
  390.     $r->dir_config('LDAPPort') || 389;
  391.   my $authenldapserver = $r->dir_config('AuthenLDAPServer') ||
  392.     $r->dir_config('AuthzLDAPServer') || $r->dir_config('LDAPServer') ||
  393.       "localhost";
  394.   my $authenldapport = $r->dir_config('AuthenLDAPPort') ||
  395.     $r->dir_config('AuthzLDAPPort') || $r->dir_config('LDAPPort') || 389;
  396.   my $memberattrtype = $r->dir_config('AuthzMemberAttrType') ||
  397.     $r->dir_config('MemberAttrType') || 'member';
  398.   my $memberattrvalue = $r->dir_config('AuthzMemberAttrValue') ||
  399.     $r->dir_config('MemberAttrValue') || 'cn';
  400.   my $nested_groups = $r->dir_config('AuthzNestedGroups') ||
  401.     $r->dir_config('NestedGroups');
  402.   my $uidattrtype = $r->dir_config('AuthzUidAttrType') ||
  403.     $r->dir_config('UidAttrType') || 'uid';
  404.   my $userbasedn = $r->dir_config('AuthenBaseDN');
  405.   $r->log->debug(join ", ", "AuthzBaseDN=$basedn",
  406.          "GroupAttrType=$groupattrtype",
  407.          "LDAPServer=$authzldapserver",
  408.          "MemberAttrType=$memberattrtype",
  409.          "MemberAttrValue=$memberattrvalue",
  410.          "NestedGroups=$nested_groups", "UserBaseDN=$userbasedn");
  411.  
  412.  
  413.   for my $req (@$requires) {
  414.     my ($require, $rest) = split /\s+/, $req->{requirement}, 2;
  415.  
  416.     if ($require eq "user") { return OK
  417.                 if grep $username eq $_, split /\s+/, $rest}
  418.     elsif ($require eq "valid-user") { return OK }
  419.     elsif ($require eq 'group') {
  420.       my $Ld = undef;
  421.       # Connect to the server
  422.       unless ($Ld = new Net::LDAP($authenldapserver,port => $authenldapport)) {
  423.     $r->note_basic_auth_failure;
  424.     $r->log_reason("user $username: Authen LDAP Connection Failed",$r->uri);
  425.     return SERVER_ERROR;
  426.       }
  427.  
  428.       # Bind anonymously
  429.       my $msg = $Ld->bind;
  430.       unless ($msg->code == LDAP_SUCCESS) {
  431.     $r->note_basic_auth_failure;
  432.     $r->log_reason("user $username: Authen LDAP Initial Bind Failed: " .
  433.                $msg->code . " " . $msg->error, $r->uri);
  434.     return SERVER_ERROR;
  435.       }
  436.  
  437.       # Get user DN
  438.       $msg = $Ld->search(base   => $userbasedn,
  439.              filter => qq($uidattrtype=$username));
  440.       unless ($msg->code == LDAP_SUCCESS) {
  441.     $r->note_basic_auth_failure;
  442.     $r->log_reason("LDAP read failure " .
  443.                $msg->code . " " . $msg->error, $r->uri);
  444.     return SERVER_ERROR;
  445.       }
  446.       unless ($msg->count) {
  447.     $r->note_basic_auth_failure;
  448.     $r->log_reason("user ($uidattrtype) $username doesn't " .
  449.                "exist in LDAP " .
  450.                $msg->code . " " . $msg->error . $r->uri);
  451.     return AUTH_REQUIRED;
  452.       }
  453.  
  454.       my $userinfo = undef;
  455.       if ($memberattrvalue eq 'dn') {
  456.     $userinfo = $msg->first_entry->dn;
  457.       } else {
  458.     $userinfo = ($msg->first_entry->get($memberattrvalue))[0];
  459.       }
  460.       $r->log->debug("handler: Userinfo is $userinfo ($memberattrvalue)");
  461.  
  462.       $Ld->unbind();
  463.       $Ld = undef;
  464.       # Connect to the server
  465.       unless ($Ld = new Net::LDAP($authzldapserver,port => $authzldapport)) {
  466.     $r->note_basic_auth_failure;
  467.     $r->log_reason("user $username: Authz LDAP Connection Failed",$r->uri);
  468.     return SERVER_ERROR;
  469.       }
  470.  
  471.       # Bind anonymously
  472.       $msg = $Ld->bind;
  473.       unless ($msg->code == LDAP_SUCCESS) {
  474.     $r->note_basic_auth_failure;
  475.     $r->log_reason("user $username: Authz LDAP Initial Bind Failed: " .
  476.                $msg->code . " " . $msg->error, $r->uri);
  477.     return SERVER_ERROR;
  478.       }
  479.  
  480.       # Compare the username
  481.       my ($result, $group) = check_group($r, $Ld, $basedn, $groupattrtype,
  482.                      $memberattrtype, $userinfo, $rest,
  483.                      $nested_groups);
  484.       return $result unless $result == OK;
  485.  
  486.       # Everything's A-OK
  487.       $r->subprocess_env(REMOTE_GROUP => $group);
  488.       return OK;
  489.     }
  490.   }
  491. }
  492.  
  493. 1;
  494.  
  495. __END__
  496.  
  497. # Documentation - try 'pod2text AuthzLDAP'
  498.  
  499. =head1 NAME
  500.  
  501. Apache::AuthzLDAP - mod_perl LDAP Authorization Module
  502.  
  503. =head1 SYNOPSIS
  504.  
  505.  <Directory /foo/bar>
  506.  # Authorization Realm and Type (only Basic supported)
  507.  AuthName "Foo Bar Authentication"
  508.  AuthType Basic
  509.  
  510.  # Any of the following variables can be set.
  511.  # Defaults are listed to the right.
  512.  PerlSetVar AuthenBaseDN         o=Foo,c=Bar       # Default: Empty String ("")
  513.  PerlSetVar AuthzBaseDN          o=Tivoli Systems  # Default: none
  514.  PerlSetVar AuthzGroupAttrType   gid               # Default: cn
  515.  PerlSetVar AuthzLDAPServer      ldap.foo.com      # Default: localhost
  516.  PerlSetVar AuthzLDAPPort        389               # Default: 389
  517.  PerlSetVar AuthzMemberAttrType  uid               # Default: member
  518.  PerlSetVar AuthzMemberAttrValue dn                # Default: cn
  519.  PerlSetVar AuthzNestedGroups    On                # Default: off
  520.  PerlSetVar AuthzUidattrType     userid            # Default: uid
  521.  
  522.  PerlAuthzHandler Apache::AuthzLDAP
  523.  
  524.  require group "My Group" GroupA "Group B"         # Authorize user against
  525.                                                    # multiple groups
  526.  </Directory>
  527.  
  528. =head1 DESCRIPTION
  529.  
  530. B<Apache::AuthzLDAP> is designed to work with mod_perl
  531. and Net::LDAP. This module authorizes a user against an LDAP
  532. backend. It can be combined with Apache::AuthenLDAP to
  533. provide LDAP authentication as well.
  534.  
  535. =head1 CONFIGURATION OPTIONS
  536.  
  537. The following variables can be defined within the configuration
  538. of Directory, Location, or Files blocks or within .htaccess
  539. files.
  540.  
  541. =over 4
  542.  
  543. =item B<AuthenBaseDN>
  544.  
  545. The base distinguished name with which to query LDAP for purposes
  546. of authentication. By default, the AuthenBaseDN is blank.
  547.  
  548. =back
  549.  
  550. =over 4
  551.  
  552. =item B<AuthzBaseDN>
  553.  
  554. The base distinguished name with which to query LDAP for purposes
  555. of authorization. By default, the AuthzBaseDN is blank.
  556.  
  557. =back
  558.  
  559. =over 4
  560.  
  561. =item B<AuthzGroupAttrType>
  562.  
  563. The attribute type name that contains the group's
  564. identification. By default, AuthzGroupAttrType is set to cn.
  565.  
  566. =back
  567.  
  568. =over 4
  569.  
  570. =item B<AuthzLDAPServer>
  571.  
  572. The hostname for the LDAP server to query. By default,
  573. AuthzLDAPServer is set to localhost.
  574.  
  575. =back
  576.  
  577. =over 4
  578.  
  579. =item B<AuthzLDAPPort>
  580.  
  581. The port on which the LDAP server is listening. By default,
  582. AuthzLDAPPort is set to 389.
  583.  
  584. =back
  585.  
  586. =over 4
  587.  
  588. =item B<AuthzMemberAttrType>
  589.  
  590. The attribute type name that contains the group member's
  591. identification. By default, AuthzMemberAttrType is set to member.
  592.  
  593. =back
  594.  
  595. =over 4
  596.  
  597. =item B<AuthzMemberAttrValue>
  598.  
  599. The attribute value contained within the AuthzMemberAttrType
  600. above. By default, AuthzMemberAttrValue is set to cn.
  601.  
  602. =back
  603.  
  604. =over 4
  605.  
  606. =item B<AuthzNestedGroups>
  607.  
  608. When the AuthzNestedGroups value is on, a recursive group search
  609. occurs until the user is found in a group or the deepest group's
  610. member list does not contain any groups. By default,
  611. AuthzNestedGroups is set to off.
  612.  
  613. =back
  614.  
  615. =over 4
  616.  
  617. =item B<AuthzUidAttrType>
  618.  
  619. The attribute type name that contains the user's
  620. identification. By default, AuthzUidAttrType is set to uid.
  621.  
  622. =back
  623.  
  624. =head1 NOTES
  625.  
  626. This module has hooks built into it to handle Apache::AuthzCache
  627. version 0.02 and higher passing notes to avoid bugs in the
  628. set_handlers() method in mod_perl versions 1.2x.
  629.  
  630. =head1 AUTHORS
  631.  
  632. Jason Bodnar,
  633. Christian Gilmore <cgilmore@tivoli.com>
  634.  
  635. =head1 See ALSO
  636.  
  637. httpd(8), ldap(3), mod_perl(1), slapd(8C)
  638.  
  639. =head1 COPYRIGHT
  640.  
  641. Copyright (C) 2001, International Business Machines Corporation
  642. and others. All Rights Reserved.
  643.  
  644. This module is free software; you can redistribute it and/or
  645. modify it under the terms of the IBM Public License.
  646.  
  647. =cut
  648.  
  649. ###############################################################################
  650. ###############################################################################
  651. # $Log: AuthzLDAP.pm,v $
  652. # Revision 1.16  2001/07/12 14:18:52  cgilmore
  653. # see ChangeLog
  654. #
  655. # Revision 1.15  2001/05/27 20:47:41  cgilmore
  656. # Added handling for AuthenLDAPServer to query user information
  657. #
  658. # Revision 1.14  2001/05/27 20:27:15  cgilmore
  659. # removed redeclaration of $msg in same scope
  660. #
  661. # Revision 1.13  2001/05/27 20:22:51  cgilmore
  662. # updated docs to reflect new variable names
  663. #
  664. # Revision 1.12  2001/05/27 20:01:12  cgilmore
  665. # see ChangeLog
  666. #
  667. # Revision 1.11  2001/01/08 17:23:47  cgilmore
  668. # fixed nested group bug and better handled pre-1.26 conditions
  669. #
  670. # Revision 1.10  2000/09/26 18:51:21  cgilmore
  671. # updated to Apache from Tivoli namespace and updated pod.
  672. #
  673. # Revision 1.9  2000/08/26 16:41:49  cgilmore
  674. # corrected fetch bug with userinfo. cleaned up debug statements.
  675. #
  676. # Revision 1.8  2000/08/26 15:34:32  cgilmore
  677. # re-designed. See pod.
  678. #
  679. # Revision 1.7  2000/08/26 15:26:46  cgilmore
  680. # re-fixed same bug
  681. #
  682. # Revision 1.6  2000/08/21 14:15:49  cgilmore
  683. # fixed bug that improperly dealt with end-of-line non-quoted groups
  684. #
  685. # Revision 1.5  2000/07/18 15:37:11  cgilmore
  686. # added userbasedn and adding $groups to empty @groups
  687. #
  688. # Revision 1.4  2000/07/17 15:37:06  cgilmore
  689. # added handling of no hits for user in LDAP
  690. #
  691. # Revision 1.3  2000/07/12 18:32:07  cgilmore
  692. # Finally found a hack (using r->notes) around bugs in set_handlers()
  693. # and lookup_uri(). See files for more.
  694. #
  695. # Revision 1.2  2000/06/01 16:18:54  cgilmore
  696. # added Log message
  697. #
  698. ###############################################################################
  699. ###############################################################################
  700.