added empty token check and copyright
This commit is contained in:
parent
40e1f1bf58
commit
339d6de8bd
4 changed files with 15 additions and 1 deletions
6
jwt.go
6
jwt.go
|
|
@ -1,3 +1,5 @@
|
|||
// Copyright (C) 2018 Marius Schellenberger
|
||||
|
||||
// Package jwt provides a easy to use JSON Web Token and blacklisting library
|
||||
package jwt
|
||||
|
||||
|
|
@ -24,6 +26,7 @@ const (
|
|||
|
||||
var (
|
||||
ErrNoJWT = errors.New("not a json web token")
|
||||
ErrEmptyToken = errors.New("token is empty")
|
||||
ErrUnsupportedAlg = errors.New("unsupported algorithm")
|
||||
ErrInvalid = errors.New("token validation failed")
|
||||
ErrBlacklisted = errors.New("token blacklisted")
|
||||
|
|
@ -274,6 +277,9 @@ func (jwt *JWT) Stop() error {
|
|||
|
||||
// DecodeToken decodes a raw string token into a *Token object
|
||||
func DecodeToken(token string) (t *Token, err error) {
|
||||
if token == "" {
|
||||
return nil, ErrEmptyToken
|
||||
}
|
||||
parts := strings.Split(token, ".")
|
||||
if len(parts) < 3 {
|
||||
return nil, ErrMissingTokenParts
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue