📄 sasl.sdf
字号:
# Copyright 1999-2007 The OpenLDAP Foundation, All Rights Reserved.# COPYING RESTRICTIONS APPLY, see COPYRIGHT.H1: Using SASLOpenLDAP clients and servers are capable of authenticating via the{{TERM[expand]SASL}} ({{TERM:SASL}}) framework, which is detailedin {{REF:RFC2222}}. This chapter describes how to make use ofSASL in OpenLDAP.There are several industry standard authentication mechanisms thatcan be used with SASL, including {{TERM:GSSAPI}} for {{TERM:Kerberos}}V, DIGEST-MD5, and PLAIN and EXTERNAL for use with {{TERM[expand]TLS}}(TLS).The standard client tools provided with OpenLDAP Software, such as{{ldapsearch}}(1) and {{ldapmodify}}(1), will by default attemptto authenticate the user to the {{slapd}}(8) server using SASL.Basic authentication service can be set up by the LDAP administratorwith a few steps, allowing users to be authenticated to the slapdserver as their LDAP entry. With a few extra steps, some users andservices can be allowed to exploit SASL's proxy authorizationfeature, allowing them to authenticate themselves and then switchtheir identity to that of another user or service.This chapter assumes you have read {{Cyrus SASL for SystemAdministrators}}, provided with the {{PRD:Cyrus}} {{PRD:SASL}}package (in {{FILE:doc/sysadmin.html}}) and have a working CyrusSASL installation. You should use the Cyrus SASL {{EX:sample_client}}and {{EX:sample_server}} to test your SASL installation beforeattempting to make use of it with OpenLDAP Software.Note that in the following text the term {{user}} is used to describea person or application entity who is connecting to the LDAP servervia an LDAP client, such as {{ldapsearch}}(1). That is, the term{{user}} not only applies to both an individual using an LDAP client,but to an application entity which issues LDAP client operationswithout direct user control. For example, an e-mail server whichuses LDAP operations to access information held in an LDAP serveris an application entity.H2: SASL Security ConsiderationsSASL offers many different authentication mechanisms. This sectionbriefly outlines security considerations.Some mechanisms, such as PLAIN and LOGIN, offer no greater securityover LDAP {{simple}} authentication. Like LDAP {{simple}}authentication, such mechanisms should not be used unless you haveadequate security protections in place. It is recommended thatthese mechanisms be used only in conjunction with {{TERM[expand]TLS}}(TLS). Use of PLAIN and LOGIN are not discussed further in thisdocument.The DIGEST-MD5 mechanism is the mandatory-to-implement authenticationmechanism for LDAPv3. Though DIGEST-MD5 is not a strong authenticationmechanism in comparison with trusted third party authenticationsystems (such as Kerberos or public key systems), it does offersignificant protections against a number of attacks. Unlike theCRAM-MD5 mechanism, it prevents chosen plaintext attacks. DIGEST-MD5is favored over the use of plaintext password mechanisms. TheCRAM-MD5 mechanism is deprecated in favor of DIGEST-MD5. Use of{{SECT:DIGEST-MD5}} is discussed below.The GSSAPI mechanism utilizes Kerberos V to provide secureauthentication services. The KERBEROS_V4 mechanism is availablefor those using Kerberos IV. Kerberos is viewed as a secure,distributed authentication system suitable for both small and largeenterprises. Use of {{SECT:GSSAPI}} and {{SECT:KERBEROS_V4}} arediscussed below.The EXTERNAL mechanism utilizes authentication services providedby lower level network services such as {{TERM:TLS}} (TLS). Whenused in conjunction with {{TERM:TLS}} {{TERM:X.509}}-based publickey technology, EXTERNAL offers strong authentication. Use ofEXTERNAL is discussed in the {{SECT:Using TLS}} chapter.There are other strong authentication mechanisms to choose from,including {{TERM:OTP}} (one time passwords) and {{TERM:SRP}} (secureremote passwords). These mechanisms are not discussed in thisdocument.H2: SASL AuthenticationGetting basic SASL authentication running involves a few steps.The first step configures your slapd server environment sothat it can communicate with client programs using the securitysystem in place at your site. This usually involves setting up aservice key, a public key, or other form of secret. The second stepconcerns mapping authentication identities to LDAP DN's, whichdepends on how entries are laid out in your directory. An explanationof the first step will be given in the next section using KerberosV4 as an example mechanism. The steps necessary for your site'sauthentication mechanism will be similar, but a guide to everymechanism available under SASL is beyond the scope of this chapter.The second step is described in the section {{SECT:Mapping Authentication Identities}}.H3: GSSAPIThis section describes the use of the SASL GSSAPI mechanism andKerberos V with OpenLDAP. It will be assumed that you have KerberosV deployed, you are familiar with the operation of the system, andthat your users are trained in its use. This section also assumesyou have familiarized yourself with the use of the GSSAPI mechanismby reading {{Configuring GSSAPI and Cyrus SASL}} (provided withCyrus SASL in the {{FILE:doc/gssapi}} file) and successfullyexperimented with the Cyrus provided {{EX:sample_server}} and{{EX:sample_client}} applications. General information aboutKerberos is available at {{URL:http://web.mit.edu/kerberos/www/}}.To use the GSSAPI mechanism with {{slapd}}(8) one must create a servicekey with a principal for {{ldap}} service within the realm for the hoston which the service runs. For example, if you run {{slapd}} on{{EX:directory.example.com}} and your realm is {{EX:EXAMPLE.COM}},you need to create a service key with the principal:> ldap/directory.example.com@EXAMPLE.COMWhen {{slapd}}(8) runs, it must have access to this key. This isgenerally done by placing the key into a keytab file,{{FILE:/etc/krb5.keytab}}. See your Kerberos and Cyrus SASLdocumentation for information regarding keytab location settings.To use the GSSAPI mechanism to authenticate to the directory, theuser obtains a Ticket Granting Ticket (TGT) prior to running theLDAP client. When using OpenLDAP client tools, the user may mandateuse of the GSSAPI mechanism by specifying {{EX:-Y GSSAPI}} as acommand option.For the purposes of authentication and authorization, {{slapd}}(8)associates an authentication request DN of the form:> uid=<primary[/instance]>,cn=<realm>,cn=gssapi,cn=authContinuing our example, a user with the Kerberos principal{{EX:kurt@EXAMPLE.COM}} would have the associated DN:> uid=kurt,cn=example.com,cn=gssapi,cn=authand the principal {{EX:ursula/admin@FOREIGN.REALM}} would have theassociated DN:> uid=ursula/admin,cn=foreign.realm,cn=gssapi,cn=authThe authentication request DN can be used directly ACLs and{{EX:groupOfNames}} "member" attributes, since it is of legitimateLDAP DN format. Or alternatively, the authentication DN could bemapped before use. See the section {{SECT:Mapping AuthenticationIdentities}} for details.H3: KERBEROS_V4This section describes the use of the SASL KERBEROS_V4 mechanismwith OpenLDAP. It will be assumed that you are familiar with theworkings of the Kerberos IV security system, and that your site hasKerberos IV deployed. Your users should be familiar withauthentication policy, how to receive credentials ina Kerberos ticket cache, and how to refresh expired credentials.Note: KERBEROS_V4 and Kerberos IV are deprecated in favor of GSSAPIand Kerberos V.Client programs will need to be able to obtain a session key foruse when connecting to your LDAP server. This allows the LDAP serverto know the identity of the user, and allows the client to know itis connecting to a legitimate server. If encryption layers are tobe used, the session key can also be used to help negotiate thatoption.The slapd server runs the service called "{{ldap}}", and the serverwill require a srvtab file with a service key. SASL aware clientprograms will be obtaining an "ldap" service ticket with the user'sticket granting ticket (TGT), with the instance of the ticketmatching the hostname of the OpenLDAP server. For example, if yourrealm is named {{EX:EXAMPLE.COM}} and the slapd server is runningon the host named {{EX:directory.example.com}}, the {{FILE:/etc/srvtab}}file on the server will have a service key> ldap.directory@EXAMPLE.COMWhen an LDAP client is authenticating a user to the directory usingthe KERBEROS_IV mechanism, it will request a session key for thatsame principal, either from the ticket cache or by obtaining a newone from the Kerberos server. This will require the TGT to beavailable and valid in the cache as well. If it is not present orhas expired, the client may print out the message:> ldap_sasl_interactive_bind_s: Local errorWhen the service ticket is obtained, it will be passed to the LDAPserver as proof of the user's identity. The server will extractthe identity and realm out of the service ticket using SASLlibrary calls, and convert them into an {{authentication requestDN}} of the form> uid=<username>,cn=<realm>,cn=<mechanism>,cn=authSo in our above example, if the user's name were "adamson", theauthentication request DN would be:> uid=adamsom,cn=example.com,cn=kerberos_v4,cn=authThis authentication request DN can be used directly ACLs or,alternatively, mapped prior to use. See the section {{SECT:MappingAuthentication Identities}} for details.H3: DIGEST-MD5This section describes the use of the SASL DIGEST-MD5 mechanismusing secrets stored either in the directory itself or in CyrusSASL's own database. DIGEST-MD5 relies on the client and the serversharing a "secret", usually a password. The server generates achallenge and the client a response proving that it knows the sharedsecret. This is much more secure than simply sending the secretover the wire.Cyrus SASL supports several shared-secret mechanisms. To do this,it needs access to the plaintext password (unlike mechanisms whichpass plaintext passwords over the wire, where the server can storea hashed version of the password).The server's copy of the shared-secret may be stored in Cyrus SASL'sown {{sasldb}} database, in an external system accessed via{{saslauthd}}, or in LDAP database itself. In either case it isvery important to apply file access controls and LDAP access controlsto prevent exposure of the passwords. The configuration and commandsdiscussed in this section assume the use of Cyrus SASL 2.1.To use secrets stored in {{sasldb}}, simply add users with the{{saslpasswd2}} command:> saslpasswd2 -c <username>The passwords for such users must be managed with the {{saslpasswd2}}command.To use secrets stored in the LDAP directory, place plaintext passwordsin the {{EX:userPassword}} attribute. It will be necessary to addan option to {{EX:slapd.conf}} to make sure that passwords set usingthe LDAP Password Modify Operation are stored in plaintext:> password-hash {CLEARTEXT}Passwords stored in this way can be managed either with {{ldappasswd}}(1)or by simply modifying the {{EX:userPassword}} attribute. Regardless ofwhere the passwords are stored, a mapping will be needed fromauthentication request DN to user's DN.The DIGEST-MD5 mechanism produces authentication IDs of the form:> uid=<username>,cn=<realm>,cn=digest-md5,cn=authIf the default realm is used, the realm name is omitted from the ID,giving:> uid=<username>,cn=digest-md5,cn=authSee {{SECT: Mapping Authentication Identities}} below for informationon optional mapping of identities.With suitable mappings in place, users can specify SASL IDs whenperforming LDAP operations and sldb}} and the directory itself willbe used to verify the authentication. For example, the useridentified by the directory entry:> dn: cn=Andrew Findlay+uid=u000997,dc=example,dc=com> objectclass: inetOrgPerson> objectclass: person> sn: Findlay> uid: u000997> userPassword: secretcan issue commands of the form:> ldapsearch -Y DIGEST-MD5 -U u000997 ...Note: in each of the above cases, no authorization identity (e.g.{{EX:-X}}) was provided. Unless you are attempting {{SECT:SASLProxy Authorization}}, no authorization identity should be specified.The server will infer an authorization identity from authenticationidentity (as described below).H3: Mapping Authentication IdentitiesThe authentication mechanism in the slapd server will use SASLlibrary calls to obtain the authenticated user's "username", basedon whatever underlying authentication mechanism was used. Thisusername is in the namespace of the authentication mechanism, andnot in the normal LDAP namespace. As stated in the sections above,that username is reformatted into an authentication request DN ofthe form> uid=<username>,cn=<realm>,cn=<mechanism>,cn=author> uid=<username>,cn=<mechanism>,cn=authdepending on whether or not <mechanism> employs the concept of"realms". Note also that the realm part will be omitted if thedefault realm was used in the authentication.The {{ldapwhoami}}(1) command may be used to determine the identityassociated with the user. It is very useful for determining properfunction of mappings.It is not intended that you should add LDAP entries of the aboveform to your LDAP database. Chances are you have an LDAP entry foreach of the persons that will be authenticating to LDAP, laid outin your directory tree, and the tree does not start at cn=auth.But if your site has a clear mapping between the "username" and anLDAP entry for the person, you will be able to configure your LDAPserver to automatically map a authentication request DN to theuser's {{authentication DN}}.Note: it is not required that the authentication request DN nor theuser's authentication DN resulting from the mapping refer to anentry held in the directory. However, additional capabilitiesbecome available (see below).The LDAP administrator will need to tell the slapd server how tomap an authentication request DN to a user's authentication DN.This is done by adding one or more {{EX:authz-regexp}} directives tothe {{slapd.conf}}(5) file. This directive takes two arguments:> authz-regexp <search pattern> <replacement pattern>The authentication request DN is compared to the search patternusing the regular expression functions {{regcomp}}() and {{regexec}}(),and if it matches, it is rewritten as the replacement pattern. Ifthere are multiple {{EX:authz-regexp}} directives, only the firstwhose search pattern matches the authentication identity is used.The string that is output from the replacement pattern should bethe authentication DN of the user or an LDAP URL. If replacementstring produces a DN, the entry named by this DN need not be heldby this server. If the replace string produces an LDAP URL, thatLDAP URL must evaluate to one and only one entry held by this server.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -