MG-7 - Return an error in case of missing token type (#17)

Signed-off-by: Dusan Borovcanin <borovcanindusan1@gmail.com>
This commit is contained in:
Dušan Borovčanin
2024-12-25 23:44:30 +01:00
committed by GitHub
parent 3e70b71142
commit af072b0b37
+4 -1
View File
@@ -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.
@@ -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 {