Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch LDAP test to use entryUUID as unique id for groups #2345

Merged
merged 1 commit into from
Dec 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions changelog/unreleased/ldap-group-id.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Enhancement: Don't assume that the LDAP groupid in reva matches the name

This allows using attributes like e.g. `entryUUID` or any custom id attribute
as the id for groups.

https://github.com/cs3org/reva/pull/2345
2 changes: 1 addition & 1 deletion pkg/group/manager/ldap/ldap.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ func (m *manager) GetMembers(ctx context.Context, gid *grouppb.GroupId) ([]*user
m.c.BaseDN,
ldap.ScopeWholeSubtree, ldap.NeverDerefAliases, 0, 0, false,
m.getMemberFilter(gid),
[]string{m.c.Schema.CN}, // TODO use DN to look up user id
[]string{m.c.Schema.GID}, // TODO use DN to look up user id
nil,
)

Expand Down
7 changes: 5 additions & 2 deletions pkg/user/manager/ldap/ldap.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ type attributes struct {
UIDNumber string `mapstructure:"uidNumber"`
// GIDNumber is a numeric id that maps to a filesystem gid, eg. 654321
GIDNumber string `mapstructure:"gidNumber"`
// GID is an immutable group id
GID string `mapstructure:"gid"`
}

// Default attributes (Active Directory)
Expand All @@ -86,6 +88,7 @@ var ldapDefaults = attributes{
DisplayName: "displayName",
UIDNumber: "uidNumber",
GIDNumber: "gidNumber",
GID: "cn",
}

func parseConfig(m map[string]interface{}) (*config, error) {
Expand Down Expand Up @@ -392,7 +395,7 @@ func (m *manager) getLDAPUserGroups(ctx context.Context, conn *ldap.Conn, userEn
m.c.BaseDN,
ldap.ScopeWholeSubtree, ldap.NeverDerefAliases, 0, 0, false,
m.getGroupFilter(username),
[]string{m.c.Schema.CN}, // TODO use DN to look up group id
[]string{m.c.Schema.GID}, // TODO use DN to look up group id
nil,
)

Expand All @@ -407,7 +410,7 @@ func (m *manager) getLDAPUserGroups(ctx context.Context, conn *ldap.Conn, userEn
// FIXME this makes the users groups use the cn, not an immutable id
// FIXME 1. use the memberof or members attribute of a user to get the groups
// FIXME 2. ook up the id for each group
groups = append(groups, entry.GetEqualFoldAttributeValue(m.c.Schema.CN))
groups = append(groups, entry.GetEqualFoldAttributeValue(m.c.Schema.GID))
}
return groups, nil
}
Expand Down
7 changes: 4 additions & 3 deletions tests/oc-integration-tests/drone/ldap-users.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ uid="entryuuid"
displayName="displayName"
dn="dn"
cn="cn"
gid="entryuuid"

[grpc.services.groupprovider]
driver = "ldap"
Expand All @@ -56,16 +57,16 @@ hostname="ldap"
port=636
insecure=true
base_dn="dc=owncloud,dc=com"
groupfilter="(&(objectclass=posixGroup)(|(gid={{.OpaqueId}})(cn={{.OpaqueId}})))"
groupfilter="(&(objectclass=posixGroup)(|(entryuuid={{.OpaqueId}})(cn={{.OpaqueId}})))"
findfilter="(&(objectclass=posixGroup)(|(cn={{query}}*)(displayname={{query}}*)(mail={{query}}*)))"
attributefilter="(&(objectclass=posixGroup)({{attr}}={{value}}))"
memberfilter="(&(objectclass=posixAccount)(cn={{.OpaqueId}}))"
memberfilter="(&(objectclass=posixAccount)(entryuuid={{.OpaqueId}}))"
bind_username="cn=admin,dc=owncloud,dc=com"
bind_password="admin"
idp="http://localhost:20080"

[grpc.services.groupprovider.drivers.ldap.schema]
gid="cn"
gid="entryuuid"
displayName="cn"
dn="dn"
cn="cn"
7 changes: 4 additions & 3 deletions tests/oc-integration-tests/local-mesh/ldap-users.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ uid="uid"
displayName="displayName"
dn="dn"
cn="cn"
gid="entryuuid"

[grpc.services.groupprovider]
driver = "ldap"
Expand All @@ -57,16 +58,16 @@ hostname="localhost"
port=636
insecure=true
base_dn="dc=owncloud,dc=com"
groupfilter="(&(objectclass=posixGroup)(|(gid={{.OpaqueId}})(cn={{.OpaqueId}})))"
groupfilter="(&(objectclass=posixGroup)(|(entryuuid={{.OpaqueId}})(cn={{.OpaqueId}})))"
findfilter="(&(objectclass=posixGroup)(|(cn={{query}}*)(displayname={{query}}*)(mail={{query}}*)))"
attributefilter="(&(objectclass=posixGroup)({{attr}}={{value}}))"
memberfilter="(&(objectclass=posixAccount)(cn={{.OpaqueId}}))"
memberfilter="(&(objectclass=posixAccount)(entryuuid={{.OpaqueId}}))"
bind_username="cn=admin,dc=owncloud,dc=com"
bind_password="admin"
idp="http://localhost:40080"

[grpc.services.groupprovider.drivers.ldap.schema]
gid="cn"
gid="entryuuid"
displayName="cn"
dn="dn"
cn="cn"
7 changes: 4 additions & 3 deletions tests/oc-integration-tests/local/ldap-users.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ uid="entryuuid"
displayName="displayName"
dn="dn"
cn="cn"
gid="entryuuid"

[grpc.services.groupprovider]
driver = "ldap"
Expand All @@ -60,16 +61,16 @@ hostname="openldap"
port=636
insecure=true
base_dn="dc=owncloud,dc=com"
groupfilter="(&(objectclass=posixGroup)(|(gid={{.OpaqueId}})(cn={{.OpaqueId}})))"
groupfilter="(&(objectclass=posixGroup)(|(entryuuid={{.OpaqueId}})(cn={{.OpaqueId}})))"
findfilter="(&(objectclass=posixGroup)(|(cn={{query}}*)(displayname={{query}}*)(mail={{query}}*)))"
attributefilter="(&(objectclass=posixGroup)({{attr}}={{value}}))"
memberfilter="(&(objectclass=posixAccount)(cn={{.OpaqueId}}))"
memberfilter="(&(objectclass=posixAccount)(entryuuid={{.OpaqueId}}))"
bind_username="cn=admin,dc=owncloud,dc=com"
bind_password="admin"
idp="http://localhost:20080"

[grpc.services.groupprovider.drivers.ldap.schema]
gid="cn"
gid="entryuuid"
displayName="cn"
dn="dn"
cn="cn"