Merge pull request #1282 from trheyi/main

Refactor assistant route handling to apply OAuth guard globally
This commit is contained in:
Max 2025-11-08 11:44:55 +08:00 committed by GitHub
commit e2954ec5eb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 10 deletions

View file

@ -13,17 +13,16 @@ func Attach(group *gin.RouterGroup, oauth types.OAuth) {
// Get the Agent instance
n := agent.GetAgent()
// Create assistants group with OAuth guard
assistants := group.Group("/assistants")
assistants.Use(oauth.Guard)
// Apply OAuth guard to all routes
group.Use(oauth.Guard)
// Assistant CRUD - Standard REST endpoints
assistants.GET("/", ListAssistants) // GET /assistants - List assistants
assistants.POST("/", n.HandleAssistantSave) // POST /assistants - Create/Update assistant
assistants.GET("/tags", ListAssistantTags) // GET /assistants/tags - Get all assistant tags with permission filtering
assistants.GET("/:id", n.HandleAssistantDetail) // GET /assistants/:id - Get assistant details
assistants.DELETE("/:id", n.HandleAssistantDelete) // DELETE /assistants/:id - Delete assistant
group.GET("/assistants", ListAssistants) // GET /assistants - List assistants
group.POST("/assistants", n.HandleAssistantSave) // POST /assistants - Create/Update assistant
group.GET("/assistants/tags", ListAssistantTags) // GET /assistants/tags - Get all assistant tags with permission filtering
group.GET("/assistants/:id", n.HandleAssistantDetail) // GET /assistants/:id - Get assistant details
group.DELETE("/assistants/:id", n.HandleAssistantDelete) // DELETE /assistants/:id - Delete assistant
// Assistant Actions
assistants.POST("/:id/call", n.HandleAssistantCall) // POST /assistants/:id/call - Execute assistant API
group.POST("/assistants/:id/call", n.HandleAssistantCall) // POST /assistants/:id/call - Execute assistant API
}

View file

@ -754,7 +754,7 @@ func TestListAssistantTags(t *testing.T) {
data, hasData := response["data"].([]interface{})
if hasData {
t.Logf("Successfully retrieved %d tags", len(data))
// Verify tag structure
if len(data) > 0 {
tag, ok := data[0].(map[string]interface{})