MCPcopy
hub / github.com/tinyauthapp/tinyauth / ensureOAuthSessionLimit

Method ensureOAuthSessionLimit

internal/service/auth_service.go:754–788  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

752}
753
754func (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
790func (auth *AuthService) lockdownMode() {
791 ctx, cancel := context.WithCancel(context.Background())

Callers 2

NewOAuthSessionMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected