Aller au contenu principal

KytheraDB -- Governance

Enterprise governance model for KytheraDB, covering roles, teams, permissions, audit, and session management.


Table of Contents

  1. Role Hierarchy
  2. Team Management
  3. Project Permissions
  4. Audit Trail
  5. Session Management
  6. User Blocking
  7. Project Access Control

Role Hierarchy

KytheraDB defines five roles in ascending order of privilege:

viewer < qa < dev < admin < super_admin

Role Definitions

RoleDescriptionScope
viewerRead-only access to project data and schemasProject
qaViewer access plus seeding and QA template executionProject
devQA access plus SQL write, patches, imports, bridge, preflightProject
adminFull project access, connection management, team management, user adminOrganization
super_adminGovernance-only role: DSI dashboard, cross-organization visibilityPlatform

Role Capabilities

Capabilityviewerqadevadminsuper_admin
View schemas and dataYesYesYesYes--
Export dataYesYesYesYes--
Run seeds--YesYesYes--
Run QA templates--YesYesYes--
Write SQL----YesYes--
Create/execute patches----YesYes--
Import data----YesYes--
Bridge transfers----YesYes--
Preflight analysis----YesYes--
Performance monitoring----YesYes--
Manage connections------Yes--
Manage anonymization------Yes--
GDPR/compliance scanning------Yes--
Project configuration------Yes--
Team management------Yes--
User management------Yes--
Governance dashboard--------Yes
Block/unblock users--------Yes
Force logout--------Yes
Cross-project audit--------Yes
Manage project permissions--------Yes

super_admin Restrictions

The super_admin role is designed exclusively for governance and oversight. It cannot:

  • Access project data directly
  • Execute SQL queries
  • Create or modify records
  • Navigate to project routes

This separation ensures that governance users operate at the organizational level without touching production data.


Team Management

Teams group users for project access control.

Team Structure

Team
├── name: string
├── description: string
├── created_at: timestamp
└── members: TeamMember[]
├── user_id: UUID
├── role: string (admin, dev, qa, viewer)
└── joined_at: timestamp

Team Operations

OperationRequired RoleEndpoint
Create teamadminPOST /teams/
List teamsadminGET /teams/
View team detailsadminGET /teams/{team_id}
Update teamadminPATCH /teams/{team_id}
Delete teamadminDELETE /teams/{team_id}
Add memberadminPOST /teams/{team_id}/members
Remove memberadminDELETE /teams/{team_id}/members/{user_id}
Update member roleadminPATCH /teams/{team_id}/members/{user_id}
List team projectsadminGET /teams/{team_id}/projects
Create team projectadminPOST /teams/{team_id}/projects

Governance Team Operations

Super admins can manage teams through the governance API:

OperationEndpoint
List all teamsGET /governance/teams
Create teamPOST /governance/teams
View team detailsGET /governance/teams/{team_id}
Delete teamDELETE /governance/teams/{team_id}

Project Permissions

Fine-grained, per-user access grants on individual projects.

Permission Types

PermissionDescription
READView project schemas, data, and configurations
WRITEModify data through CRUD operations
EXECUTEExecute SQL queries and run seeds
PATCHCreate and execute mass patches
ADMINFull project control including configuration changes

Access Resolution

When a user attempts to access a project, the system checks in order:

  1. No team assigned to project: Any authenticated user has access (backward compatibility for projects created before team management).
  2. Team membership: If the project has a team_id, the user must be a member of that team.
  3. Direct permission: If the user is not a team member, check for a ProjectPermission record granting them access.

If none of these conditions are met, access is denied with HTTP 403.

Permission Management

Only super_admin users can manage project permissions through the governance API:

OperationEndpoint
Grant permissionPOST /governance/projects/{project_id}/permissions
List permissionsGET /governance/projects/{project_id}/permissions
Revoke permissionDELETE /governance/projects/{project_id}/permissions/{user_id}

Permission Data Model

ProjectPermission
├── id: UUID
├── project_id: UUID (FK → projects)
├── user_id: UUID (FK → app_users)
├── permissions: string[] (e.g., ["READ", "WRITE", "EXECUTE"])
├── granted_by: UUID (FK → app_users)
├── granted_at: timestamp

Audit Trail

Every significant action in the platform is recorded in the audit log.

Audit Log Entry

AuditLog
├── id: UUID
├── project_id: UUID (nullable for platform-level actions)
├── user_id: UUID (who performed the action)
├── action: string (e.g., "seed_insert", "patch_execute", "bridge_transfer")
├── details: JSON (action-specific metadata)
├── is_deleted_project: boolean (true if the project has been deleted)
├── created_at: timestamp

Audit Access

ScopeEndpointRole
Project activityGET /projects/{id}/activityAny member
Platform activityGET /auth/activityadmin
Governance auditGET /governance/auditsuper_admin
Export audit (CSV)GET /governance/audit/exportsuper_admin

Governance Audit Features

The governance audit endpoint supports:

  • Pagination: Page-based navigation for large audit logs
  • Filtering: By user, action type, date range, project
  • Search: Text search across action details
  • Export: Download the filtered audit trail as a CSV file

Session Management

Enterprise super admins can monitor and control active user sessions.

Session Operations

OperationEndpointDescription
List sessionsGET /governance/sessionsView all active user sessions
Revoke sessionPOST /governance/sessions/{user_id}/revokeForce-logout a specific user
Force logoutPOST /governance/users/{user_id}/force-logoutInvalidate all sessions for a user

Session Data

Sessions are tracked through JWT token issuance. Revoking a session invalidates the user's token, requiring them to re-authenticate.


User Blocking

Super admins can block users to prevent all platform access.

Block Operations

OperationEndpointDescription
Block userPOST /governance/users/{user_id}/blockBlock user with required reason
UnblockPOST /governance/users/{user_id}/unblockRestore user access

Block Data Model

User
├── is_active: boolean (false when blocked)
├── block_reason: string (required when blocking)

Blocked users receive HTTP 401 on all authenticated requests. The block reason is recorded for compliance and audit purposes.


Project Access Control

Access Flow Diagram

User requests project resource

├─ Is user authenticated?
│ No → 401 Unauthorized

├─ Is user super_admin?
│ Yes → 403 (governance only, no project access)

├─ Does project have a team_id?
│ No → Allow (backward compatibility)

├─ Is user a member of the project's team?
│ Yes → Allow

├─ Does user have a direct ProjectPermission?
│ Yes → Allow

└─ 403 Forbidden

Connection-Level Environment Awareness

Each connection has an environment_tag (e.g., dev, staging, production). This tag affects:

  • Preflight Guard: Stricter risk thresholds for production connections
  • Guard Rails: Policies can be configured per environment
  • Validation Rules: Rules can be scoped to specific environments via environment_tags
  • UI Indicators: The sidebar displays the active connection's environment tag

Governance Dashboard

The governance dashboard (GET /governance/dashboard) provides:

  • Total user count, active count, blocked count
  • Total team count and member distribution
  • Total project count with connection counts
  • Recent activity across all projects
  • Alert detection for anomalous activity patterns
  • Deleted project tracking