You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2020/10/20 08:02:19 UTC

[GitHub] [apisix-dashboard] nic-chen commented on a change in pull request #564: feat: refactor `manager api`

nic-chen commented on a change in pull request #564:
URL: https://github.com/apache/apisix-dashboard/pull/564#discussion_r508290471



##########
File path: api/filter/authentication.go
##########
@@ -17,49 +17,55 @@
 package filter
 
 import (
-	"github.com/apisix/manager-api/conf"
-	"github.com/apisix/manager-api/errno"
-	"github.com/dgrijalva/jwt-go"
-	"github.com/gin-gonic/gin"
 	"net/http"
 	"strings"
+
+	"github.com/dgrijalva/jwt-go"
+	"github.com/gin-gonic/gin"
+
+	"github.com/apisix/manager-api/conf"
 )
 
 func Authentication() gin.HandlerFunc {
 	return func(c *gin.Context) {
-		if c.Request.URL.Path != "/apisix/admin/user/login" && strings.HasPrefix(c.Request.URL.Path,"/apisix") {
+		if c.Request.URL.Path != "/apisix/admin/user/login" && strings.HasPrefix(c.Request.URL.Path, "/apisix") {
 			tokenStr := c.GetHeader("Authorization")
 
 			// verify token
 			token, err := jwt.ParseWithClaims(tokenStr, &jwt.StandardClaims{}, func(token *jwt.Token) (interface{}, error) {
 				return []byte(conf.AuthenticationConfig.Session.Secret), nil
 			})
 
-			if err != nil {
-				c.AbortWithStatusJSON(http.StatusUnauthorized, errno.FromMessage(errno.ForbiddenError).Response())
+			errResp := gin.H{
+				"code":    010013,

Review comment:
       will do this next version




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org