Skip to content

Commit

Permalink
fix(ocm): fix wildcards in ocm domains
Browse files Browse the repository at this point in the history
Signed-off-by: jkoberg <jkoberg@owncloud.com>
  • Loading branch information
kobergj committed Jan 9, 2025
1 parent 2f48e2c commit 2dbf829
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
5 changes: 5 additions & 0 deletions changelog/unreleased/fix-wildcards.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Bugfix: Fix ocm wildcards

ocm wildcards were not working properly. We now overwrite the wildcard values with the actual domain.

https://github.com/cs3org/reva/pull/5033
13 changes: 13 additions & 0 deletions pkg/ocm/provider/authorizer/json/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,22 @@ func (a *authorizer) GetInfoByDomain(_ context.Context, domain string) (*ocmprov
return nil, err
}
for _, p := range a.providers {
// we can exit early if this an exact match
if strings.Contains(p.Domain, normalizedDomain) {
return p, nil
}

// check if the domain matches a regex
if ok, err := regexp.MatchString(p.Domain, normalizedDomain); ok && err == nil {
// overwrite wildcards with the actual domain
for i, s := range p.Services {
s.Endpoint.Path = strings.ReplaceAll(s.Endpoint.Path, p.Domain, normalizedDomain)
s.Host = strings.ReplaceAll(s.Host, p.Domain, normalizedDomain)
p.Services[i] = s
}
p.Domain = normalizedDomain
return p, nil
}
}
return nil, errtypes.NotFound(domain)
}
Expand Down

0 comments on commit 2dbf829

Please sign in to comment.