fix(路由): 修正套餐真流量预警与资产自动续费的超管/平台 gate 作用域
Some checks failed
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Has been cancelled
Some checks failed
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Has been cancelled
Fiber 组中间件按路径前缀生效,两处 gate 挂在空路径组上实际落到 /api/admin 前缀, 注册顺序在其之后的后台接口对代理与企业账号一律返回 403(含代理充值、代理自充 支付方式与订单等)。gate 改为挂在各自功能路径组上,代理与企业仅被拒绝这两组功能入口。
This commit is contained in:
@@ -13,8 +13,10 @@ import (
|
|||||||
|
|
||||||
// registerAssetAutoRenewalRoutes 注册资产钱包自动续费配置的读写路由。
|
// registerAssetAutoRenewalRoutes 注册资产钱包自动续费配置的读写路由。
|
||||||
// 沿用超管/平台路由组级 gate 先例:代理、企业与个人客户账号一律 403,无任何读取或修改入口。
|
// 沿用超管/平台路由组级 gate 先例:代理、企业与个人客户账号一律 403,无任何读取或修改入口。
|
||||||
|
// gate 必须挂在功能路径组上:Fiber 的组中间件按路径前缀生效,挂在空路径组上会落到
|
||||||
|
// /api/admin 前缀,从而拦截该层其余全部接口。
|
||||||
func registerAssetAutoRenewalRoutes(router fiber.Router, handler *admin.AssetAutoRenewalConfigHandler, doc *openapi.Generator, basePath string) {
|
func registerAssetAutoRenewalRoutes(router fiber.Router, handler *admin.AssetAutoRenewalConfigHandler, doc *openapi.Generator, basePath string) {
|
||||||
group := router.Group("", func(c *fiber.Ctx) error {
|
group := router.Group("/asset-auto-renewal-config", func(c *fiber.Ctx) error {
|
||||||
userType := middleware.GetUserTypeFromContext(c.UserContext())
|
userType := middleware.GetUserTypeFromContext(c.UserContext())
|
||||||
if userType != constants.UserTypeSuperAdmin && userType != constants.UserTypePlatform {
|
if userType != constants.UserTypeSuperAdmin && userType != constants.UserTypePlatform {
|
||||||
return errors.New(errors.CodeForbidden, constants.PlatformManagementForbiddenMessage)
|
return errors.New(errors.CodeForbidden, constants.PlatformManagementForbiddenMessage)
|
||||||
|
|||||||
@@ -13,16 +13,18 @@ import (
|
|||||||
|
|
||||||
// registerPackageTrafficAlertRoutes 注册套餐真流量预警规则与达量预警路由。
|
// registerPackageTrafficAlertRoutes 注册套餐真流量预警规则与达量预警路由。
|
||||||
// 沿用超管/平台路由组级 gate 先例:代理、企业与个人客户账号一律 403。
|
// 沿用超管/平台路由组级 gate 先例:代理、企业与个人客户账号一律 403。
|
||||||
|
// gate 必须挂在功能路径组上:Fiber 的组中间件按路径前缀生效,挂在空路径组上会落到
|
||||||
|
// /api/admin 前缀,从而拦截该层其余全部接口。
|
||||||
func registerPackageTrafficAlertRoutes(router fiber.Router, handler *admin.PackageTrafficAlertHandler, doc *openapi.Generator, basePath string) {
|
func registerPackageTrafficAlertRoutes(router fiber.Router, handler *admin.PackageTrafficAlertHandler, doc *openapi.Generator, basePath string) {
|
||||||
group := router.Group("", func(c *fiber.Ctx) error {
|
gate := func(c *fiber.Ctx) error {
|
||||||
userType := middleware.GetUserTypeFromContext(c.UserContext())
|
userType := middleware.GetUserTypeFromContext(c.UserContext())
|
||||||
if userType != constants.UserTypeSuperAdmin && userType != constants.UserTypePlatform {
|
if userType != constants.UserTypeSuperAdmin && userType != constants.UserTypePlatform {
|
||||||
return errors.New(errors.CodeForbidden, constants.PlatformManagementForbiddenMessage)
|
return errors.New(errors.CodeForbidden, constants.PlatformManagementForbiddenMessage)
|
||||||
}
|
}
|
||||||
return c.Next()
|
return c.Next()
|
||||||
})
|
}
|
||||||
|
|
||||||
ruleGroup := group.Group("/package-traffic-alert-rules")
|
ruleGroup := router.Group("/package-traffic-alert-rules", gate)
|
||||||
rulePath := basePath + "/package-traffic-alert-rules"
|
rulePath := basePath + "/package-traffic-alert-rules"
|
||||||
|
|
||||||
Register(ruleGroup, doc, rulePath, "GET", "", handler.ListRules, RouteSpec{
|
Register(ruleGroup, doc, rulePath, "GET", "", handler.ListRules, RouteSpec{
|
||||||
@@ -52,7 +54,7 @@ func registerPackageTrafficAlertRoutes(router fiber.Router, handler *admin.Packa
|
|||||||
Auth: true,
|
Auth: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
alertGroup := group.Group("/package-traffic-alerts")
|
alertGroup := router.Group("/package-traffic-alerts", gate)
|
||||||
alertPath := basePath + "/package-traffic-alerts"
|
alertPath := basePath + "/package-traffic-alerts"
|
||||||
|
|
||||||
Register(alertGroup, doc, alertPath, "GET", "", handler.ListAlerts, RouteSpec{
|
Register(alertGroup, doc, alertPath, "GET", "", handler.ListAlerts, RouteSpec{
|
||||||
|
|||||||
Reference in New Issue
Block a user