Skip to content

Commit 4e1f750

Browse files
larsvealdas
authored andcommitted
Fix data race in Config.ToMiddleware.func2.1()
Fixes a data race in ToMiddleware() by creating a new instance of the err variable in the returned function.
1 parent 1f68bd7 commit 4e1f750

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

jwt.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ package echojwt
66
import (
77
"errors"
88
"fmt"
9+
"net/http"
10+
911
"github.com/golang-jwt/jwt/v4"
1012
"github.com/labstack/echo/v4"
1113
"github.com/labstack/echo/v4/middleware"
12-
"net/http"
1314
)
1415

1516
// Config defines the config for JWT middleware.
@@ -224,7 +225,7 @@ func (config Config) ToMiddleware() (echo.MiddlewareFunc, error) {
224225
}
225226

226227
// prioritize token errors over extracting errors
227-
err = lastTokenErr
228+
err := lastTokenErr
228229
if err == nil {
229230
err = lastExtractorErr
230231
}

0 commit comments

Comments
 (0)