feat(server): org-scope service layer + handlers + org admin API

Threads org_id through every admin-facing service function (servers, keys,
assignments, secrets, workflows/steps/runs, monitors, channels, audit),
adds RequireRole middleware, and wires /api/org user + OIDC management
routes. Agent/scheduler paths keep unique-key signatures and resolve org
from the loaded record; internal-only helpers (getServerByID,
getRunByID, getMonitorByID) preserve those call sites.
This commit is contained in:
2026-07-21 16:56:39 +01:00
parent d0ed9885e7
commit 850aa0ed05
21 changed files with 451 additions and 209 deletions
+13
View File
@@ -35,6 +35,19 @@ func UserID(c *gin.Context) string {
return ""
}
func RequireRole(roles ...string) gin.HandlerFunc {
return func(c *gin.Context) {
r := Role(c)
for _, want := range roles {
if r == want {
c.Next()
return
}
}
c.AbortWithStatusJSON(http.StatusForbidden, gin.H{"error": "insufficient role"})
}
}
func Middleware() gin.HandlerFunc {
return func(c *gin.Context) {
cookie, err := c.Request.Cookie(sessionCookieName)