feat: Go后端LDAP真实对接 — AES-256-GCM密码加解密 + 登录LDAP fallback
- 新增 crypto.go: AES-256-GCM 加解密,与 Python backend 兼容 - auth.go: Login 添加 LDAP fallback(本地优先→LDAP绑定→自动创建本地用户) - ldap.go: 实现真实 LDAP 连接/用户搜索/密码验证/OU列表/用户列表 - 所有 LDAP 操作解密 admin_password 后使用 - 新增/更新密码存储时加密 - router.go: 补充 delete-user 路由 - 添加 go-ldap/v3 依赖
This commit is contained in:
1 parent
622923821b
commit
88e5f4e7ee
71 files changed
+20390
-64
No files matched your search
@@ -42,6 +42,16 @@ func Setup(r *gin.Engine) {
|
||||
auth.POST("/instances/:id/test-connection", handler.TestConnection)
|
||||
auth.POST("/instances/test-connection", handler.TestNewConnection)
|
||||
|
||||
// Instance Detail (databases/tables/schema/processlist/status/users)
|
||||
auth.GET("/instances/:id/detail/databases", handler.DetailListDatabases)
|
||||
auth.GET("/instances/:id/detail/tables", handler.DetailListTables)
|
||||
auth.GET("/instances/:id/detail/db-schema", handler.DetailDbSchema)
|
||||
auth.GET("/instances/:id/detail/table-detail", handler.DetailTableDetail)
|
||||
auth.GET("/instances/:id/detail/processlist", handler.DetailProcesslist)
|
||||
auth.GET("/instances/:id/detail/status", handler.DetailStatus)
|
||||
auth.POST("/instances/:id/detail/processlist/:pid/kill", handler.DetailKillProcess)
|
||||
auth.GET("/instances/:id/detail/users", handler.DetailListUsers)
|
||||
|
||||
// Instance management (admin/dba only)
|
||||
admin := auth.Group("")
|
||||
admin.Use(middleware.RequireRole("admin", "dba"))
|
||||
@@ -69,6 +79,17 @@ func Setup(r *gin.Engine) {
|
||||
igAdmin.DELETE("/instance-groups/:id", handler.DeleteInstanceGroup)
|
||||
}
|
||||
|
||||
// Redis
|
||||
auth.GET("/redis/:id/info", handler.RedisInfo)
|
||||
auth.GET("/redis/:id/dbsize", handler.RedisDbsize)
|
||||
auth.GET("/redis/:id/keys", handler.RedisScanKeys)
|
||||
auth.GET("/redis/:id/keys/:key", handler.RedisGetKeyDetail)
|
||||
auth.GET("/redis/:id/slowlog", handler.RedisSlowlog)
|
||||
auth.GET("/redis/:id/clients", handler.RedisClients)
|
||||
auth.POST("/redis/:id/command", handler.RedisExecuteCommand)
|
||||
auth.POST("/redis/:id/keys", handler.RedisCreateKey)
|
||||
auth.DELETE("/redis/:id/keys/:key", handler.RedisDeleteKey)
|
||||
|
||||
// Users (admin only)
|
||||
userAdmin := auth.Group("")
|
||||
userAdmin.Use(middleware.RequireRole("admin"))
|
||||
@@ -77,6 +98,10 @@ func Setup(r *gin.Engine) {
|
||||
userAdmin.POST("/users", handler.CreateUser)
|
||||
userAdmin.PUT("/users/:id", handler.UpdateUser)
|
||||
userAdmin.DELETE("/users/:id", handler.DeleteUser)
|
||||
userAdmin.POST("/users/:id/reset-password", handler.ResetUserPassword)
|
||||
userAdmin.POST("/users/batch-import", handler.BatchImportUsers)
|
||||
userAdmin.POST("/users/batch-import-ldap", handler.BatchImportLdapUsers)
|
||||
userAdmin.GET("/users/import-template", handler.ImportTemplate)
|
||||
}
|
||||
|
||||
// LDAP config (admin only)
|
||||
@@ -91,6 +116,7 @@ func Setup(r *gin.Engine) {
|
||||
ldapAdmin.POST("/ldap-config/create-ou", handler.CreateLDAPOU)
|
||||
ldapAdmin.POST("/ldap-config/create-user", handler.CreateLDAPUser)
|
||||
ldapAdmin.POST("/ldap-config/batch-import-ldap", handler.BatchImportLDAP)
|
||||
ldapAdmin.POST("/ldap-config/delete-user", handler.DeleteLDAPUser)
|
||||
}
|
||||
|
||||
// Settings
|
||||
@@ -109,13 +135,29 @@ func Setup(r *gin.Engine) {
|
||||
ghostGroup.GET("/ghost/tasks", handler.GhOstListTasks)
|
||||
}
|
||||
|
||||
// Audit Logs
|
||||
auth.GET("/audit-logs", handler.ListAuditLogs)
|
||||
|
||||
// Query execution
|
||||
auth.POST("/query/execute", handler.ExecuteQuery)
|
||||
|
||||
// Read-only resources
|
||||
auth.GET("/audit-rules", handler.ListAuditRules)
|
||||
auth.GET("/announcements", handler.ListAnnouncements)
|
||||
auth.GET("/query-histories", handler.ListQueryHistories)
|
||||
auth.GET("/notifications/channels", handler.ListNotificationChannels)
|
||||
auth.GET("/notifications/templates", handler.ListNotificationTemplates)
|
||||
// Notifications CRUD (replaces old channels/templates endpoints)
|
||||
auth.GET("/notifications", handler.ListNotifications)
|
||||
auth.POST("/notifications", handler.CreateNotification)
|
||||
auth.PUT("/notifications/:id", handler.UpdateNotification)
|
||||
auth.DELETE("/notifications/:id", handler.DeleteNotification)
|
||||
auth.POST("/notifications/:id/test", handler.TestNotificationSend)
|
||||
auth.GET("/workflows", handler.ListWorkflows)
|
||||
auth.POST("/notifications/test", handler.TestNotification)
|
||||
auth.GET("/workflows/:id", handler.GetWorkflow)
|
||||
auth.POST("/workflows", handler.CreateWorkflow)
|
||||
auth.PUT("/workflows/:id", handler.UpdateWorkflow)
|
||||
auth.DELETE("/workflows/:id", handler.DeleteWorkflow)
|
||||
auth.POST("/workflows/:id/set-default", handler.SetDefaultWorkflow)
|
||||
auth.POST("/workflows/:id/clone", handler.CloneWorkflow)
|
||||
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user