Skip to content

Commit

Permalink
MG-7 - Return an error in case of missing token type (#17)
Browse files Browse the repository at this point in the history
Signed-off-by: Dusan Borovcanin <[email protected]>
  • Loading branch information
dborovcanin authored Dec 25, 2024
1 parent 3e70b71 commit af072b0
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion auth/jwt/tokenizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ import (
)

var (
// errInvalidIssuer is returned when the issuer is not magistrala.auth.
errInvalidIssuer = errors.New("invalid token issuer value")
// errInvalidType is returned when there is no type field.
errInvalidType = errors.New("invalid token type")
// errJWTExpiryKey is used to check if the token is expired.
errJWTExpiryKey = errors.New(`"exp" not satisfied`)
// ErrSignJWT indicates an error in signing jwt token.
Expand Down Expand Up @@ -127,7 +130,7 @@ func toKey(tkn jwt.Token) (auth.Key, error) {

tType, ok := tkn.Get(tokenType)
if !ok {
return auth.Key{}, err
return auth.Key{}, errInvalidType
}
ktype, err := strconv.ParseInt(fmt.Sprintf("%v", tType), 10, 64)
if err != nil {
Expand Down

0 comments on commit af072b0

Please sign in to comment.