@@ -76,24 +76,25 @@ func newClientCache() *clientCache {
76
76
}
77
77
78
78
type cacheKey struct {
79
+ clusterAddress string
79
80
// Canonical issuer URL string of the provider.
80
81
issuerURL string
81
82
clientID string
82
83
}
83
84
84
- func (c * clientCache ) getClient (issuer , clientID string ) (* oidcAuthProvider , bool ) {
85
+ func (c * clientCache ) getClient (clusterAddress , issuer , clientID string ) (* oidcAuthProvider , bool ) {
85
86
c .mu .RLock ()
86
87
defer c .mu .RUnlock ()
87
- client , ok := c .cache [cacheKey {issuer , clientID }]
88
+ client , ok := c .cache [cacheKey {clusterAddress : clusterAddress , issuerURL : issuer , clientID : clientID }]
88
89
return client , ok
89
90
}
90
91
91
92
// setClient attempts to put the client in the cache but may return any clients
92
93
// with the same keys set before. This is so there's only ever one client for a provider.
93
- func (c * clientCache ) setClient (issuer , clientID string , client * oidcAuthProvider ) * oidcAuthProvider {
94
+ func (c * clientCache ) setClient (clusterAddress , issuer , clientID string , client * oidcAuthProvider ) * oidcAuthProvider {
94
95
c .mu .Lock ()
95
96
defer c .mu .Unlock ()
96
- key := cacheKey {issuer , clientID }
97
+ key := cacheKey {clusterAddress : clusterAddress , issuerURL : issuer , clientID : clientID }
97
98
98
99
// If another client has already initialized a client for the given provider we want
99
100
// to use that client instead of the one we're trying to set. This is so all transports
@@ -107,7 +108,7 @@ func (c *clientCache) setClient(issuer, clientID string, client *oidcAuthProvide
107
108
return client
108
109
}
109
110
110
- func newOIDCAuthProvider (_ string , cfg map [string ]string , persister restclient.AuthProviderConfigPersister ) (restclient.AuthProvider , error ) {
111
+ func newOIDCAuthProvider (clusterAddress string , cfg map [string ]string , persister restclient.AuthProviderConfigPersister ) (restclient.AuthProvider , error ) {
111
112
issuer := cfg [cfgIssuerUrl ]
112
113
if issuer == "" {
113
114
return nil , fmt .Errorf ("Must provide %s" , cfgIssuerUrl )
@@ -119,7 +120,7 @@ func newOIDCAuthProvider(_ string, cfg map[string]string, persister restclient.A
119
120
}
120
121
121
122
// Check cache for existing provider.
122
- if provider , ok := cache .getClient (issuer , clientID ); ok {
123
+ if provider , ok := cache .getClient (clusterAddress , issuer , clientID ); ok {
123
124
return provider , nil
124
125
}
125
126
@@ -157,7 +158,7 @@ func newOIDCAuthProvider(_ string, cfg map[string]string, persister restclient.A
157
158
persister : persister ,
158
159
}
159
160
160
- return cache .setClient (issuer , clientID , provider ), nil
161
+ return cache .setClient (clusterAddress , issuer , clientID , provider ), nil
161
162
}
162
163
163
164
type oidcAuthProvider struct {
0 commit comments