2020-10-17 05:40:17 +02:00
|
|
|
package jwt
|
|
|
|
|
|
|
|
import (
|
2020-10-30 21:12:16 +01:00
|
|
|
"github.com/kataras/jwt"
|
2020-10-17 05:40:17 +02:00
|
|
|
)
|
|
|
|
|
2020-10-18 20:51:25 +02:00
|
|
|
// Blocklist should hold and manage invalidated-by-server tokens.
|
|
|
|
// The `NewBlocklist` and `NewBlocklistContext` functions
|
|
|
|
// returns a memory storage of tokens,
|
|
|
|
// it is the internal "blocklist" struct.
|
|
|
|
//
|
|
|
|
// The end-developer can implement her/his own blocklist,
|
|
|
|
// e.g. a redis one to keep persistence of invalidated tokens on server restarts.
|
|
|
|
// and bind to the JWT middleware's Blocklist field.
|
|
|
|
type Blocklist interface {
|
2020-10-30 21:12:16 +01:00
|
|
|
jwt.TokenValidator
|
|
|
|
|
|
|
|
// InvalidateToken should invalidate a verified JWT token.
|
|
|
|
InvalidateToken(token []byte, expiry int64)
|
2020-10-18 20:51:25 +02:00
|
|
|
// Del should remove a token from the storage.
|
2020-10-30 21:12:16 +01:00
|
|
|
Del(token []byte)
|
2020-10-18 20:51:25 +02:00
|
|
|
// Count should return the total amount of tokens stored.
|
|
|
|
Count() int
|
|
|
|
// Has should report whether a specific token exists in the storage.
|
2020-10-30 21:12:16 +01:00
|
|
|
Has(token []byte) bool
|
2020-10-17 05:40:17 +02:00
|
|
|
}
|