|
1 | | -# Management (Control Plane) API |
| 1 | +# Management API: Architecture & Entity Reference |
2 | 2 |
|
3 | | -This system serves as the Control Plane for our system, allowing users to self-service and manage their own user accounts, organizations, groups, and vaults. It communicates (server-to-server) with our @server/ using gRPC for all data operations, and exposes gRPC and REST APIs for client connections. These client connections will be from a web-based Dashboard, CLI tools, and potentially other client types in the future. |
| 3 | +> **Developer Guide**: This document provides a comprehensive reference for the InferaDB Management API architecture, data model, and core entity definitions. Use this as your primary reference when implementing features or understanding system behavior. |
4 | 4 |
|
5 | | -For data storage, we will support both in-memory and FoundationDB. In-memory is the default for development, and FoundationDB for production. |
| 5 | +## Overview |
| 6 | + |
| 7 | +The **Management API** is InferaDB's control plane, providing self-service capabilities for users to manage their accounts, organizations, teams, vaults, and access control. It serves as the orchestration layer between client applications (Dashboard, CLI, SDKs) and the InferaDB Server (data plane). |
| 8 | + |
| 9 | +**Key Responsibilities**: |
| 10 | + |
| 11 | +- User authentication & session management (password, passkey/WebAuthn, OAuth) |
| 12 | +- Multi-tenant organization management with role-based access control (RBAC) |
| 13 | +- Vault lifecycle management (create, configure, sync with Server, delete) |
| 14 | +- Client credential management for backend services (Ed25519 certificates, OAuth 2.0 JWT Bearer) |
| 15 | +- Token issuance for Server API access (vault-scoped JWTs with refresh tokens) |
| 16 | +- Audit logging for security events and compliance |
| 17 | + |
| 18 | +**Architecture**: |
| 19 | + |
| 20 | +- **Storage**: FoundationDB (production) or in-memory (development) |
| 21 | +- **Server Communication**: gRPC for real-time vault synchronization |
| 22 | +- **Client APIs**: REST (Dashboard, CLI) and gRPC (SDKs) |
| 23 | +- **Deployment**: Single-instance (dev/small deployments) or multi-instance HA (production) |
| 24 | + |
| 25 | +**Related Documentation**: |
| 26 | + |
| 27 | +- [Architecture.md](Architecture.md) - System architecture diagrams and deployment topologies |
| 28 | +- [Flows.md](Flows.md) - Sequence diagrams for key operations (registration, login, token generation) |
| 29 | +- [Authentication.md](Authentication.md) - Complete authentication and authorization guide |
| 30 | +- [GettingStarted.md](GettingStarted.md) - Step-by-step setup tutorial |
| 31 | +- [OpenAPI Specification](../OpenAPI.yaml) - Complete REST API reference |
| 32 | + |
| 33 | +--- |
| 34 | + |
| 35 | +## Table of Contents |
| 36 | + |
| 37 | +### Foundation |
| 38 | + |
| 39 | +- [Primary Keys](#primary-keys) - Snowflake ID generation and collision avoidance |
| 40 | + |
| 41 | +### Core Entities |
| 42 | + |
| 43 | +- [User Management](#user-management) |
| 44 | + |
| 45 | + - [User](#user) - User accounts |
| 46 | + - [UserEmail](#useremail) - Email addresses and verification |
| 47 | + - [UserEmailVerificationToken](#useremailverificationtoken) - Email ownership verification |
| 48 | + - [UserPasswordResetToken](#userpasswordresettoken) - Password reset flow |
| 49 | + - [UserPasskey](#userpasskey) - WebAuthn/FIDO2 credentials |
| 50 | + - [UserSession](#usersession) - Authentication sessions |
| 51 | + - [SessionType](#sessiontype) - Session type enumeration |
| 52 | + |
| 53 | +- [Organizations](#organizations) |
| 54 | + |
| 55 | + - [Organization](#organization) - Tenant/organization entities |
| 56 | + - [OrganizationMember](#organizationmember) - User membership in organizations |
| 57 | + - [OrganizationRole](#organizationrole) - Member, Admin, Owner roles |
| 58 | + - [OrganizationInvitation](#organizationinvitation) - Invite users to join |
| 59 | + - [OrganizationTier](#organizationtier) - Billing tiers and limits |
| 60 | + |
| 61 | +- [Teams](#teams) |
| 62 | + |
| 63 | + - [OrganizationTeam](#organizationteam) - Groups of users within organizations |
| 64 | + - [OrganizationTeamMember](#organizationteammember) - Team membership |
| 65 | + - [OrganizationTeamPermission](#organizationteampermission) - Delegated permissions |
| 66 | + - [OrganizationPermission](#organizationpermission) - Permission enumeration |
| 67 | + |
| 68 | +- [Clients](#clients) |
| 69 | + |
| 70 | + - [Client](#client) - Service identities for backend applications |
| 71 | + - [ClientCertificate](#clientcertificate) - Ed25519 key pairs for JWT signing |
| 72 | + |
| 73 | +- [Vaults](#vaults) |
| 74 | + |
| 75 | + - [Vault](#vault) - Authorization policy containers |
| 76 | + - [VaultSyncStatus](#vaultsyncstatus) - Synchronization status with Server |
| 77 | + - [VaultTeamGrant](#vaultteamgrant) - Team-based vault access |
| 78 | + - [VaultUserGrant](#vaultusergrant) - Direct user vault access |
| 79 | + - [VaultRole](#vaultrole) - Reader, Writer, Manager, Admin roles |
| 80 | + |
| 81 | +- [Tokens](#tokens) |
| 82 | + |
| 83 | + - [VaultRefreshToken](#vaultrefreshtoken) - Long-lived refresh tokens for vault JWTs |
| 84 | + |
| 85 | +- [Audit](#audit) |
| 86 | + - [AuditLog](#auditlog) - Security event logging |
| 87 | + - [AuditEventType](#auditeventtype) - Event type enumeration |
| 88 | + |
| 89 | +### System Behavior |
| 90 | + |
| 91 | +- [Behavioral Rules](#behavioral-rules) - Entity lifecycle and business logic |
| 92 | +- [Authentication & Authorization](#authentication--authorization) - Login flows and token management |
| 93 | +- [Email Flows](#email-flows) - Email verification and password reset |
| 94 | + |
| 95 | +### System Design |
| 96 | + |
| 97 | +- [API Design](#api-design) - REST conventions and best practices |
| 98 | +- [Management → Server Authentication](#management--server-privileged-authentication) - gRPC inter-service communication |
| 99 | +- [Server API Integration](#server-api-role-enforcement--tenant-isolation) - Role enforcement and tenant isolation |
| 100 | +- [Configuration](#configuration) - Environment variables and settings |
| 101 | +- [Multi-Instance Deployment](#multi-instance-deployment--distributed-coordination) - HA setup and leader election |
| 102 | +- [Multi-Tenancy & Data Isolation](#multi-tenancy--data-isolation) - Tenant separation guarantees |
| 103 | +- [Soft Delete & Cleanup](#soft-delete--cleanup) - Grace periods and background jobs |
| 104 | + |
| 105 | +### Operations |
| 106 | + |
| 107 | +- [Testing Strategy](#testing-strategy) - Test coverage and approaches |
| 108 | +- [Error Response Taxonomy](#error-response-taxonomy) - Standardized error codes |
| 109 | +- [Enhanced Security Features](#enhanced-security-features) - Rate limiting and security hardening |
| 110 | +- [Observability & Monitoring](#observability--monitoring-day-1) - Logging, metrics, and tracing |
| 111 | + |
| 112 | +### Planning |
| 113 | + |
| 114 | +- [Future Considerations](#future-considerations) - Roadmap and enhancement ideas |
| 115 | + |
| 116 | +--- |
6 | 117 |
|
7 | 118 | ## Primary Keys |
8 | 119 |
|
@@ -60,8 +171,24 @@ let user_id = id_gen.next_id(); // Returns i64 |
60 | 171 |
|
61 | 172 | **Storage**: IDs are stored as `i64` in FoundationDB and serialized as strings in JSON responses to avoid JavaScript's 53-bit integer precision limit. |
62 | 173 |
|
| 174 | +--- |
| 175 | + |
63 | 176 | ## Entity Definitions |
64 | 177 |
|
| 178 | +This section provides detailed specifications for all entities in the Management API data model. Each entity includes: |
| 179 | + |
| 180 | +- **Purpose**: What the entity represents |
| 181 | +- **Data**: Field definitions with types, constraints, and validation rules |
| 182 | +- **Constraints**: Uniqueness requirements and business rules |
| 183 | +- **Cascade Delete**: Behavior when parent entities are deleted |
| 184 | +- **API Path**: REST endpoint location |
| 185 | + |
| 186 | +> **Implementation Note**: All entities support soft deletion (90-day grace period) unless otherwise noted. See [Soft Delete & Cleanup](#soft-delete--cleanup) for details. |
| 187 | +
|
| 188 | +--- |
| 189 | + |
| 190 | +## User Management |
| 191 | + |
65 | 192 | ### User |
66 | 193 |
|
67 | 194 | Represents an individual user. Lives under the `/v1/users` API path. |
@@ -252,6 +379,8 @@ Enum defining session types (hard-coded). |
252 | 379 |
|
253 | 380 | --- |
254 | 381 |
|
| 382 | +## Organizations |
| 383 | + |
255 | 384 | ### Organization |
256 | 385 |
|
257 | 386 | Represents a single organization (tenant). Lives under the `/v1/organizations` API path. |
@@ -307,6 +436,8 @@ Associates a User with an Organization. Lives under the `/v1/organizations/:org/ |
307 | 436 |
|
308 | 437 | --- |
309 | 438 |
|
| 439 | +## Clients |
| 440 | + |
310 | 441 | ### Client |
311 | 442 |
|
312 | 443 | Represents a registered Client for an Organization using the Client Assertion pattern (OAuth 2.0 JWT Bearer, RFC 7523). A client is a logical service identity (e.g., "Production Backend", "CI/CD Pipeline") that can have multiple certificates for graceful rotation. |
@@ -532,6 +663,8 @@ Enum defining Organization billing/feature tiers (hard-coded). |
532 | 663 |
|
533 | 664 | --- |
534 | 665 |
|
| 666 | +## Teams |
| 667 | + |
535 | 668 | ### OrganizationTeam |
536 | 669 |
|
537 | 670 | Represents a team (group of users) within an Organization. Lives under the `/v1/organizations/:org/teams` API path. |
@@ -718,6 +851,8 @@ Users can accumulate permissions from multiple sources: |
718 | 851 |
|
719 | 852 | --- |
720 | 853 |
|
| 854 | +## Vaults |
| 855 | + |
721 | 856 | ### Vault |
722 | 857 |
|
723 | 858 | Represents an authorization vault (tenant in @server). Lives under the `/v1/vaults` API path. |
@@ -840,6 +975,8 @@ Enum defining Vault access roles (hard-coded). |
840 | 975 |
|
841 | 976 | --- |
842 | 977 |
|
| 978 | +## Tokens |
| 979 | + |
843 | 980 | ### VaultRefreshToken |
844 | 981 |
|
845 | 982 | Represents a refresh token for vault-scoped JWTs. Enables long-running operations and background jobs to refresh their Server API access tokens without re-authenticating. Not exposed via REST API (internal use only). |
@@ -906,6 +1043,8 @@ Represents a refresh token for vault-scoped JWTs. Enables long-running operation |
906 | 1043 |
|
907 | 1044 | --- |
908 | 1045 |
|
| 1046 | +## Audit |
| 1047 | + |
909 | 1048 | ### AuditLog |
910 | 1049 |
|
911 | 1050 | Represents a security audit event for tracking authentication events, permission changes, and sensitive operations. Not directly exposed via REST API (admin/debug access only via `/v1/audit-logs` endpoint). |
|
0 commit comments