Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MG-7 - Fix: Nil error returned in case of token type missing #17

Merged
merged 1 commit into from
Dec 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
)

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 @@

tType, ok := tkn.Get(tokenType)
if !ok {
return auth.Key{}, err
return auth.Key{}, errInvalidType

Check warning on line 133 in auth/jwt/tokenizer.go

View check run for this annotation

Codecov / codecov/patch

auth/jwt/tokenizer.go#L133

Added line #L133 was not covered by tests
}
ktype, err := strconv.ParseInt(fmt.Sprintf("%v", tType), 10, 64)
if err != nil {
Expand Down
Loading