Skip to content

Commit

Permalink
Clarify magic number
Browse files Browse the repository at this point in the history
  • Loading branch information
buger committed May 11, 2018
1 parent 859e3fb commit cb3da3d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,13 @@ func (t BaseMiddleware) ApplyPolicies(key string, session *user.SessionState) er
// CheckSessionAndIdentityForValidKey will check first the Session store for a valid key, if not found, it will try
// the Auth Handler, if not found it will fail
func (t BaseMiddleware) CheckSessionAndIdentityForValidKey(key string) (user.SessionState, bool) {
if len(key) <= t.Spec.GlobalConfig.MinTokenLength || len(key) <= 3 {
minLength := t.Spec.GlobalConfig.MinTokenLength
if minLength == 0 {
// See https://github.com/TykTechnologies/tyk/issues/1681
minLength = 3
}

if len(key) <= minLength {
return user.SessionState{IsInactive: true}, false
}

Expand Down

0 comments on commit cb3da3d

Please sign in to comment.