JupyterHub 的 LDAP 身份验证器
项目描述
jupyterhub-ldap-身份验证器
JupyterHub的 LDAP Authenticator 插件。这个项目是在考虑企业 LDAP 集成的情况下编写的,包括以下功能:
- 支持多个 LDAP 服务器并允许配置
server_pool_strategy
- 每个身份验证请求使用单个只读 LDAP 连接
allowed_groups
验证身份验证用户是否存在于 LDAP 中并且是测试身份验证之前的成员allowed_groups
支持在列表中使用嵌套组- 支持在登录时创建域用户主目录
这个项目的灵感来自ldapauthenticator项目
安装
使用 pip 安装:
pip install jupyterhub-ldap-authenticator
配置
要启用 LDAPAuthenticator,请将以下行添加到 Jupyterhub 配置文件并使用下面列出的参数扩展配置。
c.JupyterHub.authenticator_class = 'ldapauthenticator.LDAPAuthenticator'
- LDAPAuthenticator.server_hosts
- 服务器的 scheme://hostname:hostport 格式的名称、IP 或完整 URL 列表(必需)。
# example- list of complete urls
c.LDAPAuthenticator.server_hosts = ['ldaps://ldap1.example.com:636', 'ldaps://ldap2.example.com:636']
# example - list of names
c.LDAPAuthenticator.server_hosts = ['ldap1.example.com', 'ldap2.example.com']
# example - list of ips
c.LDAPAuthenticator.server_hosts = ['10.0.0.1', '10.0.0.2']
- LDAPAuthenticator.server_port
- LDAP 服务器正在侦听的端口。对于明文连接,通常为 389,对于安全连接,通常为 636(默认为无)。
# example
c.LDAPAuthenticator.server_port = 636
- LDAPAuthenticator.server_use_ssl
- 布尔值,指定连接是否在安全端口上(默认为 False)。
# example
c.LDAPAuthenticator.server_use_ssl = True
- LDAPAuthenticator.server_connect_timeout
- 在引发异常之前建立 ldap 连接时允许的超时(以秒为单位)(默认为无)。
# example
c.LDAPAuthenticator.server_connect_timeout = 10
- LDAPAuthenticator.server_receive_timeout
- 在引发异常之前允许来自已建立的 ldap 连接的响应超时(默认为无)。
# example
c.LDAPAuthenticator.server_receive_timeout = 10
- LDAPAuthenticator.server_pool_strategy
- 可用的池 HA 策略(默认为“FIRST”)。
- FIRST:获取池中的第一台服务器,如果 'server_pool_active' 设置为 True,则获取第一台可用的服务器。
- ROUND_ROBIN:每次打开连接时使用池中的后续服务器。如果 'server_pool_active' 设置为 True 不可用的服务器将被丢弃。
- RANDOM:每次打开连接时,都会在池中选择一个随机服务器。如果 'server_pool_active' 设置为 True 不可用的服务器将被丢弃。
# example
c.LDAPAuthenticator.server_pool_strategy = 'FIRST'
- LDAPAuthenticator.server_pool_active
- 如果为 True,则 ServerPool 策略将检查服务器可用性。设置为整数以获得在放弃前尝试的最大周期数(默认为 True)。
# example - boolean
c.LDAPAuthenticator.server_pool_active = True
# example - maximum number of tries
c.LDAPAuthenticator.server_pool_active = 3
- LDAPAuthenticator.server_pool_exhaust
- 如果为 True,则将从池中删除任何不活动的服务器。如果设置为整数,这将是无法访问的服务器被视为离线的秒数。当此超时到期时,服务器将重新插入池中并再次检查可用性(默认为 False)。
# example - boolean
c.LDAPAuthenticator.server_pool_exhaust = True
# example - offline timeout
c.LDAPAuthenticator.server_pool_exhaust = 600
- LDAPAuthenticator.bind_user_dn
- 用于登录以进行简单绑定的用户帐户(默认为无)。
# example - freeipa
c.LDAPAuthenticator.bind_user_dn = 'uid=imauser,cn=users,cn=accounts,dc=example,dc=com'
# example - Active Directory
c.LDAPAuthenticator.bind_user_dn = 'CN=imauser,CN=Users,DC=example,DC=com'
- LDAPAuthenticator.bind_user_password
- 简单绑定的用户密码(默认为无)。
# example
c.LDAPAuthenticator.bind_user_password = 'password'
- LDAPAuthenticator.user_search_base
- 目录信息树中用户搜索将开始的位置。
# example - freeipa
c.LDAPAuthenticator.user_search_base = 'cn=users,cn=accounts,dc=example,dc=com'
# example - active directory
c.LDAPAuthenticator.user_search_base = 'CN=Users,DC=example,DC=com'
- LDAPAuthenticator.user_search_filter
- LDAP 搜索过滤器以验证组织内是否存在身份验证用户。包含“{username}”的搜索过滤器将该值替换为验证用户的用户名。
# example - freeipa
c.LDAPAuthenticator.user_search_filter = '(&(objectClass=person)(uid={username}))'
# example - active directory
c.LDAPAuthenticator.user_search_filter = '(&(objectCategory=person)(objectClass=user)(sAMAccountName={username}))'
- LDAPAuthenticator.user_membership_attribute
- 用于关联用户组成员身份的 LDAP 属性(默认为“memberOf”)。
# example
c.LDAPAuthenticator.user_membership_attribute = 'memberOf'
- LDAPAuthenticator.group_search_base
- 目录信息树中组搜索将开始的位置。包含“{group}”的搜索字符串将替换为从 allowed_groups 获取的条目
# example - freeipa
c.LDAPAuthenticator.group_search_base = 'cn=groups,cn=accounts,dc=example,dc=com'
# example - active directory
c.LDAPAuthenticator.group_search_base = 'CN=Groups,DC=example,DC=com'
- LDAPAuthenticator.group_search_filter
- LDAP 搜索过滤器返回在 allowed_groups 参数中定义的组的成员。包含“{group}”的搜索过滤器将该值替换为 allowed_groups 参数中提供的组 dns。
# example - freeipa
c.LDAPAuthenticator.group_search_filter = '(&(objectClass=ipausergroup)(memberOf={group}))'
# example - active directory
c.LDAPAuthenticator.group_search_filter = '(&(objectClass=group)(memberOf={group}))'
- LDAPAuthenticator.allowed_groups
- 用户必须是其成员才能获得登录权限的 LDAP 组 DN 列表。如果未定义或设置为 None,allowed_groups 将被短路并允许所有用户(默认为 None)。
# example
c.LDAPAuthenticator.allowed_groups = ['cn=jupyterhub-users,cn=groups,cn=accounts,dc=example,dc=com']
- LDAPAuthenticator.allow_nested_groups
- 允许在 allowed_groups 的嵌套组中递归搜索成员的布尔值(默认为 False)。
# example
c.LDAPAuthenticator.allow_nested_groups = True
- LDAPAuthenticator.username_pattern
- 所有有效用户名必须匹配的正则表达式模式。如果用户名与此处指定的模式不匹配,则不会尝试验证。如果未设置,则允许任何用户名(默认为无)。
# example - freeipa
c.LDAPAuthenticator.username_pattern = '[a-zA-Z0-9_.][a-zA-Z0-9_.-]{0,252}[a-zA-Z0-9_.$-]?'
# example - active directory
c.LDAPAuthenticator.username_pattern = '[a-zA-Z0-9_.][a-zA-Z0-9_.-]{8,20}[a-zA-Z0-9_.$-]?'
- LDAPAuthenticator.create_user_home_dir
- 允许在登录时创建用户主目录的布尔值
# example
c.LDAPAuthenticator.create_user_home_dir = True
- LDAPAuthenticator.create_user_home_dir_cmd
- 将用户主目录创建为字符串列表时使用的命令。用户名将作为最后一个参数附加。在 Linux 系统上默认为 `mkhomedir_helper`。
# example
c.LDAPAuthenticator.create_user_home_dir_cmd = ['mkhomedir_helper']
例子
FreeIPA 集成
# freeipa example
c.JupyterHub.authenticator_class = 'ldapauthenticator.LDAPAuthenticator'
c.LDAPAuthenticator.server_hosts = ['ldaps://ldap1.example.com:636', 'ldaps://ldap2.example.com:636']
c.LDAPAuthenticator.bind_user_dn = 'uid=imauser,cn=users,cn=accounts,dc=example,dc=com'
c.LDAPAuthenticator.bind_user_password = 'imapassword'
c.LDAPAuthenticator.user_search_base = 'cn=users,cn=accounts,dc=example,dc=com'
c.LDAPAuthenticator.user_search_filter = '(&(objectClass=person)(uid={username}))'
c.LDAPAuthenticator.user_membership_attribute = 'memberOf'
c.LDAPAuthenticator.group_search_base = 'cn=groups,cn=accounts,dc=example,dc=com'
c.LDAPAuthenticator.group_search_filter = '(&(objectClass=ipausergroup)(memberOf={group}))'
c.LDAPAuthenticator.allowed_groups = ['cn=jupyterhub-users,cn=groups,cn=accounts,dc=example,dc=com']
c.LDAPAuthenticator.allow_nested_groups = True
c.LDAPAuthenticator.username_pattern = '[a-zA-Z0-9_.][a-zA-Z0-9_.-]{0,252}[a-zA-Z0-9_.$-]?'
c.LDAPAuthenticator.create_user_home_dir = True
c.LDAPAuthenticator.create_user_home_dir_cmd = ['mkhomedir_helper']
活动目录集成
# active directory example
c.JupyterHub.authenticator_class = 'ldapauthenticator.LDAPAuthenticator'
c.LDAPAuthenticator.server_hosts = ['ldaps://ldap1.example.com:636', 'ldaps://ldap2.example.com:636']
c.LDAPAuthenticator.bind_user_dn = 'CN=imauser,CN=Users,DC=example,DC=com'
c.LDAPAuthenticator.bind_user_password = 'imapassword'
c.LDAPAuthenticator.user_search_base = 'CN=Users,DC=example,DC=com'
c.LDAPAuthenticator.user_search_filter = '(&(objectCategory=person)(objectClass=user)(sAMAccountName={username}))
c.LDAPAuthenticator.user_membership_attribute = 'memberOf'
c.LDAPAuthenticator.group_search_base = 'CN=Groups,DC=example,DC=com'
c.LDAPAuthenticator.group_search_filter = '(&(objectClass=group)(memberOf={group}))'
c.LDAPAuthenticator.allowed_groups = ['CN=jupyterhub-users,CN=Groups,DC=example,DC=com']
c.LDAPAuthenticator.allow_nested_groups = True
c.LDAPAuthenticator.username_pattern = '[a-zA-Z0-9_.][a-zA-Z0-9_.-]{8,20}[a-zA-Z0-9_.$-]?'
c.LDAPAuthenticator.create_user_home_dir = True
c.LDAPAuthenticator.create_user_home_dir_cmd = ['mkhomedir_helper']
OpenLDAP 集成
由于 OpenLDAP 本身不支持其用户对象中的 memberOf 属性,因此allowed_groups
在以下示例中,范围已被短路:
# openldap example
c.JupyterHub.authenticator_class = 'ldapauthenticator.LDAPAuthenticator'
c.LDAPAuthenticator.server_hosts = ['ldaps://ldap1.example.com:636', 'ldaps://ldap2.example.com:636']
c.LDAPAuthenticator.bind_user_dn = 'uid=imauser,ou=People,dc=example,dc=com'
c.LDAPAuthenticator.bind_user_password = 'imapassword'
c.LDAPAuthenticator.user_search_base = 'ou=People,dc=example,dc=com'
c.LDAPAuthenticator.user_search_filter = '(&(objectClass=posixAccount)(uid={username}))'
c.LDAPAuthenticator.username_pattern = '[a-zA-Z0-9_.][a-zA-Z0-9_.-]{0,252}[a-zA-Z0-9_.$-]?'
c.LDAPAuthenticator.create_user_home_dir = True
c.LDAPAuthenticator.create_user_home_dir_cmd = ['mkhomedir_helper']
项目详情
关
jupyterhub -ldap-authenticator-0.4.1.tar.gz 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 85f981a359693ff9c7123d0b5c4614f53bcea9363fb096b7e3123b0a67757409 |
|
MD5 | 5b83a4268a73984dad21742af9680055 |
|
布莱克2-256 | 3db2ae1bf57bd750ab93eaf5ca29976a4e390146b7cc50e71c759dc134818c03 |
关
jupyterhub_ldap_authenticator -0.4.1-py3-none-any.whl 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | dde410cf440c03d9f04cc63b2a0680512a970ca907b089759eb874fb9e3a60db |
|
MD5 | 49739a34aeb23192a1aad4bf311572cc |
|
布莱克2-256 | 271a7ae0ee68ab5c845f34cd7214ca90748dff09a9b7cca92f4b5b1a287e33bc |