Upgrade to the v4 release of golang-jwt#2122
Closed
abscondment wants to merge 1 commit intolabstack:masterfrom
Closed
Upgrade to the v4 release of golang-jwt#2122abscondment wants to merge 1 commit intolabstack:masterfrom
abscondment wants to merge 1 commit intolabstack:masterfrom
Conversation
According to the [4.0.0 Version History](https://github.com/golang-jwt/jwt/blob/main/VERSION_HISTORY.md#400), the v4 version is backwards compatible with v3.x
Contributor
|
This would be breaking change. This will come with Changing to import (
"github.com/golang-jwt/jwt/v4"
)
...
...
...
signingKey := []byte("secret")
config := middleware.JWTConfig{
TokenLookup: "query:token",
ParseTokenFunc: func(auth string, c echo.Context) (interface{}, error) {
keyFunc := func(t *jwt.Token) (interface{}, error) {
if t.Method.Alg() != "HS256" {
return nil, fmt.Errorf("unexpected jwt signing method=%v", t.Header["alg"])
}
return signingKey, nil
}
// claims are of type `jwt.MapClaims` when token is created with `jwt.Parse`
token, err := jwt.Parse(auth, keyFunc)
if err != nil {
return nil, err
}
if !token.Valid {
return nil, errors.New("invalid token")
}
return token, nil
},
}
e.Use(middleware.JWTWithConfig(config)) |
Author
|
Makes sense, @aldas - thanks for the response. I thought I'd done a thorough search for this change in closed PRs, but I guess I missed it! We can wait for v5 :) |
Closed
This was referenced Oct 31, 2022
Merged
Contributor
|
For history sake. Release |
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
There have been a bunch of improvements to the jwt dependency.
According to the golang-jwt/jwt Releases, "any future
/v4work is intended to be backwards-compatible with existing v3.x.y tags."This appears to be true; all tests pass for recent versions.
I noted that
make test_versionfail for go1.9.7 and go1.10.3 on themasterbranch, so I omitted them from my testing: