Browse Source

修复oss签名鉴权

宋伯文 5 months ago
parent
commit
56665246fe
1 changed files with 21 additions and 17 deletions
  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),
 	)
 }