浏览代码

修复oss签名鉴权

宋伯文 5 月之前
父节点
当前提交
56665246fe
共有 1 个文件被更改,包括 21 次插入17 次删除
  1. 21 17
      internal/handler/routes.go

+ 21 - 17
internal/handler/routes.go

@@ -1285,22 +1285,26 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
 	)
 
 	server.AddRoutes(
-		[]rest.Route{
-			{
-				Method:  http.MethodPost,
-				Path:    "/api/avatar/config",
-				Handler: avatar.GetApiAvatarConfigHandler(serverCtx),
-			},
-			{
-				Method:  http.MethodPost,
-				Path:    "/api/avatar/sts",
-				Handler: avatar.GetAcsResponseHandler(serverCtx),
-			},
-			{
-				Method:  http.MethodPost,
-				Path:    "/api/avatar/signature",
-				Handler: avatar.GetSignatureResponseHandler(serverCtx),
-			},
-		},
+		rest.WithMiddlewares(
+			[]rest.Middleware{serverCtx.Miniprogram},
+			[]rest.Route{
+				{
+					Method:  http.MethodPost,
+					Path:    "/api/avatar/config",
+					Handler: avatar.GetApiAvatarConfigHandler(serverCtx),
+				},
+				{
+					Method:  http.MethodPost,
+					Path:    "/api/avatar/sts",
+					Handler: avatar.GetAcsResponseHandler(serverCtx),
+				},
+				{
+					Method:  http.MethodPost,
+					Path:    "/api/avatar/signature",
+					Handler: avatar.GetSignatureResponseHandler(serverCtx),
+				},
+			}...,
+		),
+		rest.WithJwt(serverCtx.Config.Auth.AccessSecret),
 	)
 }