Documentation ¶
Index ¶
- func BlacklistToken(token []byte, expireAt int64) error
- func ClearAllTokens() (int64, error)
- func IsBlacklisted(token []byte) (bool, error)
- func RequireTokenAuthentication(w http.ResponseWriter, req *http.Request, next http.HandlerFunc)
- func ValidateTokenAuthentication(w http.ResponseWriter, req *http.Request, next http.HandlerFunc)
- type JwtAuthBackend
- func (authBackend *JwtAuthBackend) Authenticate(u *user.User) bool
- func (authBackend *JwtAuthBackend) GenerateToken(u *user.User) (string, error)
- func (authBackend *JwtAuthBackend) IsTerminated(tokenstr string) bool
- func (authBackend *JwtAuthBackend) TerminateToken(tokenstr string, token *jwt.Token) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BlacklistToken ¶
BlacklistToken adds the token to a ledis database
func ClearAllTokens ¶
func IsBlacklisted ¶
IsBlackListed checks if a token is in the blacklist list
func RequireTokenAuthentication ¶
func RequireTokenAuthentication(w http.ResponseWriter, req *http.Request, next http.HandlerFunc)
func ValidateTokenAuthentication ¶
func ValidateTokenAuthentication(w http.ResponseWriter, req *http.Request, next http.HandlerFunc)
Types ¶
type JwtAuthBackend ¶
func InitJwtAuthBackend ¶
func InitJwtAuthBackend() (*JwtAuthBackend, error)
InitJwtAuthBackend instantiate a thread-safe JwtAuthBackend instance if it has not been started.
func (*JwtAuthBackend) Authenticate ¶
func (authBackend *JwtAuthBackend) Authenticate(u *user.User) bool
Authenticate authenticate the provided user login credentials
func (*JwtAuthBackend) GenerateToken ¶
func (authBackend *JwtAuthBackend) GenerateToken(u *user.User) (string, error)
GenerateToken creates an encrypted token including the user's ID using signing method RS512 and the public/private key
func (*JwtAuthBackend) IsTerminated ¶
func (authBackend *JwtAuthBackend) IsTerminated(tokenstr string) bool
IsTerminated check if the token has been terminated before its expiration
func (*JwtAuthBackend) TerminateToken ¶
func (authBackend *JwtAuthBackend) TerminateToken(tokenstr string, token *jwt.Token) error
TerminateToken invalidates the token before its expiration time. This function is invoked when the user logged out.
Click to show internal directories.
Click to hide internal directories.