]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Various tweaks, and information on performing group checks
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Tue, 22 Oct 2019 10:59:47 +0000 (06:59 -0400)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Tue, 22 Oct 2019 10:59:47 +0000 (06:59 -0400)
doc/antora/modules/howto/pages/modules/ldap/authorization/groups.adoc
doc/antora/modules/howto/pages/modules/ldap/authorization/locating_the_user.adoc
doc/antora/modules/howto/pages/modules/ldap/authorization/user_account_controls.adoc
doc/antora/modules/howto/pages/modules/ldap/authorization/user_disambiguation.adoc
doc/antora/modules/howto/pages/modules/ldap/ldapsearch/locating_objects.adoc
doc/antora/modules/howto/pages/modules/ldap/ldapsearch/translating_to_the_ldap_module.adoc

index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..21399254cbc5fd0e46b145c5ae437980b447f6b5 100644 (file)
@@ -0,0 +1,192 @@
+= Group authorization
+
+A very common requirement is to restrict access to particular groups within
+LDAP, or to return different authorizational attributes based on a user's group
+memberships.
+
+How groups are managed by different directories can differ significantly.
+
+Other sections in this tutorial have assigned variant numbers to the different
+group mappings.  The definitions of these variants is repeated below for easy
+referencing:
+
+- _variant 1_ - User objects contain membership attributes referencing group objects by DN.
+- _variant 2_ - User objects contain membership attributes referencing group objects by name.
+- _variant 3_ - Group objects contain membership attributes referencing user objects by DN.
+- _variant 4_ - Group objects contain membership attributes referencing user objects by name.
+
+== Configuring group lookups
+
+=== Editing mods-available/ldap to configure _variant 1_ group checks
+
+[source,config]
+----
+ldap {
+       group {
+               # example - ou=groups,dc=example,dc=com
+               base_dn = '<group_base_dn>'             <1>
+
+               # example - groupOfNames
+               filter = '<group_object_class_filter>'  <2>
+
+               # example - cn
+               name_attribute = '<group_name_attribute>'  <3>
+
+               # example - memberOf
+               membership_attribute = '<group_membership_attribute>  <4>
+       }
+}
+----
+<1> Where in the directory to begin the search for group objects.
+<2> Filter matching the objectClass(es) of all relevant group objects.
+<3> Attribute within the group object containing its name.
+<4> Attribute within the user object referencing groups by their DNs.
+
+=== Editing mods-available/ldap to configure _variant 2_ group checks
+
+[source,config]
+----
+ldap {
+       group {
+               # example - ou=groups,dc=example,dc=com
+               base_dn = '<group_base_dn>'             <1>
+
+               # example - groupOfNames
+               filter = '<group_object_class_filter>'  <2>
+
+               # example - cn
+               name_attribute = '<group_name_attribute>'  <3>
+
+               # example - memberOf
+               membership_attribute = '<group_membership_attribute>  <4>
+       }
+}
+----
+<1> Where in the directory to begin the search for group objects.
+<2> Filter matching the objectClass(es) of all relevant group objects.
+<3> Attribute within the group object containing its name.
+<4> Attribute within the user object referencing groups by their name.
+
+=== Editing mods-available/ldap to configure _variant 3_ group checks
+
+[source,config]
+----
+ldap {
+       group {
+               # example - ou=groups,dc=example,dc=com
+               base_dn = '<group_base_dn>'             <1>
+
+               # example - groupOfNames
+               filter = '<group_object_class_filter>'  <2>
+
+               # example - cn
+               name_attribute = '<group_name_attribute>'  <3>
+
+               # example - (member=%{control:Ldap-UserDn})
+               membership_filter = "(<group_membership_dn_attribute>=%{control:Ldap-UserDn})"  <4>
+       }
+}
+----
+<1> Where in the directory to begin the search for group objects.
+<2> Filter matching the objectClass(es) of all relevant group objects.
+<3> Attribute within the group object containing its name.
+<4> Attribute within the group object referencing users by their DN.
+
+=== Editing mods-available/ldap to configure _variant 4_ group checks
+
+[source,config]
+----
+ldap {
+       group {
+               # example - ou=groups,dc=example,dc=com
+               base_dn = '<group_base_dn>'             <1>
+
+               # example - groupOfNames
+               filter = '<group_object_class_filter>'  <2>
+
+               # example - cn
+               name_attribute = '<group_name_attribute>'  <3>
+
+               # example - (memberUid=%{control:Ldap-UserDn})
+               membership_filter = "(<group_membership_uid_attribute>=%{control:Ldap-UserDn})"  <4>
+       }
+}
+----
+<1> Where in the directory to begin the search for group objects.
+<2> Filter matching the objectClass(es) of all relevant group objects.
+<3> Attribute within the group object containing its name.
+<4> Attribute within the group object referencing users by their name (uid).
+
+== "Live" group lookups
+
+[TIP]
+====
+For _variant 1_ and _variant 2_, when checking group memberships, it is most
+efficient to specify the group in the same format as the reference.
+
+For example, if the directory implements _variant 1_, then the group would be
+specified as a DN, and if the directory implements _variant 2_, then the group
+would be specified by name.
+====
+
+Group checks are performed using the virtual attribute `LDAP-Group`.
+Comparing this attribute to a group name or group DN, will, (if group caching
+is not enabled) result in a query being sent to the LDAP Directory to determine
+if the user is a member of the specified group.
+
+When performing group checks LDAP module abstracts away the differences between
+group membership _variants [1-4]_ so long as it has been configured
+appropriately.
+
+=== Group membership check by DN
+
+[source,unlang]
+----
+if (LDAP-Group == 'cn=foo,ou=groups,dc=example,dc=com') {
+       update reply {
+               &Reply-Message := "Welcome member of group 'foo'"
+       }
+}
+----
+
+=== Group membership check by name
+
+[source,unlang]
+----
+if (LDAP-Group == 'foo') {
+       update reply {
+               &Reply-Message := "Welcome member of group 'foo'"
+       }
+}
+----
+
+== Cached group lookups
+
+In some instances it's useful to retrieve complete group listings for users.
+The most common reasons for this are:
+- To maintain a local cache in case connectivity to the LDAP directory is lost.
+- To perform group checks in ways not supported by the LDAP module.  One example
+  of this is checking for membership in nested groups.
+
+When caching group membership information the LDAP module abstracts away the
+differences between group membership _variants [1-4]_ so long as it has been
+configured appropriately.
+
+Two configuration items control group caching:
+
+- `group.cacheable_name` - If set to 'yes', the names of groups the user is a member of will be cached.
+- `group.cacheable_dn` - If set to 'yes', the DNs of the groups the user is a member of will be cached.
+
+The type of caching should match the format of the group check values. For
+example, when checking for group memberships using DNs `group.cacheable_dn`
+should be set, and when checking for group memberships using group names
+`group.cacheable_name` should be set.
+
+One exception to this, is if nested group checks are being performed.
+In this case `group.cacheable_dn` must be set, as the full path of the group
+objects is required.
+
+
+
+
+
index 73f12ecfd5f3a588c6fe54287c4cdc24881b9eb6..c3e59554350e8f7b6b0537d34d69f89a50e736a6 100644 (file)
@@ -10,6 +10,8 @@ explaining how the different configuration items are used. See
 xref:modules/ldap/ldapsearch/index.adoc[ldapsearch] for how to determine the
 appropriate values for your directory.
 
