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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user