Skip to content

Conversation

panjf2000
Copy link
Contributor

The current implementation doesn't handle jwt.WithJSONNumber() parse option well, if you set this option and try to parse a JWT, it always fails type conversion here:

gin-jwt/auth_jwt.go

Lines 430 to 433 in 6b68cb3

if _, ok := claims["exp"].(float64); !ok {
mw.unauthorized(c, http.StatusBadRequest, mw.HTTPStatusMessageFunc(ErrWrongFormatOfExp, c))
return
}

We should also take care of the type json.Number and avoid the false alarm, this is also what https://github.com/golang-jwt/jwt/blob/main/map_claims.go#L40-L56 does.

@panjf2000
Copy link
Contributor Author

cc @appleboy

@panjf2000
Copy link
Contributor Author

any comments on this?
@appleboy

@appleboy appleboy added the bug label Dec 1, 2022
@appleboy
Copy link
Owner

appleboy commented Dec 1, 2022

LGTM @panjf2000 Thanks.

@appleboy appleboy merged commit b3c8050 into appleboy:master Dec 1, 2022
@appleboy
Copy link
Owner

appleboy commented Dec 1, 2022

@panjf2000 sorry for the late response.

@panjf2000 panjf2000 deleted the fix-json-number branch December 1, 2022 03:46
@panjf2000
Copy link
Contributor Author

Could you set up a new release for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants