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

Groups are empty while authenticating using DEX (LDAP)

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

截图:登录成功,群组为空

我的 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: People 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 mail: john.doe@example.org homeDirectory: / home / jdoe cn: John Doe sn: Doe uidNumber: 10002 objectClass: posixAccount objectClass: inetOrgPerson objectClass: top userPassword: 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 mail: jane.doe@example.org homeDirectory: / home / jdoe cn: Jane Doe sn: Doe uidNumber: 10001 objectClass: posixAccount objectClass: inetOrgPerson objectClass: top userPassword: foo gidNumber: 10001

dn: ou=Groups,dc=ec2-54-185-211-121,dc=us-west-2,dc=compute,dc=amazonaws,dc=com ou: Groups 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: developers objectClass: posixGroup objectClass: top gidNumber: 20002 memberUid: janedoe

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

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

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

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

我的问题和解决方案不在 dex 配置中,如果您告诉 dex 这样做,dex 会从 ldap 请求组。 一切都在客户身上。 OIDC 有一个 "concept" 范围,我想大多数(全部?)oidc 客户端都实现了它,至少 gangway 和 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-server 以将 dex 用于其 oidc。

希望对您有所帮助

-罗伯特