]> git.sur5r.net Git - openldap/blob - doc/guide/admin/sasl.sdf
ITS#1958 from Andrew Findlay with minor adjustments
[openldap] / doc / guide / admin / sasl.sdf
1 # Copyright 1999-2000, The OpenLDAP Foundation, All Rights Reserved.
2 # COPYING RESTRICTIONS APPLY, see COPYRIGHT.
3
4 H1: Using SASL
5
6 OpenLDAP clients and servers are capable of authenticating via the
7 {{TERM[expand]SASL}} ({{TERM:SASL}}) framework, which is detailed
8 in {{REF:RFC2222}}.   This chapter describes how to make use of
9 SASL in OpenLDAP.
10
11 There are several industry standard authentication mechanisms that
12 can be used with SASL, including Kerberos V4, GSSAPI, and some of
13 the Digest mechanisms. The standard client tools provided with
14 OpenLDAP, such as {{ldapsearch}}(1) and {{ldapmodify}}(1), will by
15 default attempt to authenticate the user to the {{slapd}}(8) server
16 using SASL. Basic authentication service can be set up by the LDAP
17 administrator with a few steps, allowing users to be authenticated
18 to the slapd server as their LDAP entry.  With a few extra steps,
19 some users and services can be allowed to exploit SASL's authorization
20 feature, allowing them to authenticate themselves and then switch
21 their identity to that of another user or service.
22
23 This chapter assumes you have read {{Cyrus SASL for System
24 Administrators}}, provided with the {{PRD:Cyrus}} {{PRD:SASL}}
25 package (in {{FILE:doc/sysadmin.html}}).
26
27 Note that in the following text the term {{user}} is used to describe
28 a person or application entity who is connecting to the LDAP server
29 via an LDAP client, such as {{ldapsearch}}(1).  That is, the term
30 {{user}} not only applies to both an individual using an LDAP client,
31 but to an application entity which issues LDAP client operations
32 without direct user control.  For example, an e-mail server which
33 uses LDAP operations to access information held in an LDAP server
34 is an application entity.
35
36
37 H2: SASL Security Considerations
38
39 SASL offers many different authentication mechanisms.  This section
40 briefly outlines security considerations.
41
42 Some mechanisms, such as PLAIN and LOGIN, offer no greater security over
43 LDAP "simple" authentication.  Like "simple" authentication, such
44 mechanisms should not be used unless you have adequate security
45 protections in place.  It is recommended that these mechanisms be
46 used only in conjunction with {{TERM[expand]TLS}} (TLS).  Use of
47 PLAIN and LOGIN are not discussed further in this document.
48
49 The DIGEST-MD5 mechanism is the mandatory-to-implement authentication
50 mechanism for LDAPv3.  Though DIGEST-MD5 is not a strong authentication
51 mechanism in comparison with trusted third party authentication
52 systems (such as Kerberos or public key systems), yet it does offer
53 significant protections against a number of attacks.  Unlike the
54 CRAM-MD5 mechanism, it prevents chosen plaintext attacks.  DIGEST-MD5
55 is favored over the weaker and even more dangerous use of plaintext
56 password mechanisms.  The CRAM-MD5 mechanism is deprecated in favor
57 of DIGEST-MD5.  Use of {{SECT:DIGEST-MD5}} is discussed below.
58
59 The KERBEROS_V4 mechanism utilizes Kerberos IV to provide secure
60 authentication services.  There is also a GSSAPI based mechanism
61 which is generally used in conjunction with Kerberos V.  Kerberos
62 is viewed as a secure, distributed authentication system suitable
63 for both small and large enterprises.  Use of {{SECT:KERBEROS_V4}}
64 and {{SECT:GSSAPI}} are discussed below.
65
66 The EXTERNAL mechanism utilizes authentication services provided
67 by lower level network services such as {{TERM:TLS}} (TLS).  When
68 used in conjunction with TLS {{TERM:X.509}}-based public key technology,
69 EXTERNAL offers strong authentication.  Use of EXTERNAL is discussed
70 in the {{SECT:Using TLS}} chapter.
71
72 There are other strong authentication mechanisms to choose from,
73 including OTP (one time passwords) and SRP (secure remote passwords).
74 These mechanisms are not discussed in this document.
75
76
77 H2: SASL Authentication
78
79 Getting basic SASL authentication running involves a few steps.
80 The first step configures your slapd server environment so
81 that it can communicate with client programs using the security
82 system in place at your site. This usually involves setting up a
83 service key, a public key, or other form of secret. The second step
84 concerns mapping authentication identities to LDAP DN's, which
85 depends on how entries are laid out in your directory. An explanation
86 of the first step will be given in the next section using Kerberos
87 V4 as an example mechanism. The steps necessary for your site's
88 authentication mechanism will be similar, but a guide to every
89 mechanism available under SASL is beyond the scope of this chapter.
90 The second step is described in the section 
91 {{SECT:Mapping Authentication identities to LDAP entries}}.
92
93 H3: KERBEROS_V4
94
95 This section describes the use of the SASL KERBEROS_V4 mechanism
96 with OpenLDAP.  It will be assumed that you are familiar with the
97 workings of the Kerberos IV security system, and that your site has
98 Kerberos IV deployed.  Your users should be familiar with
99 authentication policy, how to receive credentials in
100 a Kerberos ticket cache, and how to refresh expired credentials.
101
102 Client programs will need to be able to obtain a session key for
103 use when connecting to your LDAP server. This allows the LDAP server
104 to know the identity of the user, and allows the client to know it
105 is connecting to a legitimate server. If encryption layers are to
106 be used, the session key can also be used to help negotiate that
107 option.
108
109 The slapd server runs the service called "{{ldap}}", and the server
110 will require a srvtab file with a service key.  SASL aware client
111 programs will be obtaining an "ldap" service ticket with the user's
112 ticket granting ticket (TGT), with the instance of the ticket
113 matching the hostname of the OpenLDAP server. For example, if your
114 realm is named {{EX:EXAMPLE.COM}} and the slapd server is running
115 on the host named {{EX:directory.example.com}}, the {{FILE:/etc/srvtab}}
116 file on the server will have a service key
117
118 >       ldap.directory@EXAMPLE.COM
119
120 When an LDAP client is authenticating a user to the directory using
121 the KERBEROS_IV mechanism, it will request a session key for that
122 same principal, either from the ticket cache or by obtaining a new
123 one from the Kerberos server.  This will require the TGT to be
124 available and valid in the cache as well.  If it is not present or
125 has expired, SASL will print out the message
126
127 >       ldap_sasl_interactive_bind_s: Local error
128
129 When the service ticket is obtained, it will be passed to the LDAP
130 server as proof of the user's identity.  The server will extract
131 the identity and realm out of the service ticket using SASL
132 library calls, and convert them into an {{authentication request
133 DN}} of the form
134
135 >       uid=<username>,cn=<realm>,cn=<mechanism>,cn=auth
136
137 So in our above example, if the user's name were "adamson", the
138 authentication request DN would be:
139
140 >       uid=adamsom,cn=example.com,cn=kerberos_v4,cn=auth
141
142 This authentication request DN by itself could be placed into ACL's
143 and {{EX:groupOfNames}} "member" attributes, since it is of legitimate
144 LDAP DN format. The section
145 {{SECT:Mapping Authentication identities to LDAP entries}},
146 however, tells how to map that
147 DN into the DN of a person's own LDAP entry.
148
149 Also note that this example, being for Kerberos, shows the <realm>
150 portion of the DN being filled in with the Kerberos realm of the
151 company. Several other authentication mechanisms do not employ the
152 concept of a realm, so the ",cn=<realm>" portion of the authentication
153 request DN would not appear.
154
155
156 H3: GSSAPI
157
158 This section describes the use of the SASL GSSAPI mechanism and
159 Kerberos V with OpenLDAP. Since Kerberos V is being used, the information
160 is very similar to the previous section.
161 It will be assumed that you have Kerberos
162 V deployed, you are familiar with the operation of the system, and that
163 your users are trained in its use.  This section also assumes you have
164 familiarized yourself with the use of the GSSAPI mechanism by reading
165 {{Configuring GSSAPI and Cyrus SASL}} (provided with Cyrus SASL in
166 the {{FILE:doc/gssapi}} file) and successfully experimented with
167 the Cyrus provided sample_server and sample_client applications.
168 General information about Kerberos is available at
169 {{URL:http://web.mit.edu/kerberos/www/}}.
170
171 To use the GSSAPI mechanism with {{slapd}}(8) one must create a service
172 key with a principal for {{ldap}} service within the realm for the host
173 on which the service runs.  For example, if you run {{slapd}} on
174 {{EX:directory.example.com}} and your realm is {{EX:EXAMPLE.COM}},
175 you need to create a service key with the principal:
176
177 >       ldap/directory.example.com@EXAMPLE.COM
178
179 When {{slapd}}(8) runs, it must have access to this key.  This is
180 generally done by placing the key into a keytab, such as
181 {{FILE:/etc/krb5.keytab}}.
182
183 To use the GSSAPI mechanism to authenticate to the directory, the
184 user obtains a Ticket Granting Ticket (TGT) prior to running the
185 LDAP client.  When using OpenLDAP client tools, the user may mandate
186 use of the GSSAPI mechanism by specifying {{EX:-Y GSSAPI}} as a
187 command option.
188
189 For the purposes of authentication and authorization, {{slapd}}(8)
190 associates a non-mapped authentication request DN of the form:
191
192 >       uid=<principal>,cn=<realm>,cn=gssapi,cn=auth
193
194 Continuing our example, a user
195 with the Kerberos principal {{EX:kurt@EXAMPLE.COM}} would have
196 the associated DN:
197
198 >       uid=kurt,cn=example.com,cn=gssapi,cn=auth
199
200 and the principal {{EX:ursula@FOREIGN.REALM}} would have the
201 associated DN:
202
203 >       uid=ursula,cn=foreign.realm,cn=gssapi,cn=auth
204
205
206 H3: DIGEST-MD5
207
208 This section describes the use of the SASL DIGEST-MD5 mechanism using
209 secrets stored either in the directory itself or in Cyrus SASL's own
210 database. DIGEST-MD5 relies on the client and the server sharing a
211 "secret", usually a password. The server generates a challenge and the
212 client a response proving that it knows the shared secret. This is much
213 more secure than simply sending the secret over the wire.
214
215 Cyrus SASL supports several shared-secret mechanisms. To do this, it
216 needs access to the plaintext password (unlike mechanisms which pass
217 plaintext passwords over the wire, where the server can store a hashed
218 version of the password).
219
220 Secret passwords are normally stored in Cyrus SASL's own {{sasldb}}
221 database, but if OpenLDAP has been compiled with Cyrus SASL 2.1 it is
222 possible to store the secrets in the LDAP database itself. With Cyrus
223 SASL 1.5, secrets may only be stored in the {{sasldb}}.  In either
224 case it is very important to apply file access controls and LDAP access
225 controls to prevent exposure of the passwords.
226
227 The configuration and commands discussed in this section assume the use
228 of Cyrus SASL 2.1. If you are using version 1.5 then certain features
229 will not be available, and the command names will not have the trailing
230 digit "2".
231
232 To use secrets stored in {{sasldb,}} simply add users with the
233 {{saslpasswd2}} command:
234
235 >       saslpasswd2 -c <username>
236
237 The passwords for such users must be managed with the {{saslpasswd2}}
238 command.
239
240 To use secrets stored in the LDAP directory, place plaintext passwords
241 in the {{EX:userPassword}} attribute. It will be necessary to add an
242 option to {{EX:slapd.conf}} to make sure that passwords changed through
243 LDAP are stored in plaintext:
244
245 >       password-hash   {CLEARTEXT}
246
247 Passwords stored in this way can be managed either with {{EX:ldappasswd}}
248 or by simply modifying the {{EX:userPassword}} attribute.
249
250 Wherever the passwords are stored, a mapping will be needed from SASL
251 authentication IDs to regular DNs. The DIGEST-MD5 mechanism produces
252 authentication IDs of the form:
253
254 >       uid=<username>,cn=<realm>,cn=digest-md5,cn=auth
255
256 NOTE that if the default realm is used, the realm name is omitted from
257 the ID, giving:
258
259 >       uid=<username>,cn=digest-md5,cn=auth
260
261 See {{SECT: Mapping Authentication identities to LDAP entries}} below
262 for information on mapping such IDs to DNs.
263
264 With suitable mappings in place, users can specify SASL IDs when
265 performing LDAP operations, and the password stored in {{sasldb}} or in
266 the directory itself will be used to verify the authentication.
267 For example, the user identified by the directory entry:
268
269 >       dn: cn=Andrew Findlay+uid=u000997,dc=example,dc=com
270 >       objectclass: inetOrgPerson
271 >       objectclass: person
272 >       sn: Findlay
273 >       uid: u000997
274 >       userPassword: secret
275
276 can issue commands of the form:
277
278 >       ldapsearch -U u000997 -b dc=example,dc=com 'cn=andrew*'
279
280 or can specify the realm explicitly:
281
282 >       ldapsearch -U u000997@myrealm -b dc=example,dc=com 'cn=andrew*'
283
284 If several SASL mechanisms are supported at your site, it may be
285 necessary to specify which one to use, e.g.:
286
287 >       ldapsearch -Y DIGEST-MD5 -U u000997 -b dc=example,dc=com 'cn=andrew*'
288
289
290
291 H3: Mapping Authentication identities to LDAP entries
292
293 The authentication mechanism in the slapd server will use SASL
294 library calls to obtain the authenticated user's "username", based
295 on whatever underlying authentication mechanism was used.  This
296 username is in the namespace of the authentication mechanism, and
297 not in the LDAP namespace. As stated in the sections above, that
298 username is reformatted into an authentication request DN of the
299 form
300
301 >       uid=<username>,cn=<realm>,cn=<mechanism>,cn=auth
302
303 or
304
305 >       uid=<username>,cn=<mechanism>,cn=auth
306
307 depending on whether or not <mechanism> employs the concept of
308 "realms". Note also that the realm part will be omitted if the default
309 realm was used in the authentication.
310
311 It is not intended that you should add LDAP entries of the above
312 form to your LDAP database. Chances are you have an LDAP entry for
313 each of the people that will be authenticating to LDAP, laid out
314 in your directory tree, and the tree does not start at cn=auth.
315 But if your site has a clear mapping between the "username" and an
316 LDAP entry for the person, you will be able to configure your LDAP
317 server to automatically map a user's authentication username to
318 their {{authentication DN}}.
319
320 The LDAP administrator will need to tell the slapd server how to
321 map an authentication request DN to a user's authentication DN.
322 This is done by adding one or more {{EX:sasl-regexp}} directives to
323 the {{slapd.conf}}(5) file.  This directive takes two arguments:
324
325 >       sasl-regexp   <search pattern>   <replacement pattern>
326
327 The authentication request DN is compared to the search pattern
328 using the regular expression functions {{regcomp}}() and {{regexec}}(),
329 and if it matches, it is rewritten as the replacement pattern. If
330 there are multiple {{EX:sasl-regexp}} directives, only the first
331 whose search pattern matches the authentication identity is used.
332 The string that is output from the replacement pattern should be
333 the authentication DN of the user, in a legitimate LDAP DN format.
334 It can also be an LDAP URL, which is discussed below.
335
336 The search pattern can contain any of the regular expression
337 characters listed in {{regexec}}(3C). The main characters of note
338 are dot ".", asterisk "*", and the open and close parenthesis "("
339 and ")".  Essentially, the dot matches any character, the asterisk
340 allows zero or more repeats of the immediately preceding character or
341 pattern, and terms in parenthesis are
342 remembered for the replacement pattern.
343
344 The replacement pattern will produce the final authentication DN
345 of the user.  Anything from the authentication request DN that
346 matched a string in parenthesis in the search pattern is stored in
347 the variable "$1". That variable "$1" can appear in the replacement
348 pattern, and will be replaced by the string from the authentication
349 request DN. If there were multiple sets of parentheses in the search
350 pattern, the variables $2, $3, etc are used.
351
352 For example, suppose the user's authentication identity is written
353 as the DN string
354
355 >       uid=adamson,cn=example.com,cn=kerberos_v4,cn=auth
356
357 and the user's actual LDAP entry is
358
359 >       uid=adamson,ou=person,dc=example,dc=com
360
361 The {{EX:sasl-regexp}} directive in {{slapd.conf}}(5) could be
362 written
363
364 >       sasl-regexp 
365 >         uid=(.*),cn=example.com,cn=kerberos_v4,cn=auth
366 >         uid=$1,ou=person,dc=example,dc=com
367
368 An even more lenient rule could be written as
369
370 >       sasl-regexp
371 >         uid=(.*),cn=.*,cn=auth 
372 >         uid=$1,ou=person,dc=example,dc=com
373
374 Be careful about setting the search pattern too leniently, however,
375 since it may mistakenly allow people to become authenticated as a
376 DN to which they should not have access. It is better to write
377 several strict directives than one lenient directive which has
378 security holes. If there is only one authentication mechanism in
379 place at your site, and zero or one realms in use, you might be
380 able to map between authentication identities and LDAP DN's with
381 a single {{EX:sasl-regexp}} directive.
382
383 Don't forget to allow for the case where the realm is omitted as well
384 as the case with an explicitly specified realm. This may well
385 require a separate {{EX:sasl-regexp}} directive for each case, with the
386 explicit-realm entry being listed first.
387
388 Some sites may have people's DN's spread to multiple areas of the
389 LDAP tree, such as if there were an ou=accounting tree and an
390 ou=engineering tree, with people interspersed between them. Or
391 there may not be enough information in the authentication identity
392 to isolate the DN, such as if the above person's LDAP entry looked
393 like
394
395 >       dn: cn=mark adamson,ou=person,dc=example,dc=com
396 >       objectclass: Person
397 >       cn: mark adamson
398 >       uid: adamson
399
400 In this case, the information in the authentication identity can
401 only be used to search for the user's DN, not derive it directly.
402 For both of these situations, and others, the replacement pattern
403 in the {{EX:sasl-regexp}} directives will need to produce an LDAP
404 URL, described in the next section.
405
406
407 H3: Performing searches for a person's DN
408
409 When there is not enough information in the authentication identity
410 to derive a person's authentication DN directly, the {{EX:sasl-regexp}}
411 directives in the {{slapd.conf}}(5) file will need to produce an
412 LDAP URL.  This URL will then be used to perform an internal search
413 of the LDAP database to find the person's authentication DN.
414
415 An LDAP URL, similar to other URL's, is of the form
416
417 >       ldap://<host>/<base>?<attrs>?<scope>?<filter>
418
419 This contains all of the elements necessary to perform an LDAP
420 search:  the name of the server <host>, the LDAP DN search base
421 <base>, the LDAP attributes to retrieve <attrs>, the search scope
422 <scope> which is one of the three options "base", "one", or "sub",
423 and lastly an LDAP search filter <filter>. Since the search is for
424 an LDAP DN on the local machine, the <host> portion should be empty.
425 The <attrs> field is also ignored since only the DN is of concern.
426 These two elements are left in the format of the URL to maintain
427 the clarity of what information goes where in the string.
428
429 Suppose that the person in the example from above did in fact have
430 an authentication username of "adamson" and that information was
431 kept in the attribute "uid" in their LDAP entry. The {{EX:sasl-regexp}}
432 directive might be written as
433
434 >       sasl-regexp 
435 >         uid=(.*),cn=example.com,cn=kerberos_v4,cn=auth  
436 >         ldap:///ou=person,dc=example,dc=com??sub?(uid=$1)
437
438 This will initiate an internal search of the LDAP database inside
439 the slapd server. If the search returns exactly one entry, it is
440 accepted as being the DN of the user. If there are more than one
441 entries returned, or if there are zero entries returned, the
442 authentication fails and the user's connection is left bound as
443 the authentication request DN.
444
445 Note that if the search scope <scope> in the URL is "base", then
446 the only LDAP entry that will be returned is the searchbase DN
447 <base>, so the actual search of the database is skipped. This is
448 equivalent to setting the replacement pattern in the directive to
449 a DN directly, as in the section above.
450
451 The attributes that are used in the search filter <filter> in the
452 URL should be indexed to allow faster searching. If they are not,
453 the authentication step alone can take uncomfortably long periods,
454 and users may assume the server is down.
455
456 A more complex site might have several realms in use, each mapping to
457 a different sub-tree in the directory. These can be handled with
458 statements of the form:
459
460 >       # Match Engineering realm
461 >       sasl-regexp
462 >          uid=(.*),cn=engineering.example.com,cn=digest-md5,cn=auth
463 >          ldap:///dc=eng,dc=example,dc=com??sub?(&(uid=$1)(objectClass=person))
464 >
465 >       # Match Accounting realm
466 >       sasl-regexp
467 >          uid=(.*),cn=accounting.example.com,cn=digest-md5,cn=auth
468 >          ldap:///dc=accounting,dc=example,dc=com??sub?(&(uid=$1)(objectClass=person))
469 >
470 >       # Default realm is customers.example.com
471 >       sasl-regexp
472 >          uid=(.*),cn=digest-md5,cn=auth
473 >          ldap:///dc=customers,dc=example,dc=com??sub?(&(uid=$1)(objectClass=person))
474
475 Note that the explicitly-named realms are handled first, to avoid the
476 realm name becoming part of the UID. Note also the limitation of
477 matches to those entries with objectClass=person to avoid matching
478 other entries that happen to refer to the UID.
479
480 See {{slapd.conf}}(5) for more detailed information.
481
482
483 H2: SASL Authorization
484
485 The SASL offers a feature known as {{authorization}}, which allows
486 an authenticated user to request that they act on the behalf of
487 another user.  This step occurs after the user has obtained an
488 authentication DN, and involves sending an authorization identity
489 to the server. The server will then make a decision on whether or
490 not to allow the authorization to occur. If it is allowed, the
491 user's LDAP connection is switched to have a binding DN derived
492 from the authorization identity, and the LDAP session proceeds with
493 the access of the new authorization DN.
494
495 The decision to allow an authorization to proceed depends on the
496 rules and policies of the site where LDAP is running, and thus
497 cannot be made by SASL alone. The SASL library leaves it up to the
498 server to make the decision. The LDAP administrator sets the
499 guidelines of who can authorize to what identity by adding information
500 into the LDAP database entries. By default, the authorization
501 features are disabled, and must be explicitly configured by the
502 LDAP administrator before use.
503
504 H3: Uses of Authorization
505
506 This sort of service is useful when one entity needs to act on the
507 behalf of many other users. For example, users may be directed to
508 a web page to make changes to their personal information in their
509 LDAP entry. The users authenticate to the web server to establish
510 their identity, but the web server CGI cannot authenticate to the
511 LDAP server as that user to make changes for them. Instead, the
512 web server authenticates itself to the LDAP server as a service
513 identity, say,
514
515 >       cn=WebUpdate,dc=example,dc=com
516
517 and then it will SASL authorize to the DN of the user. Once so
518 authorized, the CGI makes changes to the LDAP entry of the user,
519 and as far as the slapd server can tell for its ACLs, it is the
520 user themself on the other end of the connection. The user could
521 have connected to the LDAP server directly and authenticated as
522 themself, but that would require the user to have more knowledge
523 of LDAP clients, knowledge which the web page provides in an easier
524 format.
525
526 Authorization can also be used to limit access to an account that
527 has greater access to the database. Such an account, perhaps even
528 the root DN specified in {{slapd.conf}}(5), can have a strict list
529 of people who can authorize to that DN. Changes to the LDAP database
530 could then be only allowed by that DN, and in order to become that
531 DN, users must first authenticate as one of the persons on the
532 list. This allows for better auditing of who made changes to the
533 LDAP database.  If people were allowed to authenticate directly to
534 the priviliged account, possibly through the {{EX:rootpw}}
535 {{slapd.conf}}(5) directive or through a {{EX:userPassword}}
536 attribute, then auditing becomes more difficult.
537
538 Note that after a successful authorization, the original authentication
539 DN in the LDAP connection is overwritten by the new DN from the
540 authorization request. If a service program is able to authenticate
541 itself as its own authentication DN and then authorize to other
542 DN's, and it is planning on switching to several different identities
543 during one LDAP session, it will need to authenticate itself each
544 time before authorizing to another DN. The slapd server does not
545 keep record of the service program's ability to switch to other
546 DN's.  On authentication mechanisms like Kerberos this will not
547 require multiple connections being made to the Kerberos server,
548 since the user's TGT and "ldap" session key are valid for multiple
549 uses for the several hours of the ticket lifetime.
550
551
552 H3: Authorization Identities
553
554 The authorization identity is sent to the slapd server via the -X
555 switch for {{ldapsearch}}(1) and other tools, or in the *authzid
556 parameter to the {{lutil_sasl_defaults}}() call. The identity can
557 be in one of two forms, either
558
559 >       u:<username>
560
561 or
562
563 >       dn:<dn>
564
565 In the first form, the <username> is from the same namespace as
566 the authentication identities above. It is the user's username as
567 it is refered to by the underlying authentication mechanism.
568 Authorization identities of this form are converted into a DN format
569 by the same function that the authentication process used, producing
570 an {{authorization request DN}} of the form
571
572 >       uid=<username>,cn=<realm>,cn=<mechanism>,cn=auth
573
574 That authorization request DN is then run through the same
575 {{EX:sasl-regexp}} process to convert it into a legitimate authorization
576 DN from the database. If it cannot be converted due to a failed
577 search from an LDAP URL, the authorization request fails with
578 "inappropriate access".  Otherwise, the DN string is now a legitimate
579 authorization DN ready to undergo approval.
580
581 If the authorization identity was provided in the second form, with
582 a {{EX:"dn:"}} prefix, the string after the prefix is already in
583 authorization DN form, ready to undergo approval.
584
585
586 H3: Authorization rules
587
588 Once slapd has the authorization DN, the actual approval process
589 begins. There are two attributes that the LDAP administrator can
590 put into LDAP entries to allow authorization:
591
592 >       saslAuthzTo
593 >       saslAuthzFrom
594
595 Both can be multivalued.  The {{EX:saslAuthzTo}} attribute is a
596 source rule, and it is placed into the entry associated with the
597 authentication DN to tell what authorization DNs the authenticated
598 DN is allowed to assume.  The second attribute is a destination
599 rule, and it is placed into the entry associated with the requested
600 authorization DN to tell which authenticated DNs may assume it.
601
602 The choice of which authorization policy attribute to use is up to
603 the administrator.  Source rules are checked first in the person's
604 authentication DN entry, and if none of the {{EX:saslAuthzTo}} rules
605 specify the authorization is permitted, the {{EX:saslAuthzFrom}}
606 rules in the authorization DN entry are then checked. If neither
607 case specifies that the request be honored, the request is denied.
608 Since the default behaviour is to deny authorization requests, rules
609 only specify that a request be allowed; there are no negative rules
610 telling what authorizations to deny.
611
612 The value(s) in the two attributes are of the same form as the
613 output of the replacement pattern of a {{EX:sasl-regexp}} directive:
614 either a DN or an LDAP URL. For example, if a {{EX:saslAuthzTo}}
615 value is a DN, that DN is one the authenticated user can authorize
616 to. On the other hand, if the {{EX:saslAuthzTo}} value is an LDAP
617 URL, the URL is used as an internal search of the LDAP database,
618 and the authenticated user can become ANY DN returned by the search.
619 If an LDAP entry looked like:
620
621 >       dn: cn=WebUpdate,dc=example,dc=com
622 >       saslAuthzTo: ldap:///dc=example,dc=com??sub?(objectclass=Person)
623
624 then any user who authenticated as cn=WebUpdate,dc=example,dc=com
625 could authorize to any other LDAP entry under the search base
626 "dc=example,dc=com" which has an objectClass of "Person".
627
628
629 H4: Notes on Authorization rules
630
631 An LDAP URL in a {{EX:saslAuthzTo}} or {{EX:saslAuthzFrom}} attribute
632 will return a set of DNs.  Each DN returned will be checked.
633 Searches which return a large set can cause the authorization
634 process to take an uncomfortably long time. Also, searches should
635 be performed on attributes that have been indexed by slapd.
636
637 To help produce more sweeping rules for {{EX:saslAuthzFrom}} and
638 {{EX:saslAuthzTo}}, the values of these attributes are allowed to
639 be DNs with regular expression characters in them. This means a
640 source rule like
641
642 >       saslAuthzTo: uid=.*,dc=example,dc=com
643
644 would allow that authenticated user to authorize to any DN that
645 matches the regular expression pattern given. This regular expression
646 comparison can be evaluated much faster than an LDAP search for
647 "uid=*".
648
649 Also note that the values in an authorization rule must be one of
650 the two forms: an LDAP URL or a DN (with or without regular expression
651 characters). Anything that does not begin with "ldap://" is taken
652 as a DN. It is not permissable to enter another authorization
653 identity of the form "u:<username>" as an authorization rule.
654
655 H4: Policy Configuration
656
657 The decision of which type of rules to use, {{EX:saslAuthzFrom}} or
658 {{EX:saslAuthzTo}}, will depend on the site's situation. For example, if
659 the set of people who may become a given identity can easily be
660 written as a search filter, then a single destination rule could
661 be written. If the set of people is not easily defined by a search
662 filter, and the set of people is small, it may be better to write
663 a source rule in the entries of each of those people who should be
664 allowed to perform the authorization.
665
666 By default, processing of authorization rules is disabled. The
667 {{EX:sasl-authz-policy}} directive must be set in the {{slapd.conf}}(5) file
668 to enable authorization. This directive can be set to {{EX:none}}
669 for no rules (the default), {{EX:from}} for source rules, {{EX:to}}
670 for destination rules, or {{EX:both}} for both source and destination
671 rules.
672
673 Destination rules are extremely powerful. If ordinary users have
674 access to write the {{EX:saslAuthzTo}} attribute in their own entries, then
675 they can write rules that would allow them to authorize as anyone else.
676 As such, when using destination rules, the {{EX:saslAuthzTo}} attribute
677 should be protected with an ACL that only allows privileged users
678 to set its values.