From 69e189aec4fe3d8987fac8b90c16d05c3b9b408b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Tue, 27 Oct 2020 15:21:45 +0100 Subject: [PATCH 1/2] when sharing via ocs look up user by username MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jörn Friedrich Dreyer --- changelog/unreleased/ocs-lookup-user-by-username.md | 5 +++++ .../owncloud/ocs/handlers/apps/sharing/shares/shares.go | 7 ++++--- 2 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 changelog/unreleased/ocs-lookup-user-by-username.md diff --git a/changelog/unreleased/ocs-lookup-user-by-username.md b/changelog/unreleased/ocs-lookup-user-by-username.md new file mode 100644 index 0000000000..550aeb2f75 --- /dev/null +++ b/changelog/unreleased/ocs-lookup-user-by-username.md @@ -0,0 +1,5 @@ +Bugfix: when sharing via ocs look up user by username + +The ocs api returns usernames when listing share recipients, so the lookup when creating the share needs to search the usernames and not the userid. + +https://github.com/cs3org/reva/pull/1281 diff --git a/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/shares.go b/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/shares.go index fe170753a5..5b88a5aec3 100644 --- a/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/shares.go +++ b/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/shares.go @@ -195,8 +195,9 @@ func (h *Handler) createUserShare(w http.ResponseWriter, r *http.Request) { return } - userRes, err := c.GetUser(ctx, &userpb.GetUserRequest{ - UserId: &userpb.UserId{OpaqueId: shareWith}, + userRes, err := c.GetUserByClaim(ctx, &userpb.GetUserByClaimRequest{ + Claim: "username", + Value: shareWith, }) if err != nil { response.WriteOCSError(w, r, response.MetaServerError.StatusCode, "error searching recipient", err) @@ -271,7 +272,7 @@ func (h *Handler) createUserShare(w http.ResponseWriter, r *http.Request) { createShareReq := &collaboration.CreateShareRequest{ Opaque: &types.Opaque{ Map: map[string]*types.OpaqueEntry{ - "role": &types.OpaqueEntry{ + "role": { Decoder: "json", Value: val, }, From d7dd62a4d086474310038b1c2e3cd08d9b023916 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Tue, 27 Oct 2020 16:15:29 +0100 Subject: [PATCH 2/2] update ldap filters in tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jörn Friedrich Dreyer --- tests/oc-integration-tests/drone/ldap-users.toml | 9 +++++---- tests/oc-integration-tests/local/ldap-users.toml | 9 +++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/tests/oc-integration-tests/drone/ldap-users.toml b/tests/oc-integration-tests/drone/ldap-users.toml index bbe07b447a..28e5e7ad91 100644 --- a/tests/oc-integration-tests/drone/ldap-users.toml +++ b/tests/oc-integration-tests/drone/ldap-users.toml @@ -14,8 +14,7 @@ auth_manager = "ldap" hostname="ldap" port=636 base_dn="dc=owncloud,dc=com" -userfilter="(&(objectclass=posixAccount)(cn=%s*))" -groupfilter="(&(objectclass=posixGroup)(cn=%s*))" +loginfilter="(&(objectclass=posixAccount)(|(cn={{login}}))(uid={{login}}))" bind_username="cn=admin,dc=owncloud,dc=com" bind_password="admin" idp="http://localhost:18000" @@ -32,8 +31,10 @@ driver = "ldap" hostname="ldap" port=636 base_dn="dc=owncloud,dc=com" -userfilter="(&(objectclass=posixAccount)(cn=%s*))" -groupfilter="(&(objectclass=posixGroup)(cn=%s*))" +userfilter="(&(objectclass=posixAccount)(|(uid={{.OpaqueId}})(cn={{.OpaqueId}})))" +findfilter="(&(objectclass=posixAccount)(|(cn={{query}}*)(displayname={{query}}*)(mail={{query}}*)))" +attributefilter="(&(objectclass=posixAccount)({{attr}}={{value}}))" +groupfilter="(&(objectclass=posixGroup)(cn={{.OpaqueId}}))" bind_username="cn=admin,dc=owncloud,dc=com" bind_password="admin" idp="http://localhost:18000" diff --git a/tests/oc-integration-tests/local/ldap-users.toml b/tests/oc-integration-tests/local/ldap-users.toml index 8a124cdd30..3bc0897276 100644 --- a/tests/oc-integration-tests/local/ldap-users.toml +++ b/tests/oc-integration-tests/local/ldap-users.toml @@ -14,8 +14,7 @@ auth_manager = "ldap" hostname="localhost" port=636 base_dn="dc=owncloud,dc=com" -userfilter="(&(objectclass=posixAccount)(cn=%s*))" -groupfilter="(&(objectclass=posixGroup)(cn=%s*))" +loginfilter="(&(objectclass=posixAccount)(|(cn={{login}}))(uid={{login}}))" bind_username="cn=admin,dc=owncloud,dc=com" bind_password="admin" idp="http://localhost:18000" @@ -32,8 +31,10 @@ driver = "ldap" hostname="localhost" port=636 base_dn="dc=owncloud,dc=com" -userfilter="(&(objectclass=posixAccount)(cn=%s*))" -groupfilter="(&(objectclass=posixGroup)(cn=%s*))" +userfilter="(&(objectclass=posixAccount)(|(uid={{.OpaqueId}})(cn={{.OpaqueId}})))" +findfilter="(&(objectclass=posixAccount)(|(cn={{query}}*)(displayname={{query}}*)(mail={{query}}*)))" +attributefilter="(&(objectclass=posixAccount)({{attr}}={{value}}))" +groupfilter="(&(objectclass=posixGroup)(cn={{.OpaqueId}}))" bind_username="cn=admin,dc=owncloud,dc=com" bind_password="admin" idp="http://localhost:18000"