]> git.sur5r.net Git - openldap/blob - doc/guide/admin/sasl.sdf
Moving from Slurpd.
[openldap] / doc / guide / admin / sasl.sdf
1 # Copyright 1999-2007 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:RFC4422}}.   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, {{TERM:DIGEST-MD5}}, and {{TERM:PLAIN}} and {{TERM:EXTERNAL}}
14 for use with {{TERM[expand]TLS}} (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 {{TERM:LDAP}} directory server using
19 SASL.  Basic authentication service can be set up by the LDAP
20 administrator with a few steps, allowing users to be authenticated
21 to the slapd server as their LDAP entry.  With a few extra steps,
22 some users and services can be allowed to exploit SASL's proxy
23 authorization feature, allowing them to authenticate themselves and
24 then switch 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 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 {{TERM:Kerberos}} or public key systems), it does
60 offer significant protections against a number of attacks.  Unlike
61 the {{TERM:CRAM-MD5}} mechanism, it prevents chosen plaintext
62 attacks.  DIGEST-MD5 is favored over the use of plaintext password
63 mechanisms.  The CRAM-MD5 mechanism is deprecated in favor of
64 DIGEST-MD5.  Use of {{SECT:DIGEST-MD5}} is discussed below.
65
66 The GSSAPI mechanism utilizes {{TERM:GSS-API}} {{TERM:Kerberos}} V
67 to provide secure authentication services.  The KERBEROS_V4 mechanism
68 is available for those using Kerberos IV.  Kerberos is viewed as a
69 secure, distributed authentication system suitable for both small
70 and large enterprises.  Use of {{SECT:GSSAPI}} and {{SECT:KERBEROS_V4}}
71 are 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 that it
89 can communicate with client programs using the security system in
90 place at your site. This usually involves setting up a service key,
91 a public key, or other form of secret. The second step concerns
92 mapping authentication identities to LDAP {{TERM: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 {{SECT:Mapping
99 Authentication Identities}}.
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 file,
125 {{FILE:/etc/krb5.keytab}}.  See your Kerberos and Cyrus SASL
126 documentation for information regarding keytab location settings.
127
128 To use the GSSAPI mechanism to authenticate to the directory, the
129 user obtains a Ticket Granting Ticket (TGT) prior to running the
130 LDAP client.  When using OpenLDAP client tools, the user may mandate
131 use of the GSSAPI mechanism by specifying {{EX:-Y GSSAPI}} as a
132 command option.
133
134 For the purposes of authentication and authorization, {{slapd}}(8)
135 associates an authentication request DN of the form:
136
137 >       uid=<primary[/instance]>,cn=<realm>,cn=gssapi,cn=auth
138
139 Continuing our example, a user with the Kerberos principal
140 {{EX:kurt@EXAMPLE.COM}} would have the associated DN:
141
142 >       uid=kurt,cn=example.com,cn=gssapi,cn=auth
143
144 and the principal {{EX:ursula/admin@FOREIGN.REALM}} would have the
145 associated DN:
146
147 >       uid=ursula/admin,cn=foreign.realm,cn=gssapi,cn=auth
148
149
150 The authentication request DN can be used directly ACLs and
151 {{EX:groupOfNames}} "member" attributes, since it is of legitimate
152 LDAP DN format.  Or alternatively, the authentication DN could be
153 mapped before use.  See the section {{SECT:Mapping Authentication
154 Identities}} for details.
155
156
157 H3: KERBEROS_V4
158
159 This section describes the use of the SASL KERBEROS_V4 mechanism
160 with OpenLDAP.  It will be assumed that you are familiar with the
161 workings of the Kerberos IV security system, and that your site has
162 Kerberos IV deployed.  Your users should be familiar with
163 authentication policy, how to receive credentials in
164 a Kerberos ticket cache, and how to refresh expired credentials.
165
166 Note: KERBEROS_V4 and Kerberos IV are deprecated in favor of GSSAPI
167 and Kerberos V.
168
169 Client programs will need to be able to obtain a session key for
170 use when connecting to your LDAP server. This allows the LDAP server
171 to know the identity of the user, and allows the client to know it
172 is connecting to a legitimate server. If encryption layers are to
173 be used, the session key can also be used to help negotiate that
174 option.
175
176 The slapd server runs the service called "{{ldap}}", and the server
177 will require a srvtab file with a service key.  SASL aware client
178 programs will be obtaining an "ldap" service ticket with the user's
179 ticket granting ticket (TGT), with the instance of the ticket
180 matching the hostname of the OpenLDAP server. For example, if your
181 realm is named {{EX:EXAMPLE.COM}} and the slapd server is running
182 on the host named {{EX:directory.example.com}}, the {{FILE:/etc/srvtab}}
183 file on the server will have a service key
184
185 >       ldap.directory@EXAMPLE.COM
186
187 When an LDAP client is authenticating a user to the directory using
188 the KERBEROS_IV mechanism, it will request a session key for that
189 same principal, either from the ticket cache or by obtaining a new
190 one from the Kerberos server.  This will require the TGT to be
191 available and valid in the cache as well.  If it is not present or
192 has expired, the client may print out the message:
193
194 >       ldap_sasl_interactive_bind_s: Local error
195
196 When the service ticket is obtained, it will be passed to the LDAP
197 server as proof of the user's identity.  The server will extract
198 the identity and realm out of the service ticket using SASL
199 library calls, and convert them into an {{authentication request
200 DN}} of the form
201
202 >       uid=<username>,cn=<realm>,cn=<mechanism>,cn=auth
203
204 So in our above example, if the user's name were "adamson", the
205 authentication request DN would be:
206
207 >       uid=adamsom,cn=example.com,cn=kerberos_v4,cn=auth
208
209 This authentication request DN can be used directly ACLs or,
210 alternatively, mapped prior to use.  See the section {{SECT:Mapping
211 Authentication Identities}} for details.
212
213
214 H3: DIGEST-MD5
215
216 This section describes the use of the SASL DIGEST-MD5 mechanism
217 using secrets stored either in the directory itself or in Cyrus
218 SASL's own database. DIGEST-MD5 relies on the client and the server
219 sharing a "secret", usually a password. The server generates a
220 challenge and the client a response proving that it knows the shared
221 secret. This is much more secure than simply sending the secret
222 over the wire.
223
224 Cyrus SASL supports several shared-secret mechanisms. To do this,
225 it needs access to the plaintext password (unlike mechanisms which
226 pass plaintext passwords over the wire, where the server can store
227 a hashed version of the password).
228
229 The server's copy of the shared-secret may be stored in Cyrus SASL's
230 own {{sasldb}} database, in an external system accessed via
231 {{saslauthd}}, or in LDAP database itself.  In either case it is
232 very important to apply file access controls and LDAP access controls
233 to prevent exposure of the passwords.  The configuration and commands
234 discussed in this section assume the use of Cyrus SASL 2.1.
235
236 To use secrets stored in {{sasldb}}, simply add users with the
237 {{saslpasswd2}} command:
238
239 >       saslpasswd2 -c <username>
240
241 The passwords for such users must be managed with the {{saslpasswd2}}
242 command.
243
244 To use secrets stored in the LDAP directory, place plaintext passwords
245 in the {{EX:userPassword}} attribute.  It will be necessary to add
246 an option to {{EX:slapd.conf}} to make sure that passwords set using
247 the LDAP Password Modify Operation are stored in plaintext:
248
249 >       password-hash   {CLEARTEXT}
250
251 Passwords stored in this way can be managed either with {{ldappasswd}}(1)
252 or by simply modifying the {{EX:userPassword}} attribute.  Regardless of
253 where the passwords are stored, a mapping will be needed from
254 authentication request DN to user's DN.
255
256 The DIGEST-MD5 mechanism produces authentication IDs of the form:
257
258 >       uid=<username>,cn=<realm>,cn=digest-md5,cn=auth
259
260 If the default realm is used, the realm name is omitted from the ID,
261 giving:
262
263 >       uid=<username>,cn=digest-md5,cn=auth
264
265 See {{SECT: Mapping Authentication Identities}} below for information
266 on optional mapping of identities.
267
268 With suitable mappings in place, users can specify SASL IDs when
269 performing LDAP operations and sldb}} and the directory itself will
270 be used to verify the authentication.  For example, the user
271 identified by the directory entry:
272
273 >       dn: cn=Andrew Findlay+uid=u000997,dc=example,dc=com
274 >       objectclass: inetOrgPerson
275 >       objectclass: person
276 >       sn: Findlay
277 >       uid: u000997
278 >       userPassword: secret
279
280 can issue commands of the form:
281
282 >       ldapsearch -Y DIGEST-MD5 -U u000997 ...
283
284 Note: in each of the above cases, no authorization identity (e.g.
285 {{EX:-X}}) was provided.   Unless you are attempting {{SECT:SASL
286 Proxy Authorization}}, no authorization identity should be specified.
287 The server will infer an authorization identity from authentication
288 identity (as described below).
289
290
291 H3: Mapping Authentication Identities
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 normal LDAP namespace. As stated in the sections above,
298 that username is reformatted into an authentication request DN of
299 the 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
309 default realm was used in the authentication.
310
311 The {{ldapwhoami}}(1) command may be used to determine the identity
312 associated with the user.  It is very useful for determining proper
313 function of mappings.
314
315 It is not intended that you should add LDAP entries of the above
316 form to your LDAP database.  Chances are you have an LDAP entry for
317 each of the persons that will be authenticating to LDAP, laid out
318 in your directory tree, and the tree does not start at cn=auth.
319 But if your site has a clear mapping between the "username" and an
320 LDAP entry for the person, you will be able to configure your LDAP
321 server to automatically map a authentication request DN to the
322 user's {{authentication DN}}.
323
324 Note: it is not required that the authentication request DN nor the
325 user's authentication DN resulting from the mapping refer to an
326 entry held in the directory.  However, additional capabilities
327 become available (see below).
328
329 The LDAP administrator will need to tell the slapd server how to
330 map an authentication request DN to a user's authentication DN.
331 This is done by adding one or more {{EX:authz-regexp}} directives to
332 the {{slapd.conf}}(5) file.  This directive takes two arguments:
333
334 >       authz-regexp   <search pattern>   <replacement pattern>
335
336 The authentication request DN is compared to the search pattern
337 using the regular expression functions {{regcomp}}() and {{regexec}}(),
338 and if it matches, it is rewritten as the replacement pattern. If
339 there are multiple {{EX:authz-regexp}} directives, only the first
340 whose search pattern matches the authentication identity is used.
341 The string that is output from the replacement pattern should be
342 the authentication DN of the user or an LDAP URL.  If replacement
343 string produces a DN, the entry named by this DN need not be held
344 by this server.  If the replace string produces an LDAP URL, that
345 LDAP URL must evaluate to one and only one entry held by this server.
346
347 The search pattern can contain any of the regular expression
348 characters listed in {{regexec}}(3C). The main characters of note
349 are dot ".", asterisk "*", and the open and close parenthesis "("
350 and ")".  Essentially, the dot matches any character, the asterisk
351 allows zero or more repeats of the immediately preceding character
352 or pattern, and terms in parenthesis are remembered for the replacement
353 pattern.
354
355 The replacement pattern will produce either a DN or URL refering
356 to the user.  Anything from the authentication request DN that
357 matched a string in parenthesis in the search pattern is stored in
358 the variable "$1". That variable "$1" can appear in the replacement
359 pattern, and will be replaced by the string from the authentication
360 request DN. If there were multiple sets of parentheses in the search
361 pattern, the variables $2, $3, etc are used.
362
363 H3: Direct Mapping
364
365 Where possible, direct mapping of the authentication request DN to
366 the user's DN is generally recommended.  Aside from avoiding the
367 expense of searching for the user's DN, it allows mapping to
368 DNs which refer to entries not held by this server. 
369
370 Suppose the authentication request DN is written as:
371
372 >       uid=adamson,cn=example.com,cn=gssapi,cn=auth
373
374 and the user's actual LDAP entry is:
375
376 >       uid=adamson,ou=people,dc=example,dc=com
377
378 then the following {{EX:authz-regexp}} directive in {{slapd.conf}}(5)
379 would provide for direct mapping.
380
381 >       authz-regexp 
382 >         uid=([^,]*),cn=example.com,cn=gssapi,cn=auth
383 >         uid=$1,ou=people,dc=example,dc=com
384
385 An even more lenient rule could be written as
386
387 >       authz-regexp
388 >         uid=([^,]*),cn=[^,]*,cn=auth 
389 >         uid=$1,ou=people,dc=example,dc=com
390
391 Be careful about setting the search pattern too leniently, however,
392 since it may mistakenly allow persons to become authenticated as a
393 DN to which they should not have access.  It is better to write
394 several strict directives than one lenient directive which has
395 security holes.  If there is only one authentication mechanism in
396 place at your site, and zero or one realms in use, you might be
397 able to map between authentication identities and LDAP DN's with a
398 single {{EX:authz-regexp}} directive.
399
400 Don't forget to allow for the case where the realm is omitted as
401 well as the case with an explicitly specified realm. This may well
402 require a separate {{EX:authz-regexp}} directive for each case, with
403 the explicit-realm entry being listed first.
404
405 H3: Search-based mappings
406
407 There are a number of cases where mapping to a LDAP URL may be
408 appropriate.  For instance, some sites may have person objects
409 located in multiple areas of the LDAP tree, such as if there were
410 an {{EX:ou=accounting}} tree and an {{EX:ou=engineering}} tree,
411 with persons interspersed between them.  Or, maybe the desired
412 mapping must be based upon information in the user's information.
413 Consider the need to map the above authentication request DN to
414 user whose entry is as follows:
415
416 >       dn: cn=Mark Adamson,ou=People,dc=Example,dc=COM
417 >       objectclass: person
418 >       cn: Mark Adamson
419 >       uid: adamson
420
421 The information in the authentication request DN is insufficient
422 to allow the user's DN to be directly derived, instead the user's
423 DN must be searched for.  For these situations, a replacement pattern
424 which produces a LDAP URL can be used in the {{EX:authz-regexp}}
425 directives.  This URL will then be used to perform an internal
426 search 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:authz-regexp}}
445 directive might be written as
446
447 >       authz-regexp 
448 >         uid=([^,]*),cn=example.com,cn=gssapi,cn=auth  
449 >         ldap:///ou=people,dc=example,dc=com??one?(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 the
456 authentication request DN.
457
458 The attributes that are used in the search filter <filter> in the
459 URL should be indexed to allow faster searching. If they are not,
460 the authentication step alone can take uncomfortably long periods,
461 and users may assume the server is down.
462
463 A more complex site might have several realms in use, each mapping
464 to a different subtree in the directory.  These can be handled with
465 statements of the form:
466
467 >       # Match Engineering realm
468 >       authz-regexp
469 >          uid=([^,]*),cn=engineering.example.com,cn=digest-md5,cn=auth
470 >          ldap:///dc=eng,dc=example,dc=com??one?(&(uid=$1)(objectClass=person))
471 >
472 >       # Match Accounting realm
473 >       authz-regexp
474 >          uid=([^,].*),cn=accounting.example.com,cn=digest-md5,cn=auth
475 >          ldap:///dc=accounting,dc=example,dc=com??one?(&(uid=$1)(objectClass=person))
476 >
477 >       # Default realm is customers.example.com
478 >       authz-regexp
479 >          uid=([^,]*),cn=digest-md5,cn=auth
480 >          ldap:///dc=customers,dc=example,dc=com??one?(&(uid=$1)(objectClass=person))
481
482 Note that the explicitly-named realms are handled first, to avoid
483 the realm name becoming part of the UID.  Also note the use of scope
484 and filters to limit matching to desirable entries.
485
486 Note as well that {{EX:authz-regexp}} internal search are subject
487 to access controls.  Specifically, the authentication identity
488 must have {{EX:auth}} access.
489
490 See {{slapd.conf}}(5) for more detailed information.
491
492
493 H2: SASL Proxy Authorization
494
495 The SASL offers a feature known as {{proxy authorization}}, which
496 allows an authenticated user to request that they act on the behalf
497 of another user.  This step occurs after the user has obtained an
498 authentication DN, and involves sending an authorization identity
499 to the server. The server will then make a decision on whether or
500 not to allow the authorization to occur. If it is allowed, the
501 user's LDAP connection is switched to have a binding DN derived
502 from the authorization identity, and the LDAP session proceeds with
503 the access of the new authorization DN.
504
505 The decision to allow an authorization to proceed depends on the
506 rules and policies of the site where LDAP is running, and thus
507 cannot be made by SASL alone. The SASL library leaves it up to the
508 server to make the decision. The LDAP administrator sets the
509 guidelines of who can authorize to what identity by adding information
510 into the LDAP database entries. By default, the authorization
511 features are disabled, and must be explicitly configured by the
512 LDAP administrator before use.
513
514
515 H3: Uses of Proxy Authorization
516
517 This sort of service is useful when one entity needs to act on the
518 behalf of many other users. For example, users may be directed to
519 a web page to make changes to their personal information in their
520 LDAP entry. The users authenticate to the web server to establish
521 their identity, but the web server CGI cannot authenticate to the
522 LDAP server as that user to make changes for them. Instead, the
523 web server authenticates itself to the LDAP server as a service
524 identity, say,
525
526 >       cn=WebUpdate,dc=example,dc=com
527
528 and then it will SASL authorize to the DN of the user. Once so
529 authorized, the CGI makes changes to the LDAP entry of the user,
530 and as far as the slapd server can tell for its ACLs, it is the
531 user themself on the other end of the connection. The user could
532 have connected to the LDAP server directly and authenticated as
533 themself, but that would require the user to have more knowledge
534 of LDAP clients, knowledge which the web page provides in an easier
535 format.
536
537 Proxy authorization can also be used to limit access to an account
538 that has greater access to the database. Such an account, perhaps
539 even the root DN specified in {{slapd.conf}}(5), can have a strict
540 list of people who can authorize to that DN. Changes to the LDAP
541 database could then be only allowed by that DN, and in order to
542 become that DN, users must first authenticate as one of the persons
543 on the list. This allows for better auditing of who made changes
544 to the LDAP database.  If people were allowed to authenticate
545 directly to the priviliged account, possibly through the {{EX:rootpw}}
546 {{slapd.conf}}(5) directive or through a {{EX:userPassword}}
547 attribute, then auditing becomes more difficult.
548
549 Note that after a successful proxy authorization, the original
550 authentication DN of the LDAP connection is overwritten by the new
551 DN from the authorization request. If a service program is able to
552 authenticate itself as its own authentication DN and then authorize
553 to other DN's, and it is planning on switching to several different
554 identities during one LDAP session, it will need to authenticate
555 itself each time before authorizing to another DN (or use a different
556 proxy authorization mechanism).  The slapd server does not keep
557 record of the service program's ability to switch to other DN's.
558 On authentication mechanisms like Kerberos this will not require
559 multiple connections being made to the Kerberos server, since the
560 user's TGT and "ldap" session key are valid for multiple uses for
561 the several hours of the ticket lifetime.
562
563
564 H3: SASL Authorization Identities
565
566 The SASL authorization identity is sent to the LDAP server via the
567 {{EX:-X}} switch for {{ldapsearch}}(1) and other tools, or in the
568 {{EX:*authzid}} parameter to the {{lutil_sasl_defaults}}() call.
569 The identity can be in one of two forms, either
570
571 >       u:<username>
572
573 or
574
575 >       dn:<dn>
576
577 In the first form, the <username> is from the same namespace as
578 the authentication identities above. It is the user's username as
579 it is refered to by the underlying authentication mechanism.
580 Authorization identities of this form are converted into a DN format
581 by the same function that the authentication process used, producing
582 an {{authorization request DN}} of the form
583
584 >       uid=<username>,cn=<realm>,cn=<mechanism>,cn=auth
585
586 That authorization request DN is then run through the same
587 {{EX:authz-regexp}} process to convert it into a legitimate authorization
588 DN from the database. If it cannot be converted due to a failed
589 search from an LDAP URL, the authorization request fails with
590 "inappropriate access".  Otherwise, the DN string is now a legitimate
591 authorization DN ready to undergo approval.
592
593 If the authorization identity was provided in the second form, with
594 a {{EX:"dn:"}} prefix, the string after the prefix is already in
595 authorization DN form, ready to undergo approval.
596
597
598 H3: Proxy Authorization Rules
599
600 Once slapd has the authorization DN, the actual approval process
601 begins. There are two attributes that the LDAP administrator can
602 put into LDAP entries to allow authorization:
603
604 >       authzTo
605 >       authzFrom
606
607 Both can be multivalued.  The {{EX:authzTo}} attribute is a
608 source rule, and it is placed into the entry associated with the
609 authentication DN to tell what authorization DNs the authenticated
610 DN is allowed to assume.  The second attribute is a destination
611 rule, and it is placed into the entry associated with the requested
612 authorization DN to tell which authenticated DNs may assume it.
613
614 The choice of which authorization policy attribute to use is up to
615 the administrator.  Source rules are checked first in the person's
616 authentication DN entry, and if none of the {{EX:authzTo}} rules
617 specify the authorization is permitted, the {{EX:authzFrom}}
618 rules in the authorization DN entry are then checked. If neither
619 case specifies that the request be honored, the request is denied.
620 Since the default behaviour is to deny authorization requests, rules
621 only specify that a request be allowed; there are no negative rules
622 telling what authorizations to deny.
623
624 The value(s) in the two attributes are of the same form as the
625 output of the replacement pattern of a {{EX:authz-regexp}} directive:
626 either a DN or an LDAP URL. For example, if a {{EX:authzTo}}
627 value is a DN, that DN is one the authenticated user can authorize
628 to. On the other hand, if the {{EX:authzTo}} value is an LDAP
629 URL, the URL is used as an internal search of the LDAP database,
630 and the authenticated user can become ANY DN returned by the search.
631 If an LDAP entry looked like:
632
633 >       dn: cn=WebUpdate,dc=example,dc=com
634 >       authzTo: ldap:///dc=example,dc=com??sub?(objectclass=person)
635
636 then any user who authenticated as {{EX:cn=WebUpdate,dc=example,dc=com}}
637 could authorize to any other LDAP entry under the search base
638 {{EX:dc=example,dc=com}} which has an objectClass of {{EX:Person}}.
639
640
641 H4: Notes on Proxy Authorization Rules
642
643 An LDAP URL in a {{EX:authzTo}} or {{EX:authzFrom}} attribute
644 will return a set of DNs.  Each DN returned will be checked.  Searches
645 which return a large set can cause the authorization process to
646 take an uncomfortably long time. Also, searches should be performed
647 on attributes that have been indexed by slapd.
648
649 To help produce more sweeping rules for {{EX:authzFrom}} and
650 {{EX:authzTo}}, the values of these attributes are allowed to
651 be DNs with regular expression characters in them. This means a
652 source rule like
653
654 >       authzTo: uid=[^,]*,dc=example,dc=com
655
656 would allow that authenticated user to authorize to any DN that
657 matches the regular expression pattern given. This regular expression
658 comparison can be evaluated much faster than an LDAP search for
659 {{EX:(uid=*)}}.
660
661 Also note that the values in an authorization rule must be one of
662 the two forms: an LDAP URL or a DN (with or without regular expression
663 characters). Anything that does not begin with "{{EX:ldap://}}" is
664 taken as a DN. It is not permissable to enter another authorization
665 identity of the form "{{EX:u:<username>}}" as an authorization rule.
666
667
668 H4: Policy Configuration
669
670 The decision of which type of rules to use, {{EX:authzFrom}}
671 or {{EX:authzTo}}, will depend on the site's situation. For
672 example, if the set of people who may become a given identity can
673 easily be written as a search filter, then a single destination
674 rule could be written. If the set of people is not easily defined
675 by a search filter, and the set of people is small, it may be better
676 to write a source rule in the entries of each of those people who
677 should be allowed to perform the proxy authorization.
678
679 By default, processing of proxy authorization rules is disabled.
680 The {{EX:authz-policy}} directive must be set in the
681 {{slapd.conf}}(5) file to enable authorization. This directive can
682 be set to {{EX:none}} for no rules (the default), {{EX:to}} for
683 source rules, {{EX:from}} for destination rules, or {{EX:both}} for
684 both source and destination rules.
685
686 Source rules are extremely powerful. If ordinary users have
687 access to write the {{EX:authzTo}} attribute in their own
688 entries, then they can write rules that would allow them to authorize
689 as anyone else.  As such, when using source rules, the
690 {{EX:authzTo}} attribute should be protected with an ACL that
691 only allows privileged users to set its values.
692