Skip to content

Commit 7ea841f

Browse files
committed
fix(ocm): fix wildcards in ocm domains
Signed-off-by: jkoberg <[email protected]>
1 parent 2f48e2c commit 7ea841f

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
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-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,19 @@ func (a *authorizer) GetInfoByDomain(_ context.Context, domain string) (*ocmprov
114114
return nil, err
115115
}
116116
for _, p := range a.providers {
117-
if strings.Contains(p.Domain, normalizedDomain) {
117+
if ok, err := regexp.MatchString(p.Domain, normalizedDomain); ok && err == nil {
118+
// do not overwrite values if this was a full match
119+
if p.Domain == normalizedDomain {
120+
return p, nil
121+
}
122+
123+
// overwrite wildcards with the actual domain
124+
for i, s := range p.Services {
125+
s.Endpoint.Path = strings.ReplaceAll(s.Endpoint.Path, p.Domain, normalizedDomain)
126+
s.Host = strings.ReplaceAll(s.Host, p.Domain, normalizedDomain)
127+
p.Services[i] = s
128+
}
129+
p.Domain = normalizedDomain
118130
return p, nil
119131
}
120132
}

0 commit comments

Comments
 (0)