Skip to content
This repository has been archived by the owner on Jan 18, 2021. It is now read-only.

Commit

Permalink
split LDAP filters
Browse files Browse the repository at this point in the history
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
  • Loading branch information
butonic committed Jul 24, 2020
1 parent 40a23cd commit 45d8658
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 21 deletions.
12 changes: 12 additions & 0 deletions changelog/unreleased/update-ldap-config.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Bugfix: Update LDAP filters

With the separation of use and find filters we can now use a filter that taken into account a users uuid as well as his username. This is necessary to make sharing work with the new account service which assigns accounts an immutable account id that is different from the username. Furthermore, the separate find filters now allows searching users by their displayname or email as well.


```
userfilter = "(&(objectclass=posixAccount)(|(ownclouduuid={{.OpaqueId}})(cn={{.OpaqueId}})))"
findfilter = "(&(objectclass=posixAccount)(|(cn={{query}}*)(displayname={{query}}*)(mail={{query}}*)))"
```

https://github.com/owncloud/ocis-reva/pull/399
https://github.com/cs3org/reva/pull/996
7 changes: 7 additions & 0 deletions changelog/unreleased/update-reva-to-20200724.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Enhancement: update reva to v0.1.1-0.20200724...-....

- Update reva to v0.1.1-0.20200724...-....
- Split LDAP user filters (reva/#996)

https://github.com/owncloud/ocis-reva/pull/399
https://github.com/cs3org/reva/pull/996
1 change: 1 addition & 0 deletions pkg/command/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ func Users(cfg *config.Config) *cli.Command {
"port": cfg.Reva.LDAP.Port,
"base_dn": cfg.Reva.LDAP.BaseDN,
"userfilter": cfg.Reva.LDAP.UserFilter,
"findfilter": cfg.Reva.LDAP.FindFilter,
"groupfilter": cfg.Reva.LDAP.GroupFilter,
"bind_username": cfg.Reva.LDAP.BindDN,
"bind_password": cfg.Reva.LDAP.BindPassword,
Expand Down
1 change: 1 addition & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ type LDAP struct {
Port int
BaseDN string
UserFilter string
FindFilter string
GroupFilter string
BindDN string
BindPassword string
Expand Down
21 changes: 7 additions & 14 deletions pkg/flagset/authbasic.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,18 +123,11 @@ func AuthBasicWithConfig(cfg *config.Config) []cli.Flag {
Destination: &cfg.Reva.LDAP.BaseDN,
},
&cli.StringFlag{
Name: "ldap-userfilter",
Value: "(&(objectclass=posixAccount)(cn=%s))",
Usage: "LDAP userfilter",
EnvVars: []string{"REVA_LDAP_USERFILTER"},
Destination: &cfg.Reva.LDAP.UserFilter,
},
&cli.StringFlag{
Name: "ldap-groupfilter",
Value: "(&(objectclass=posixGroup)(cn=%s))",
Usage: "LDAP groupfilter",
EnvVars: []string{"REVA_LDAP_GROUPFILTER"},
Destination: &cfg.Reva.LDAP.GroupFilter,
Name: "ldap-loginfilter",
Value: "(&(objectclass=posixAccount)(|(cn={{login}})(mail={{login}})))",
Usage: "LDAP login filter",
EnvVars: []string{"REVA_LDAP_LOGINFILTER"},
Destination: &cfg.Reva.LDAP.LoginFilter,
},
&cli.StringFlag{
Name: "ldap-bind-dn",
Expand All @@ -160,7 +153,7 @@ func AuthBasicWithConfig(cfg *config.Config) []cli.Flag {
// ldap dn is always the dn
&cli.StringFlag{
Name: "ldap-schema-uid",
Value: "uid",
Value: "ownclouduuid",
Usage: "LDAP schema uid",
EnvVars: []string{"REVA_LDAP_SCHEMA_UID"},
Destination: &cfg.Reva.LDAP.Schema.UID,
Expand All @@ -174,7 +167,7 @@ func AuthBasicWithConfig(cfg *config.Config) []cli.Flag {
},
&cli.StringFlag{
Name: "ldap-schema-displayName",
Value: "sn",
Value: "displayname",
Usage: "LDAP schema displayName",
EnvVars: []string{"REVA_LDAP_SCHEMA_DISPLAYNAME"},
Destination: &cfg.Reva.LDAP.Schema.DisplayName,
Expand Down
23 changes: 16 additions & 7 deletions pkg/flagset/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,24 @@ func UsersWithConfig(cfg *config.Config) []cli.Flag {
},
&cli.StringFlag{
Name: "ldap-userfilter",
Value: "(&(objectclass=posixAccount)(cn=%s*))",
Usage: "LDAP userfilter",
Value: "(&(objectclass=posixAccount)(|(ownclouduuid={{.OpaqueId}})(cn={{.OpaqueId}})))",
Usage: "LDAP filter used when getting a user. The CS3 userid properties {{.OpaqueId}} and {{.Idp}} are available.",
EnvVars: []string{"REVA_LDAP_USERFILTER"},
Destination: &cfg.Reva.LDAP.UserFilter,
},
&cli.StringFlag{
Name: "ldap-groupfilter",
Value: "(&(objectclass=posixGroup)(cn=%s*))",
Usage: "LDAP groupfilter",
Name: "ldap-findfilter",
Value: "(&(objectclass=posixAccount)(|(cn={{query}}*)(displayname={{query}}*)(mail={{query}}*)))",
Usage: "LDAP filter used when searching for recipients. {{query}} will be replaced with the search query",
EnvVars: []string{"REVA_LDAP_FINDFILTER"},
Destination: &cfg.Reva.LDAP.FindFilter,
},
&cli.StringFlag{
Name: "ldap-groupfilter",
// FIXME the reva implementation needs to use the memberof overlay to get the cn when it only has the uuid,
// because the ldap schema either uses the dn or the member(of) attributes to establish membership
Value: "(&(objectclass=posixGroup)(ownclouduuid={{.OpaqueId}}*))", // This filter will never work
Usage: "LDAP filter used when getting the groups of a user. The CS3 userid properties {{.OpaqueId}} and {{.Idp}} are available.",
EnvVars: []string{"REVA_LDAP_GROUPFILTER"},
Destination: &cfg.Reva.LDAP.GroupFilter,
},
Expand Down Expand Up @@ -143,7 +152,7 @@ func UsersWithConfig(cfg *config.Config) []cli.Flag {
// ldap dn is always the dn
&cli.StringFlag{
Name: "ldap-schema-uid",
Value: "uid",
Value: "ownclouduuid",
Usage: "LDAP schema uid",
EnvVars: []string{"REVA_LDAP_SCHEMA_UID"},
Destination: &cfg.Reva.LDAP.Schema.UID,
Expand All @@ -157,7 +166,7 @@ func UsersWithConfig(cfg *config.Config) []cli.Flag {
},
&cli.StringFlag{
Name: "ldap-schema-displayName",
Value: "sn",
Value: "displayname",
Usage: "LDAP schema displayName",
EnvVars: []string{"REVA_LDAP_SCHEMA_DISPLAYNAME"},
Destination: &cfg.Reva.LDAP.Schema.DisplayName,
Expand Down

0 comments on commit 45d8658

Please sign in to comment.