Ensure JWT not empty
This commit is contained in:
parent
86abb0b618
commit
3038750206
3 changed files with 22 additions and 2 deletions
|
@ -34,6 +34,10 @@ type RefreshToken struct {
|
|||
Version *string `json:"version"`
|
||||
}
|
||||
|
||||
func (rt *RefreshToken) IsValid() bool {
|
||||
return rt.JWTKey != ""
|
||||
}
|
||||
|
||||
type AccessSessionStore struct {
|
||||
s map[AccessTokenID]*AccessToken
|
||||
lastCull time.Time
|
||||
|
|
|
@ -69,6 +69,22 @@ func (a *Authenticator) newAuthStore(s storage.Store) (as *authStore, err error)
|
|||
}
|
||||
}
|
||||
|
||||
// remove invalid RefreshTokens
|
||||
i := 0
|
||||
for _, rt := range as.Refresh {
|
||||
if rt.IsValid() {
|
||||
as.Refresh[i] = rt
|
||||
i++
|
||||
}
|
||||
}
|
||||
|
||||
// don't leak memory
|
||||
for j := i; j < len(as.Refresh); j++ {
|
||||
as.Refresh[j] = RefreshToken{}
|
||||
}
|
||||
|
||||
as.Refresh = as.Refresh[:i]
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ type (
|
|||
}
|
||||
|
||||
Handler interface {
|
||||
Base() FlowHandler
|
||||
BaseHandler() FlowHandler
|
||||
FlowID() FlowID
|
||||
|
||||
flowCtime() time.Time
|
||||
|
@ -105,7 +105,7 @@ type FlowHandler struct {
|
|||
|
||||
func (f *FlowHandler) Step() Step { return f.curStep }
|
||||
|
||||
func (f *FlowHandler) Base() FlowHandler { return *f }
|
||||
func (f *FlowHandler) BaseHandler() FlowHandler { return *f }
|
||||
|
||||
func (f *FlowHandler) FlowID() FlowID {
|
||||
return f.ID
|
||||
|
|
Loading…
Reference in a new issue