使用DEX(LDAP)进行身份验证时,组为空

时间:2019-04-10 22:47:41

标签: kubernetes ldap ldap-query oidc openid-dex

我一直在尝试使用DEX for LDAP对OIDC进行身份验证。我已成功进行身份验证,但问题是LDAP搜索未返回组。以下是我的DEX配置和LDAP数据。请帮帮我

截图:登录成功,组为空

enter image description here

我的Dex配置

# User search maps a username and password entered by a user to a LDAP entry.
userSearch:
# BaseDN to start the search from. It will translate to the query
# "(&(objectClass=person)(uid=<username>))".
baseDN: ou=People,dc=ec2-54-185-211-121,dc=us-west-2,dc=compute,dc=amazonaws,dc=com
# Optional filter to apply when searching the directory.
#filter: "(objectClass=posixAccount)"
# username attribute used for comparing user entries. This will be translated
# and combine with the other filter as "(<attr>=<username>)".
username: mail
# The following three fields are direct mappings of attributes on the user entry.
# String representation of the user.
idAttr: uid
# Required. Attribute to map to Email.
emailAttr: mail
# Maps to display name of users. No default value.
nameAttr: uid

# Group search queries for groups given a user entry.
groupSearch:
# BaseDN to start the search from. It will translate to the query
# "(&(objectClass=group)(member=<user uid>))".
baseDN: dc=ec2-54-185-211-121,dc=us-west-2,dc=compute,dc=amazonaws,dc=com
# Optional filter to apply when searching the directory.
#filter: "(objectClass=posixGroup)"
# Following two fields are used to match a user to a group. It adds an additional
# requirement to the filter that an attribute in the group must match the user's
# attribute value.
userAttr: uid
groupAttr: memberUid
# Represents group name.
nameAttr: cn

我的LDAP数据

  

dn:   ou = People,dc = ec2-54-185-211-121,dc = us-west-2,dc = compute,dc = amazonaws,dc = com   ou:人物objectClass:organizationalUnit

     

dn:   uid = johndoe,ou = People,dc = ec2-54-185-211-121,dc = us-west-2,dc = compute,dc = amazonaws,dc = com   gecos:John Doe uid:johndoe loginShell:/ bin / bash邮件:   john.doe@example.org home目录:/ home / jdoe cn:John Doe sn:Doe   uidNumber:10002 objectClass:posixAccount objectClass:inetOrgPerson   objectClass:最高用户密码:bar gidNumber:10002

     

dn:   uid = janedoe,ou = People,dc = ec2-54-185-211-121,dc = us-west-2,dc = compute,dc = amazonaws,dc = com   gecos:Jane Doe uid:janedoe loginShell:/ bin / bash邮件:   jane.doe@example.org home目录:/ home / jdoe cn:Jane Doe sn:Doe   uidNumber:10001 objectClass:posixAccount objectClass:inetOrgPerson   objectClass:最高用户密码:foo gidNumber:10001

     

dn:   ou = Groups,dc = ec2-54-185-211-121,dc = us-west-2,dc = compute,dc = amazonaws,dc = com   ou:分组objectClass:organizationalUnit

     

dn:   cn = admins,ou = Groups,dc = ec2-54-185-211-121,dc = us-west-2,dc = compute,dc = amazonaws,dc = com   cn:admins objectClass:posixGroup objectClass:top gidNumber:20001   memberUid:janedoe memberUid:johndoe

     

dn:   cn = developers,ou = Groups,dc = ec2-54-185-211-121,dc = us-west-2,dc = compute,dc = amazonaws,dc = com   cn:开发人员objectClass:posixGroup objectClass:top gidNumber:   20002 memberUid:janedoe

1 个答案:

答案 0 :(得分:0)

很抱歉重播,但直到现在我才知道答案:)

我遇到了同样的问题,在我的设置中,我使用了dex (quay.io/dexidp/dex:v2.16.0)来使用MS AD。我在测试中使用了 kubernetes 1.13

我使用heptiolabs/gangway (gcr.io/heptio-images/gangway:v3.0.0)来生成kubeconfig,并使用pusher/oauth2_proxy (quay.io/pusher/oauth2_proxy)来处理仪表板登录。

我花了很多时间尝试在dex中进行不同的ldap设置,但没有使AD组出现在dex日志中或使它们在kubernetes中工作,并且我阅读的每个示例都仅使用用户。

对我来说,问题和解决方案不在dex配置中,如果您告诉dex,则dex将向ldap请求组。 一切都在客户中。 OIDC有一个范围的“概念”,我想大多数(所有?)oidc客户端都实现了它,至少舷梯和oauth2-proxy都实现了。 因此,对我来说,解决方案是配置客户端(在我的情况下为通道和oauth2-proxy),以便它们也向dex请求组。

在舷梯中,我使用了以下配置(包括注释)

# Used to specify the scope of the requested Oauth authorization.
# scopes: ["openid", "profile", "email", "offline_access"]
scopes: ["openid", "profile", "email", "offline_access", "groups"]

对于oauth2-proxy,我将此添加到了args部署

- args:
        - --scope=openid profile email groups

然后我可以在角色绑定中使用组而不是用户,不要忘记也将api服务器配置为使用dex作为其oidc。

希望有帮助

-罗伯特