()
| 752 | } |
| 753 | |
| 754 | func (auth *AuthService) ensureOAuthSessionLimit() { |
| 755 | auth.oauthMutex.Lock() |
| 756 | defer auth.oauthMutex.Unlock() |
| 757 | |
| 758 | if len(auth.oauthPendingSessions) >= MaxOAuthPendingSessions { |
| 759 | |
| 760 | cleanupIds := make([]string, 0, OAuthCleanupCount) |
| 761 | |
| 762 | for range OAuthCleanupCount { |
| 763 | oldestId := "" |
| 764 | oldestTime := int64(0) |
| 765 | |
| 766 | for id, session := range auth.oauthPendingSessions { |
| 767 | if oldestTime == 0 { |
| 768 | oldestId = id |
| 769 | oldestTime = session.ExpiresAt.Unix() |
| 770 | continue |
| 771 | } |
| 772 | if slices.Contains(cleanupIds, id) { |
| 773 | continue |
| 774 | } |
| 775 | if session.ExpiresAt.Unix() < oldestTime { |
| 776 | oldestId = id |
| 777 | oldestTime = session.ExpiresAt.Unix() |
| 778 | } |
| 779 | } |
| 780 | |
| 781 | cleanupIds = append(cleanupIds, oldestId) |
| 782 | } |
| 783 | |
| 784 | for _, id := range cleanupIds { |
| 785 | delete(auth.oauthPendingSessions, id) |
| 786 | } |
| 787 | } |
| 788 | } |
| 789 | |
| 790 | func (auth *AuthService) lockdownMode() { |
| 791 | ctx, cancel := context.WithCancel(context.Background()) |
no outgoing calls
no test coverage detected