Skip to content

Commit

Permalink
OCM: Fix open driver (#4790)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
MahdiBaghbani authored Aug 5, 2024
1 parent dde65a4 commit e636e4f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
8 changes: 8 additions & 0 deletions changelog/unreleased/fix-ocm-open-driver.md
Original file line number Diff line number Diff line change
@@ -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
9 changes: 8 additions & 1 deletion pkg/ocm/provider/authorizer/open/open.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down

0 comments on commit e636e4f

Please sign in to comment.