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