Skip to content

Commit

Permalink
Fix data race in Config.ToMiddleware.func2.1()
Browse files Browse the repository at this point in the history
Fixes a data race in ToMiddleware() by creating a new instance of the err
variable in the returned function.
  • Loading branch information
larsve authored and aldas committed Jan 24, 2023
1 parent 1f68bd7 commit 4e1f750
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions jwt.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ package echojwt
import (
"errors"
"fmt"
"net/http"

"github.com/golang-jwt/jwt/v4"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
"net/http"
)

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

// prioritize token errors over extracting errors
err = lastTokenErr
err := lastTokenErr
if err == nil {
err = lastExtractorErr
}
Expand Down

0 comments on commit 4e1f750

Please sign in to comment.