Skip to content

Commit

Permalink
var renamed
Browse files Browse the repository at this point in the history
  • Loading branch information
kpacha committed Sep 5, 2024
1 parent c0b7eda commit 945260d
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion jose.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func NewValidator(signatureConfig *SignatureConfig, cookieEf, headerEf Extractor
SecretURL: signatureConfig.SecretURL,
CipherKey: signatureConfig.CipherKey,
KeyIdentifyStrategy: signatureConfig.KeyIdentifyStrategy,
UnknownListTTL: signatureConfig.UnknownListTTL,
UnknownKeysTTL: signatureConfig.UnknownKeysTTL,
}

sp, err := SecretProvider(cfg, te)
Expand Down
4 changes: 2 additions & 2 deletions jwk.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ type SecretProviderConfig struct {
SecretURL string
CipherKey []byte
KeyIdentifyStrategy string
UnknownListTTL string
UnknownKeysTTL string
}

var (
Expand Down Expand Up @@ -201,7 +201,7 @@ func newJWKClientOptions(cfg SecretProviderConfig) (JWKClientOptions, error) {
},
},
KeyIdentifyStrategy: cfg.KeyIdentifyStrategy,
UnknownListTTL: cfg.UnknownListTTL,
UnknownKeysTTL: cfg.UnknownKeysTTL,
}, nil
}

Expand Down
7 changes: 5 additions & 2 deletions jwk_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func TokenIDGetterFactory(keyIdentifyStrategy string) TokenIDGetter {
type JWKClientOptions struct {
auth0.JWKClientOptions
KeyIdentifyStrategy string
UnknownListTTL string
UnknownKeysTTL string
}

type JWKClient struct {
Expand All @@ -81,7 +81,7 @@ func NewJWKClientWithCache(options JWKClientOptions, extractor auth0.RequestToke
misses: noTracker,
}

if ttl, err := time.ParseDuration(options.UnknownListTTL); err == nil && ttl >= time.Second {
if ttl, err := time.ParseDuration(options.UnknownKeysTTL); err == nil && ttl >= time.Second {
c.misses = &memoryMissTracker{
keys: []unknownKey{},
mu: new(sync.Mutex),
Expand Down Expand Up @@ -154,6 +154,8 @@ type unknownKey struct {
time time.Time
}

// Exists looks for the key in the list and removes all evicted entries found before the required one. If the required is evicted,
// it removes it and returns false, so the client can try to fetch it again.
func (u *memoryMissTracker) Exists(key string) bool {
u.mu.Lock()
defer u.mu.Unlock()
Expand Down Expand Up @@ -186,6 +188,7 @@ func (u *memoryMissTracker) Exists(key string) bool {
return found
}

// Add appends a key and a timestamp to the end of the list of keys
func (u *memoryMissTracker) Add(key string) {
u.mu.Lock()
u.keys = append(u.keys, unknownKey{name: key, time: time.Now()})
Expand Down
2 changes: 1 addition & 1 deletion jws.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ type SignatureConfig struct {
KeyIdentifyStrategy string `json:"key_identify_strategy"`
OperationDebug bool `json:"operation_debug,omitempty"`
Leeway string `json:"leeway"`
UnknownListTTL string `json:"unknown_list_ttl"`
UnknownKeysTTL string `json:"unknown_keys_throttle_ttl"`
}

type SignerConfig struct {
Expand Down

0 comments on commit 945260d

Please sign in to comment.