diff --git a/core/middlewares/auth.go b/core/middlewares/auth.go index 763f12f6..f7621afc 100644 --- a/core/middlewares/auth.go +++ b/core/middlewares/auth.go @@ -9,6 +9,7 @@ import ( "github.com/crawlab-team/crawlab/core/utils" "github.com/gin-gonic/gin" "go.mongodb.org/mongo-driver/bson" + "strings" ) func AuthorizationMiddleware() gin.HandlerFunc { @@ -28,6 +29,9 @@ func AuthorizationMiddleware() gin.HandlerFunc { // token string tokenStr := c.GetHeader("Authorization") + if strings.HasPrefix(tokenStr, "Bearer ") { + tokenStr = strings.Replace(tokenStr, "Bearer ", "", 1) + } // validate token u, err := userSvc.CheckToken(tokenStr)