Skip to content

Commit dc4ed94

Browse files
authored
fix(proxy): cache auth key with sandbox id (#2355)
Signed-off-by: Toma Puljak <[email protected]>
1 parent 07e5c79 commit dc4ed94

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

apps/proxy/pkg/proxy/get_target.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,13 +138,14 @@ func (p *Proxy) getSandboxPublic(ctx context.Context, sandboxId string) (*bool,
138138
}
139139

140140
func (p *Proxy) getSandboxAuthKeyValid(ctx context.Context, sandboxId string, authKey string) (*bool, error) {
141-
has, err := p.sandboxAuthKeyValidCache.Has(ctx, authKey)
141+
cacheKey := fmt.Sprintf("%s:%s", sandboxId, authKey)
142+
has, err := p.sandboxAuthKeyValidCache.Has(ctx, cacheKey)
142143
if err != nil {
143144
return nil, err
144145
}
145146

146147
if has {
147-
return p.sandboxAuthKeyValidCache.Get(ctx, authKey)
148+
return p.sandboxAuthKeyValidCache.Get(ctx, cacheKey)
148149
}
149150

150151
isValid := false
@@ -153,7 +154,7 @@ func (p *Proxy) getSandboxAuthKeyValid(ctx context.Context, sandboxId string, au
153154
isValid = true
154155
}
155156

156-
err = p.sandboxAuthKeyValidCache.Set(ctx, authKey, isValid, 2*time.Minute)
157+
err = p.sandboxAuthKeyValidCache.Set(ctx, cacheKey, isValid, 2*time.Minute)
157158
if err != nil {
158159
log.Errorf("Failed to set sandbox auth key valid in cache: %v", err)
159160
}

0 commit comments

Comments
 (0)