Skip to content

Commit

Permalink
Merge pull request #5033 from kobergj/FixOCMWildcards
Browse files Browse the repository at this point in the history
Fix Wildcards in ocm domains
  • Loading branch information
kobergj authored Jan 9, 2025
2 parents f80ba18 + 2dbf829 commit fe9caac
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 fe9caac

Please sign in to comment.