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

bug: fix the false alarm of verification with jwt.WithJSONNumber #305

Merged
merged 1 commit into from
Dec 1, 2022
Merged

bug: fix the false alarm of verification with jwt.WithJSONNumber #305

merged 1 commit into from
Dec 1, 2022

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