LDAP 身份验证
仅当您希望使用 LDAP 服务器对 Paragon Active Assurance 用户进行身份验证时,本章才有意义。
Paragon Active Assurance 支持使用 LDAP 以集中方式管理和验证用户。然后使用远程服务器而不是本地控制中心用户数据库完成认证。
当用户尝试登录“控制中心”时,后者会向 LDAP 服务器发送授权请求。根据响应,控制中心授予或拒绝用户访问 Paragon Active Assurance 帐户的权限,详见响应。
- 如果在从 LDAP 到控制中心的映射中定义了某个帐户两次,则用户将获得授予的两个帐户中的更高权限。因此,如果权限在一个列表元素中设置为“读取”,在另一个列表元素中设置为“admin”,则用户将获得该帐户的管理员权限。
- 如果一个权限映射向一个帐户授予权限,而另一个映射拒绝该权限,则用户将获得对该帐户的访问权限。
- 每次用户登录时,帐户权限都会与 LDAP 服务器同步。如果 Paragon Active Assurance 本地管理员授予用户其他权限,则这些权限仅在用户下次登录之前有效。相反,如果用户的权限在LDAP服务器上发生更改,则这些权限在下次登录之前不会生效。
- 如果在登录时输入的用户名与现有控制中心用户的电子邮件地址匹配,则登录将继续使用该用户,而不是正在创建的新用户。但是,在服务器身份验证期间,除了密码之外的所有用户配置文件详细信息都将被存储在服务器上的内容覆盖,只要这些详细信息已定义。用户仍然可以使用现有的控制中心密码登录。这意味着部分用户可以在“控制中心”中设置密码,以便在 LDAP 服务器出现故障时仍然可以登录。
- 如果登录时输入的用户名在“控制中心”中不存在,则会发生以下情况:
- 从用户
email
字段中读取用户的电子邮件地址。可以使用设置AUTH_LDAP_USER_ATTR_MAP
更改此字段的名称。 - 如果电子邮件地址有效,它也将被输入为控制中心数据库中的电子邮件地址。但是,用户仍必须使用其 LDAP 用户名登录。
- 如果电子邮件地址无效,则将使用该结构
username@LDAP_EMAIL_DOMAIN
创建一个电子邮件地址并将其输入到数据库中。编辑设置文件以更改此域。
- 从用户
我们将通过重现一个典型的 (OpenLDAP) 服务器端文件来说明上述内容,其中包含预加载到 LDAP 数据库中的数据,然后显示控制中心中需要的相应配置。
内容 ldap.ldif
:
dn: dc=example,dc=com objectClass: organization objectClass: dcObject objectClass: top dc: example o: example.com dn: ou=users,dc=example,dc=com objectClass: top objectClass: groupOfNames cn: Users member: uid=jsmith,dc=example,dc=com member: uid=jane.smith@example.com,dc=example,dc=com ou: users dn: uid=jsmith,dc=example,dc=com objectClass: top objectClass: person objectClass: organizationalPerson objectClass: inetOrgPerson objectClass: extensibleObject cn: John Smith givenName: John sn: Smith c: GB telephoneNumber: +44 20 7946 0296 mail: john.smith@example.com uid: jsmith userPassword: Password1 dn: uid=jane.smith@example.com,dc=example,dc=com objectClass: top objectClass: person objectClass: organizationalPerson objectClass: inetOrgPerson objectClass: extensibleObject cn: Jane Smith givenName: Jane sn: Smith c: GB telephoneNumber: +44 20 7946 0580 mail: jane.smith@example.com uid: jane.smith@example.com userPassword: Password1 dn: ou=admins,dc=example,dc=com objectClass: top objectClass: groupOfNames cn: Administrators member: uid=jdoe,dc=example,dc=com member: uid=jane.doe@example.com,dc=example,dc=com ou: admins dn: uid=jdoe,dc=example,dc=com objectClass: top objectClass: person objectClass: organizationalPerson objectClass: inetOrgPerson objectClass: extensibleObject cn: John Doe givenName: John sn: Doe c: GB telephoneNumber: +44 20 7946 0344 mail: john.doe@example.com uid: jdoe userPassword: Password1 dn: uid=jane.doe@example.com,dc=example,dc=com objectClass: top objectClass: person objectClass: organizationalPerson objectClass: inetOrgPerson objectClass: extensibleObject cn: Jane Doe givenName: Jane sn: Doe c: GB telephoneNumber: +44 20 7946 0113 mail: jane.doe@example.com uid: jane.doe@example.com userPassword: Password1
这将创建总共四个用户,两个具有写入权限(jsmith
和 jane.smith@example.com
),两个具有管理员权限(jdoe
和 jane.doe@example.com
)。请注意其中两个用户的用户名为 ,而另外两个uid
用户的用户名uid
由电子邮件地址组成。
为了在控制中心启用 LDAP 认证,必须在设置文件中 /etc/netrounds/netrounds.conf
提供以下属性:
# LDAP settings import ldap # NOTE: ActiveDirectoryGroupType is only needed if you are using Microsoft Active Directory. from django_auth_ldap.config import LDAPSearch, GroupOfNamesType, ActiveDirectoryGroupType AUTH_LDAP_ENABLED = True AUTH_LDAP_START_TLS = True AUTH_LDAP_SERVER_URI = 'ldap://ldap.example.com' AUTH_LDAP_USER_DN_TEMPLATE = 'uid=%(user)s,dc=example,dc=com' # LDAP user attribute value to use during lookup on database side AUTH_LDAP_USER_QUERY_FIELD = 'email' # This is the domain that will be appended to the username when the one from # LDAP is not a valid email AUTH_LDAP_EMAIL_DOMAIN='example.com' # Set up the basic group parameters # For vanilla LDAP such as OpenLDAP, use this. GROUP_OBJECTCLASS_NAME ='groupOfNames' # Uncomment this if using Microsoft Active Directory # GROUP_OBJECTCLASS_NAME = 'group' AUTH_LDAP_GROUP_SEARCH = LDAPSearch('dc=example,dc=com', ldap.SCOPE_ONELEVEL, '(objectClass=%s)' % GROUP_OBJECTCLASS_NAME ) # LDAP group type used to indicate group membership for a user AUTH_LDAP_GROUP_TYPE = GroupOfNamesType() # Note: If you are using Microsoft Active Directory, use this instead: # AUTH_LDAP_GROUP_TYPE = ActiveDirectoryGroupType() # Mapping between LDAP groups and Control Center account/permission AUTH_LDAP_ACCOUNT_GROUP_MAPPING = [ { 'dn': 'ou=users,dc=example,dc=com', 'accounts': [ { 'name': 'dev', 'permission': 'write' } ] }, { 'dn': 'ou=admins,dc=example,dc=com', 'accounts': [ { 'name': 'dev', 'permission': 'admin' } ] } ] # Populate the Django user from the LDAP directory AUTH_LDAP_USER_ATTR_MAP = { 'first_name': 'givenName', 'last_name': 'sn', 'email': 'mail', 'phone': 'telephoneNumber', 'country': 'c' } # LDAP connection options AUTH_LDAP_CONNECTION_OPTIONS = { # Limit on waiting for a network response in seconds. This is a timeout # returned by poll/select following a connect in case of no activity. # OpenLDAP specific. ldap.OPT_NETWORK_TIMEOUT: 30, # Timeout value for the synchronous API calls in seconds. OpenLDAP specific. ldap.OPT_TIMEOUT: 30 } # The following user must exist unless anonymous login is allowed # Non-anonymous bind DN # Note: It is mandatory for AUTH_LDAP_BIND_DN to start with a 'cn=' relative # distinguished name. Using 'uid=' will not work in case OpenLDAP is used as server. AUTH_LDAP_BIND_DN = 'cn=admin,dc=example,dc=com' # Non-anonymous bind password AUTH_LDAP_BIND_PASSWORD = 'Password1' # Finally, in order to get LDAP working, the first list item must be # added below AUTHENTICATION_BACKENDS = ( 'netrounds.domain.backends.LDAPAuthBackend', 'netrounds.domain.backends.AuthBackend', )
以上大部分内容遵循 https://django-auth-ldap.readthedocs.io/en/latest/reference.html#settings 记录的内容。