+== Editing mods-available/ldap to specify how to search for user objects
+
 [source,config]
 ----
 ldap {
index 76962a0ef3c1152d67f6a542987d5dc0f6394604..cf4ea27740bb7ebaea57b7ebbe05ce469c4bf844 100644 (file)
@@ -35,7 +35,7 @@ is enabled, or disabled, depending on the value of `user.access_positive`.
 
 When a user is "locked out", the LDAP module will return `disallow` in (≥ v4.0.x) and `userlock` in (≤ v3.0.x).
 
-=== Access attribute indicates account is enabled
+=== Editing mods-available/ldap to only allow access if the 'Access Attribute' is present
 
 [source,config]
 ----
@@ -52,7 +52,7 @@ ldap {
     If the attribute is absent or set to false then the user will be
     "locked out".
 
-=== Access attribute indicates account is disabled
+=== Editing mods-available/ldap to disable access if the 'Access Attribute' is present
 
 [source,config]
 ----
index 755ce84ec0a7ac8ccb8757a37cb2a643f960c1ea..ade79729ff89a969a10a67f8ebf251d9ae4ae489 100644 (file)
@@ -31,6 +31,16 @@ As the error message states, there are multiple ways to resolve this issue:
 
 == Enabling and configuring Server Side Sorting
 
+Server Side Sorting controls are specified by
+https://tools.ietf.org/html/rfc2891[RFC 2891].
+
+SSS controls allow the client to request the server sort results in a specific
+and consistent order.  This ensures that in the case where there is an ambiguous
+result, the same user object (the first in the result set) will be used by the
+LDAP module.
+
+Without SSS which object is used by the LDAP module will be essentially random.
+
 [TIP]
 ====
 If you followed the
@@ -50,16 +60,6 @@ EOF
 ----
 ====
 
-Server Side Sorting controls are specified by
-https://tools.ietf.org/html/rfc2891[RFC 2891].
-
-SSS controls allow the client to request the server sort results in a specific
-and consistent order.  This ensures that in the case where there is an ambiguous
-result, the same user object (the first in the result set) will be used by the
-LDAP module.
-
-Without SSS which object is used by the LDAP module will be essentially random.
-
 == Editing mods-available/ldap to enable SSS
 
 [source,config]
index d5a4badb7dbfee5a3c352eb031b94062a0406f4c..db699ccc6f4929725c1e3cfde341bda0894d9aee 100644 (file)
@@ -237,11 +237,11 @@ result: 0 Success
 ** `group_membership_attribute` - User object attribute containing group
  membership information. e.g. `memberOf`.
 * _variant 3_
-** `group_membership_filter_by_uid` - A filter matching user membership by DN
-e.g. `(memberUid=%{%{Stripped-User-Name}:-%{User-Name}})`.
+** `group_membership_dn_attribute` - An attribute in the group object referencing user objects by DN
+e.g. `member`.
 * _variant 4_
-** `group_membership_filter_by_name` - A filter matching user membership uid
-e.g. `(member=%{control:Ldap-UserDn})`.
+** `group_membership_uid_attribute` - An attribute in the group object referencing user objects by UID
+e.g. `memberUID`.
 
 .Locating groups in "mature" directories
 ****
index 8adadaf10a8d947a1e4f716fac26a3387439a5e1..67a1caebb5de9398028f0e5b30888100c4ab582a 100644 (file)
@@ -49,7 +49,7 @@ User objects reference groups using DNs.
 [width="100%",cols="30%,70%",options="header",]
 |===
 | Purpose                                     | `ldap { group { ... } }` config item
-| Specify how to find group objects by DN, when referenced by a user object. | ```group_membership_attribute = '<group_base_dn>'```
+| Specify how to find group objects by DN, when referenced by a user object. | ```membership_attribute = '<group_membership_attribute>'```
 |===
 
 == Groups - variant 2
@@ -59,7 +59,7 @@ User objects reference groups using group names.
 [width="100%",cols="30%,70%",options="header",]
 |===
 | Purpose                                     | `ldap { group { ... } }` config item
-| Specify how to find group objects by name, when referenced by a user object. | ```group_membership_attribute = '<group_base_dn>'```
+| Specify how to find group objects by name, when referenced by a user object. | ```membership_attribute = '<group_membership_attribute>'```
 |===
 
 == Groups - variant 3
@@ -69,7 +69,7 @@ Group objects reference users using DNs.
 [width="100%",cols="30%,70%",options="header",]
 |===
 | Purpose                                     | `ldap { group { ... } }` config item
-| Specify how to find group objects referencing a user by DN. | ```membership_filter = "(<group_membership_filter_by_uid>=%{control:Ldap-UserDn})"```
+| Specify how to find group objects referencing a user by DN. | ```membership_filter = "(<group_membership_dn_attribute>=%{control:Ldap-UserDn})"```
 |===
 
 == Groups - variant 4
@@ -79,7 +79,7 @@ Group objects reference users using user names.
 [width="100%",cols="30%,70%",options="header",]
 |===
 | Purpose                                     | `ldap { group { ... } }` config item
-| Specify how to find group objects referencing a user by name. | ```membership_filter = "(<group_membership_filter_by_name>=%{%{Stripped-User-Name}:-%{User-Name}})"```
+| Specify how to find group objects referencing a user by name. | ```membership_filter = "(<group_membership_uid_attribute>=%{%{Stripped-User-Name}:-%{User-Name}})"```
 |===
 
 .Mixing and matching group membership schemes