gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 12:04:42 27 4
gpt4 key购买 nike

我一直在尝试使用 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: 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 有一个范围的“概念”,我猜大多数(全部?)oidc 客户端都实现了它,至少 gangway 和 oauth2-proxy 都实现了。
所以我的解决方案是配置客户端(在我的例子中是 gangway 和 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

然后我可以在我的角色绑定(bind)中使用组而不是用户,不要忘记还配置 api-server 以将 dex 用于其 oidc。

希望有帮助

-罗伯特

关于kubernetes - 使用 DEX (LDAP) 进行身份验证时组为空,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55622317/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com