mirror of
https://github.com/lukaszraczylo/traefikoidc.git
synced 2026-11-03 07:44:13 +00:00
fix(security): scope introspection cache keys to the middleware instance
The introspection cache used the raw token as key in a shared cache. Two instances with different providers or clients shared results. Keys now use the same instance prefix as the verified-token cache.
This commit is contained in:
@@ -54,3 +54,16 @@ func TestTokenCacheEmptyNamespaceKeepsLegacyKey(t *testing.T) {
|
||||
t.Fatal("namespace-less caches must keep sharing the legacy key")
|
||||
}
|
||||
}
|
||||
|
||||
func TestIntrospectionKeyScopedPerInstance(t *testing.T) {
|
||||
a := &TraefikOidc{tokenCache: &TokenCache{}}
|
||||
b := &TraefikOidc{tokenCache: &TokenCache{}}
|
||||
a.tokenCache.SetNamespace("p|app-a|app-a")
|
||||
b.tokenCache.SetNamespace("p|app-b|app-b")
|
||||
if a.introspectionKey("tok") == b.introspectionKey("tok") {
|
||||
t.Fatal("different instances share an introspection cache key")
|
||||
}
|
||||
if got := (&TraefikOidc{}).introspectionKey("tok"); got != "tok" {
|
||||
t.Fatalf("namespace-less key = %q, want raw token", got)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user