Skip to content

Commit

Permalink
Cache failed OrgKey expiration attempts (TykTechnologies#2185)
Browse files Browse the repository at this point in the history
At the moment it expects that OrgKey is exists, and if not, it asks for an Org key on every request.

Fix TykTechnologies#2184
  • Loading branch information
buger authored Mar 29, 2019
1 parent dede565 commit 6320420
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 2 additions & 0 deletions middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@ func (t BaseMiddleware) OrgSessionExpiry(orgid string) int64 {
t.Logger().Debug("Checking: ", orgid)
cachedVal, found := ExpiryCache.Get(orgid)
if !found {
// Cache failed attempt
t.SetOrgExpiry(orgid, 604800)
go t.OrgSession(orgid)
t.Logger().Debug("no cached entry found, returning 7 days")
return 604800
Expand Down
3 changes: 0 additions & 3 deletions signature_validator/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ func (v *SignatureValidator) Init(hasherName string) error {

func (v SignatureValidator) Validate(signature, key, secret string, allowedClockSkew int64) error {
signatureBytes, _ := hex.DecodeString(signature)

fmt.Println("Validating:", signature, key, secret)

now := time.Now().Unix()
for i := int64(0); i <= allowedClockSkew; i++ {
if bytes.Equal(v.h.Hash(key, secret, now+i), signatureBytes) {
Expand Down

0 comments on commit 6320420

Please sign in to comment.