Skip to content

Commit fe9caac

Browse files
authored
Merge pull request #5033 from kobergj/FixOCMWildcards
Fix Wildcards in ocm domains
2 parents f80ba18 + 2dbf829 commit fe9caac

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

changelog/unreleased/fix-wildcards.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Bugfix: Fix ocm wildcards
2+
3+
ocm wildcards were not working properly. We now overwrite the wildcard values with the actual domain.
4+
5+
https://github.com/cs3org/reva/pull/5033

pkg/ocm/provider/authorizer/json/json.go

+13
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,22 @@ func (a *authorizer) GetInfoByDomain(_ context.Context, domain string) (*ocmprov
114114
return nil, err
115115
}
116116
for _, p := range a.providers {
117+
// we can exit early if this an exact match
117118
if strings.Contains(p.Domain, normalizedDomain) {
118119
return p, nil
119120
}
121+
122+
// check if the domain matches a regex
123+
if ok, err := regexp.MatchString(p.Domain, normalizedDomain); ok && err == nil {
124+
// overwrite wildcards with the actual domain
125+
for i, s := range p.Services {
126+
s.Endpoint.Path = strings.ReplaceAll(s.Endpoint.Path, p.Domain, normalizedDomain)
127+
s.Host = strings.ReplaceAll(s.Host, p.Domain, normalizedDomain)
128+
p.Services[i] = s
129+
}
130+
p.Domain = normalizedDomain
131+
return p, nil
132+
}
120133
}
121134
return nil, errtypes.NotFound(domain)
122135
}

0 commit comments

Comments
 (0)