feat(backend): implement layered session timeout and enhanced download control for web proxy

This commit is contained in:
pycook
2025-08-03 21:03:51 +08:00
parent dd11bf67ce
commit 2ef67fd396
10 changed files with 799 additions and 349 deletions

View File

@@ -27,6 +27,12 @@ func SetupRouter(r *gin.Engine) {
// Check if this is an asset subdomain request
if strings.HasPrefix(host, "asset-") {
// Allow API requests to pass through to normal routing
if strings.HasPrefix(c.Request.URL.Path, "/api/oneterm/v1/") {
c.Next()
return
}
// Handle external redirect requests
if c.Request.URL.Path == "/external" {
webProxy.HandleExternalRedirect(c)
@@ -259,8 +265,13 @@ func SetupRouter(r *gin.Engine) {
webProxyGroup.GET("/external_redirect", webProxy.HandleExternalRedirect)
webProxyGroup.POST("/close", webProxy.CloseWebSession)
webProxyGroup.GET("/sessions/:asset_id", webProxy.GetActiveWebSessions)
webProxyGroup.POST("/heartbeat", webProxy.UpdateWebSessionHeartbeat)
webProxyGroup.POST("/cleanup", webProxy.CleanupWebSession)
}
// Web proxy routes that don't require auth (heartbeat, cleanup)
webProxyNoAuth := v1AuthAbandoned.Group("/web_proxy")
{
webProxyNoAuth.POST("/heartbeat", webProxy.UpdateWebSessionHeartbeat)
webProxyNoAuth.POST("/cleanup", webProxy.CleanupWebSession)
}
}
}