Skip to content

Commit 647af2a

Browse files
committed
JWT middleware has been changed from github.com/dgrijalva/jwt-go to github.com/golang-jwt/jwt` due former library being unmaintained and having security
issues. NOTE: `golang-jwt/jwt` now only supports last 2 Go releases. So 1.15+ For detailed information please read #1940
1 parent 58366f9 commit 647af2a

File tree

4 files changed

+11
-7
lines changed

4 files changed

+11
-7
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module github.com/labstack/echo/v4
33
go 1.15
44

55
require (
6-
github.com/dgrijalva/jwt-go v3.2.0+incompatible
6+
github.com/golang-jwt/jwt v3.2.2+incompatible
77
github.com/labstack/gommon v0.3.0
88
github.com/mattn/go-colorable v0.1.8 // indirect
99
github.com/stretchr/testify v1.4.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
22
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
3-
github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM=
4-
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
3+
github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY=
4+
github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I=
55
github.com/labstack/gommon v0.3.0 h1:JEeO0bvc78PKdyHxloTKiF8BD5iGrH8T6MSeGvSgob0=
66
github.com/labstack/gommon v0.3.0/go.mod h1:MULnywXg0yavhxWKc+lOruYdAhDwPK9wf0OL7NoOu+k=
77
github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=

middleware/jwt.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// +build go1.15
2+
13
package middleware
24

35
import (
@@ -7,7 +9,7 @@ import (
79
"reflect"
810
"strings"
911

10-
"github.com/dgrijalva/jwt-go"
12+
"github.com/golang-jwt/jwt"
1113
"github.com/labstack/echo/v4"
1214
)
1315

@@ -88,7 +90,7 @@ type (
8890

8991
// ParseTokenFunc defines a user-defined function that parses token from given auth. Returns an error when token
9092
// parsing fails or parsed token is invalid.
91-
// Defaults to implementation using `github.com/dgrijalva/jwt-go` as JWT implementation library
93+
// Defaults to implementation using `github.com/golang-jwt/jwt` as JWT implementation library
9294
ParseTokenFunc func(auth string, c echo.Context) (interface{}, error)
9395
}
9496

middleware/jwt_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// +build go1.15
2+
13
package middleware
24

35
import (
@@ -9,7 +11,7 @@ import (
911
"strings"
1012
"testing"
1113

12-
"github.com/dgrijalva/jwt-go"
14+
"github.com/golang-jwt/jwt"
1315
"github.com/labstack/echo/v4"
1416
"github.com/stretchr/testify/assert"
1517
)
@@ -562,7 +564,7 @@ func TestJWTConfig_custom_ParseTokenFunc_Keyfunc(t *testing.T) {
562564
return c.String(http.StatusTeapot, "test")
563565
})
564566

565-
// example of minimal custom ParseTokenFunc implementation. Allows you to use different versions of `github.com/dgrijalva/jwt-go`
567+
// example of minimal custom ParseTokenFunc implementation. Allows you to use different versions of `github.com/golang-jwt/jwt`
566568
// with current JWT middleware
567569
signingKey := []byte("secret")
568570

0 commit comments

Comments
 (0)