合并分支 'dev' 到 'test'
fix:过滤路由 查看合并请求 !18
正在显示
2 个修改的文件
包含
16 行增加
和
2 行删除
| @@ -6,6 +6,7 @@ import ( | @@ -6,6 +6,7 @@ import ( | ||
| 6 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/constant" | 6 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/constant" |
| 7 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/utils" | 7 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/utils" |
| 8 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/protocol" | 8 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/protocol" |
| 9 | + "net/url" | ||
| 9 | "strconv" | 10 | "strconv" |
| 10 | "strings" | 11 | "strings" |
| 11 | ) | 12 | ) |
| @@ -16,6 +17,19 @@ func CheckJWTToken(ctx *context.Context) { | @@ -16,6 +17,19 @@ func CheckJWTToken(ctx *context.Context) { | ||
| 16 | msg *protocol.ResponseMessage | 17 | msg *protocol.ResponseMessage |
| 17 | ) | 18 | ) |
| 18 | 19 | ||
| 20 | + // 需要被过滤的地址 一定要写键值 | ||
| 21 | + filterMap := map[string]string{ | ||
| 22 | + "/v1/auth/checkPassword": "校验密码", | ||
| 23 | + } | ||
| 24 | + | ||
| 25 | + urlStr := "" | ||
| 26 | + tmpUrl, err := url.Parse(ctx.Request.RequestURI) | ||
| 27 | + if err == nil { | ||
| 28 | + urlStr = tmpUrl.Path | ||
| 29 | + } | ||
| 30 | + | ||
| 31 | + if res := filterMap[urlStr]; res == "" { | ||
| 32 | + /** 不在 Map 内对请求进行处理 **/ | ||
| 19 | token := ctx.Input.Header("x-mmm-accesstoken") | 33 | token := ctx.Input.Header("x-mmm-accesstoken") |
| 20 | 34 | ||
| 21 | if strings.HasSuffix(ctx.Request.RequestURI, "login") || | 35 | if strings.HasSuffix(ctx.Request.RequestURI, "login") || |
| @@ -57,5 +71,6 @@ func CheckJWTToken(ctx *context.Context) { | @@ -57,5 +71,6 @@ func CheckJWTToken(ctx *context.Context) { | ||
| 57 | } | 71 | } |
| 58 | } | 72 | } |
| 59 | } | 73 | } |
| 74 | + } | ||
| 60 | return | 75 | return |
| 61 | } | 76 | } |
| @@ -6,10 +6,9 @@ import ( | @@ -6,10 +6,9 @@ import ( | ||
| 6 | ) | 6 | ) |
| 7 | 7 | ||
| 8 | func init() { | 8 | func init() { |
| 9 | - beego.Router("/auth/checkPassword", &controllers.AuthController{}, "Post:CheckPassword") | ||
| 10 | nsV1 := beego.NewNamespace("v1") //, beego.NSBefore(middleware.CheckJWTToken) | 9 | nsV1 := beego.NewNamespace("v1") //, beego.NSBefore(middleware.CheckJWTToken) |
| 11 | nsV1.Router("/auth/login", &controllers.AuthController{}, "Post:Login") | 10 | nsV1.Router("/auth/login", &controllers.AuthController{}, "Post:Login") |
| 12 | - //nsV1.Router("/auth/checkPassword", &controllers.AuthController{}, "Post:CheckPassword") // 校验密码 | 11 | + nsV1.Router("/auth/checkPassword", &controllers.AuthController{}, "Post:CheckPassword") // 校验密码 |
| 13 | nsV1.Router("/auth/smsCode", &controllers.AuthController{}, "Post:SmsCode") | 12 | nsV1.Router("/auth/smsCode", &controllers.AuthController{}, "Post:SmsCode") |
| 14 | nsV1.Router("/auth/accessToken", &controllers.AuthController{}, "Post:AccessToken") | 13 | nsV1.Router("/auth/accessToken", &controllers.AuthController{}, "Post:AccessToken") |
| 15 | nsV1.Router("/auth/refreshToken", &controllers.AuthController{}, "Post:RefreshToken") | 14 | nsV1.Router("/auth/refreshToken", &controllers.AuthController{}, "Post:RefreshToken") |
-
请 注册 或 登录 后发表评论