From c324fb4ac0f075f8cf7ce5c9c45b64e33d1b34cd Mon Sep 17 00:00:00 2001 From: Mahdi Baghbani Date: Mon, 5 Aug 2024 11:03:21 +0330 Subject: [PATCH] OCM: Fix open driver (#4790) * ocm: fixed domain not having a protocol scheme * changelog * changelog * fix possible bug due to uppercase and lowercase string in domain * lint: add space after // in comments * Instead of modifying domain, use a new var endpoint --- changelog/unreleased/fix-ocm-open-driver.md | 8 ++++++++ pkg/ocm/provider/authorizer/open/open.go | 9 ++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 changelog/unreleased/fix-ocm-open-driver.md diff --git a/changelog/unreleased/fix-ocm-open-driver.md b/changelog/unreleased/fix-ocm-open-driver.md new file mode 100644 index 0000000000..d8341bce25 --- /dev/null +++ b/changelog/unreleased/fix-ocm-open-driver.md @@ -0,0 +1,8 @@ +Bugfix: ocm: fixed domain not having a protocol scheme + +This PR fixes a bug in the OCM open driver that causes it to be unable to probe +OCM services at the remote server due to the domain having an unsupported +protocol scheme. in this case domain doesn't have a scheme and the changes in +this PR add a scheme to the domain before doing the probe. + +https://github.com/cs3org/reva/pull/4790 diff --git a/pkg/ocm/provider/authorizer/open/open.go b/pkg/ocm/provider/authorizer/open/open.go index d0af08efb6..bad5a6a41b 100644 --- a/pkg/ocm/provider/authorizer/open/open.go +++ b/pkg/ocm/provider/authorizer/open/open.go @@ -67,9 +67,16 @@ func (a *authorizer) GetInfoByDomain(ctx context.Context, domain string) (*ocmpr } } + var endpoint string + if !strings.HasPrefix(domain, "http://") && !strings.HasPrefix(domain, "https://") { + endpoint = "https://" + domain + } else { + endpoint = domain + } + // not yet known: try to discover the remote OCM endpoint ocmClient := client.NewClient(time.Duration(10)*time.Second, true) - ocmCaps, err := ocmClient.Discover(ctx, domain) + ocmCaps, err := ocmClient.Discover(ctx, endpoint) if err != nil { return nil, errors.Wrap(err, "error probing OCM services at remote server") }