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