mirror of
https://github.com/zitadel/zitadel.git
synced 2025-06-13 04:28:33 +00:00
fix: race condition in system jwt signature check (#8618)
This commit is contained in:
parent
289378713e
commit
14383cfe8c
@ -76,7 +76,7 @@ func (s *SystemTokenVerifierFromConfig) VerifySystemToken(ctx context.Context, t
|
|||||||
|
|
||||||
type systemJWTStorage struct {
|
type systemJWTStorage struct {
|
||||||
keys map[string]*SystemAPIUser
|
keys map[string]*SystemAPIUser
|
||||||
mutex sync.Mutex
|
mutex sync.RWMutex
|
||||||
cachedKeys map[string]*rsa.PublicKey
|
cachedKeys map[string]*rsa.PublicKey
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,7 +98,9 @@ func (s *SystemAPIUser) readKey() (*rsa.PublicKey, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *systemJWTStorage) GetKeyByIDAndClientID(_ context.Context, _, userID string) (*jose.JSONWebKey, error) {
|
func (s *systemJWTStorage) GetKeyByIDAndClientID(_ context.Context, _, userID string) (*jose.JSONWebKey, error) {
|
||||||
|
s.mutex.RLock()
|
||||||
cachedKey, ok := s.cachedKeys[userID]
|
cachedKey, ok := s.cachedKeys[userID]
|
||||||
|
s.mutex.RUnlock()
|
||||||
if ok {
|
if ok {
|
||||||
return &jose.JSONWebKey{KeyID: userID, Key: cachedKey}, nil
|
return &jose.JSONWebKey{KeyID: userID, Key: cachedKey}, nil
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user