From 60b9372f4db4b3e8c9d5b69dd70d63ec4da382e9 Mon Sep 17 00:00:00 2001 From: Florian Schade Date: Thu, 5 Sep 2024 13:29:01 +0200 Subject: [PATCH 1/2] fix(ocm): use host instead of hostDomain for normalizing ocm providers --- changelog/unreleased/ocm-fix-federated-userid.md | 1 + pkg/ocm/provider/authorizer/json/json.go | 2 +- pkg/ocm/provider/authorizer/json/json_test.go | 7 ++++--- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/changelog/unreleased/ocm-fix-federated-userid.md b/changelog/unreleased/ocm-fix-federated-userid.md index eb7843cf17..109c088ff1 100644 --- a/changelog/unreleased/ocm-fix-federated-userid.md +++ b/changelog/unreleased/ocm-fix-federated-userid.md @@ -3,4 +3,5 @@ Bugfix: fix OCM userid encoding We now base64 encode the remote userid and provider as the local federated user id. This allows us to always differentiate them from local users and unpack the encoded user id and provider when making requests to the remote ocm provider. https://github.com/cs3org/reva/pull/4833 +https://github.com/cs3org/reva/pull/4837 https://github.com/owncloud/ocis/issues/9927 diff --git a/pkg/ocm/provider/authorizer/json/json.go b/pkg/ocm/provider/authorizer/json/json.go index a47ef6b778..fc3eb0c891 100644 --- a/pkg/ocm/provider/authorizer/json/json.go +++ b/pkg/ocm/provider/authorizer/json/json.go @@ -104,7 +104,7 @@ func normalizeDomain(d string) (string, error) { return "", err } - return u.Hostname(), nil + return u.Host, nil } func (a *authorizer) GetInfoByDomain(_ context.Context, domain string) (*ocmprovider.ProviderInfo, error) { diff --git a/pkg/ocm/provider/authorizer/json/json_test.go b/pkg/ocm/provider/authorizer/json/json_test.go index 04c9f5b290..52c525733b 100644 --- a/pkg/ocm/provider/authorizer/json/json_test.go +++ b/pkg/ocm/provider/authorizer/json/json_test.go @@ -24,9 +24,10 @@ func TestAuthorizer_GetInfoByDomain(t *testing.T) { expectedDomain string expectedError error }{ - "domain only": {givenDomain: "server-one:9200", expectedDomain: "server-one"}, - "domain with port": {givenDomain: "server-two:9200", expectedDomain: "server-two:9200"}, - "unknown domain": {givenDomain: "unknown-domain", expectedError: errtypes.NotFound("unknown-domain")}, + "domain only": {givenDomain: "server-one", expectedDomain: "server-one"}, + "domain with port": {givenDomain: "server-two:9200", expectedDomain: "server-two:9200"}, + "domain only with port in result": {givenDomain: "server-two", expectedDomain: "server-two:9200"}, + "unknown domain": {givenDomain: "unknown-domain", expectedError: errtypes.NotFound("unknown-domain")}, } { t.Run(name, func(t *testing.T) { info, err := authorizer.GetInfoByDomain(context.Background(), env.givenDomain) From f4fefc3a7c314fb6e89c3cfb8f48c0582dd15f34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Thu, 5 Sep 2024 14:54:35 +0200 Subject: [PATCH 2/2] fix changelog order --- changelog/unreleased/ocm-fix-federated-userid.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog/unreleased/ocm-fix-federated-userid.md b/changelog/unreleased/ocm-fix-federated-userid.md index 109c088ff1..4fa2dd3efb 100644 --- a/changelog/unreleased/ocm-fix-federated-userid.md +++ b/changelog/unreleased/ocm-fix-federated-userid.md @@ -2,6 +2,6 @@ Bugfix: fix OCM userid encoding We now base64 encode the remote userid and provider as the local federated user id. This allows us to always differentiate them from local users and unpack the encoded user id and provider when making requests to the remote ocm provider. -https://github.com/cs3org/reva/pull/4833 https://github.com/cs3org/reva/pull/4837 +https://github.com/cs3org/reva/pull/4833 https://github.com/owncloud/ocis/issues/9927