Skip to content

Commit

Permalink
impement deleterawkeys
Browse files Browse the repository at this point in the history
  • Loading branch information
kofoworola committed Aug 14, 2024
1 parent 2029cdb commit afe8c40
Showing 1 changed file with 4 additions and 21 deletions.
25 changes: 4 additions & 21 deletions gateway/auth_manager.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
package gateway

import (
"context"
"encoding/base64"
"encoding/json"
"strings"
"time"

"github.com/sirupsen/logrus"

"github.com/TykTechnologies/tyk/internal/redis"
"github.com/TykTechnologies/tyk/internal/uuid"
"github.com/TykTechnologies/tyk/storage"
"github.com/TykTechnologies/tyk/user"
Expand Down Expand Up @@ -78,27 +76,12 @@ func (b *DefaultSessionManager) ResetQuota(keyName string, session *user.Session
// Clear the rate limiter and
// Fix the raw key
keys := []string{rateLimiterSentinelKey, rawKey}
keys = rawKeysWithAllowanceScope(keyName, session, keys)
type clientProvider interface {
Client() (redis.UniversalClient, error)
}

clientFactory, ok := b.store.(clientProvider)
if !ok {
return
}

client, err := clientFactory.Client()
if err != nil {
log.WithError(err).Error("Error getting client in ResetQuota")
return
}

ctx := context.TODO()
client.Del(ctx, keys...)
keys = append(keys, rawKeysWithAllowanceScope(keyName, session)...)
b.store.DeleteRawKeys(keys)
}

func rawKeysWithAllowanceScope(keyName string, session *user.SessionState, keys []string) []string {
func rawKeysWithAllowanceScope(keyName string, session *user.SessionState) []string {
keys := make([]string, 0)
for _, acl := range session.AccessRights {
if acl.AllowanceScope == "" {
continue
Expand Down

0 comments on commit afe8c40

Please sign in to comment.