Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions storage/memory.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,9 @@ func (s *MemoryStore) GetClient(_ context.Context, id string) (fosite.Client, er
}

func (s *MemoryStore) SetTokenLifespans(clientID string, lifespans *fosite.ClientLifespanConfig) error {
s.clientsMutex.RLock()
defer s.clientsMutex.RUnlock()

if client, ok := s.Clients[clientID]; ok {
if clc, ok := client.(*fosite.DefaultClientWithCustomTokenLifespans); ok {
clc.SetTokenLifespans(lifespans)
Expand Down Expand Up @@ -388,8 +391,12 @@ func (s *MemoryStore) Authenticate(_ context.Context, name string, secret string
}

func (s *MemoryStore) RevokeRefreshToken(ctx context.Context, requestID string) error {
// We first lock refreshTokenRequestIDsMutex and then refreshTokensMutex because this is the same order
// locking happens in CreateRefreshTokenSession and using the same order prevents deadlocks.
s.refreshTokenRequestIDsMutex.Lock()
defer s.refreshTokenRequestIDsMutex.Unlock()
s.refreshTokensMutex.Lock()
defer s.refreshTokensMutex.Unlock()

if signature, exists := s.RefreshTokenRequestIDs[requestID]; exists {
rel, ok := s.RefreshTokens[signature]
Expand Down Expand Up @@ -547,8 +554,6 @@ func (s *MemoryStore) GetDeviceCodeSession(_ context.Context, signature string,

// InvalidateDeviceCodeSession invalidates the device code session
func (s *MemoryStore) InvalidateDeviceCodeSession(_ context.Context, code string) error {
s.deviceAuthsRequestIDsMutex.Lock()
defer s.deviceAuthsRequestIDsMutex.Unlock()
s.deviceAuthsMutex.Lock()
defer s.deviceAuthsMutex.Unlock()

Expand Down