fix(api): Enable management routes based on secret key presence

This commit is contained in:
hkfires
2025-10-04 13:32:54 +08:00
parent fd795caf76
commit 608d745159

View File

@@ -394,10 +394,14 @@ func (s *Server) setupRoutes() {
func (s *Server) managementAvailabilityMiddleware() gin.HandlerFunc {
return func(c *gin.Context) {
if !s.managementRoutesEnabled.Load() {
cfg := s.cfg
if cfg == nil || cfg.RemoteManagement.SecretKey == "" {
s.managementRoutesEnabled.Store(false)
c.AbortWithStatus(http.StatusNotFound)
return
}
s.managementRoutesEnabled.Store(true)
c.Next()
}
}