You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/api/authentication.md
+14-11Lines changed: 14 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,9 +8,9 @@ Pangolin implements a secure authentication system based on JSON Web Tokens (JWT
8
8
-**Root Login**: Omit `tenant-id` or set to `null`
9
9
-**Tenant-Scoped Login**: Include `tenant-id` with tenant UUID
10
10
2.**Token Issuance**: Upon successful authentication, the server returns a signed JWT.
11
-
3.**Authenticated Requests**: Clients must include this JWT in the `Authorization` header of subsequent requests:
11
+
3.**API Key Authentication (Service Users)**: Machine accounts use a static API key passed in the `X-API-Key` header.
12
12
```
13
-
Authorization: Bearer <token>
13
+
X-API-Key: <your-api-key>
14
14
```
15
15
16
16
### Login Examples
@@ -47,20 +47,23 @@ Pangolin supports the following roles:
47
47
-**TenantAdmin**: Tenant-level administration. Can manage warehouses, catalogs, and users within a tenant.
48
48
-**TenantUser**: Standard access. Can read/write data based on catalog permissions.
49
49
50
-
## Token Generation
50
+
## API Key Authentication (Service Users)
51
51
52
-
For automation and scripts, users can generate long-lived JWT tokens:
52
+
Service users are intended for machine-to-machine communication (CI/CD, automated scripts). They do not use JWT tokens; instead, they use a persistent API key.
53
53
54
54
```bash
55
-
curl -X POST http://localhost:8080/api/v1/tokens \
56
-
-H "Content-Type: application/json" \
57
-
-d '{
58
-
"tenant_id": "your-tenant-id",
59
-
"username": "your-username",
60
-
"expires_in_hours": 720
61
-
}'
55
+
curl http://localhost:8080/api/v1/catalogs \
56
+
-H "X-API-Key: pgl_key_abc123..." \
57
+
-H "X-Pangolin-Tenant: <tenant-uuid>"
62
58
```
63
59
60
+
> [!TIP]
61
+
> API keys are only displayed once upon creation. If lost, the key must be rotated via the `/api/v1/service-users/{id}/rotate` endpoint.
62
+
63
+
## Token Generation (Users)
64
+
65
+
For temporary programmatic access by human users, you can generate long-lived JWT tokens:
Copy file name to clipboardExpand all lines: docs/architecture/architecture.md
+8-6Lines changed: 8 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -27,8 +27,9 @@ Pangolin is a Rust-based, multi-tenant, branch-aware lakehouse catalog. It is fu
27
27
28
28
### 3. Storage Layer (`pangolin_store`)
29
29
-**Metadata Persistence**: Abstracted via the `CatalogStore` trait.
30
+
-**Modular Backends**: All backends are refactored into focused submodules (e.g., `tenants.rs`, `warehouses.rs`, `assets.rs`) for better maintainability.
30
31
-`MemoryStore`: Concurrent in-memory store for rapid development/testing.
31
-
-`PostgresStore`: SQL backend using `sqlx` for relational scale.
32
+
-`PostgresStore`: SQL backend using `sqlx` for production scale.
32
33
-`MongoStore`: Document backend for high-availability deployments.
33
34
-`SqliteStore`: Embedded backend for local dev and edge use cases.
34
35
-**Performance**: Direct `assets_by_id` lookup for O(1) authorization checks.
@@ -37,13 +38,14 @@ Pangolin is a Rust-based, multi-tenant, branch-aware lakehouse catalog. It is fu
37
38
38
39
### 4. Security & Isolation
39
40
-**Authentication**:
40
-
-**JWT**: Standard for UI and human CLI access.
41
-
-**API Keys**: Distributed via **Service Users** for programmatic/CI-CD access.
42
-
-**OAuth 2.0**: OIDC integration with Google, Microsoft, GitHub, and Okta.
41
+
-**JWT**: Standard for UI and corporate identity access.
42
+
-**API Keys**: Managed via **Service Users** for machine-to-machine/CI-CD access. Includes automatic rotation and usage tracking.
43
+
-**OAuth 2.0 / OIDC**: Native integration with Google, Microsoft, GitHub, and custom providers.
43
44
-**Authorization**:
44
45
-**RBAC**: Role-based access control with 3 default tiers (Root, TenantAdmin, TenantUser).
45
-
-**TBAC**: Tag-based access control allowing permissions to flow to assets with specific labels.
46
-
-**Tenant Isolation**: Strictly enforced at the middleware layer; storage queries always include `tenant_id`.
46
+
-**TBAC**: Tag-based access control allowing permissions to flow to assets with specific business labels.
47
+
-**Access Requests**: Integrated workflow for users to request access to restricted assets via the UI.
48
+
-**Tenant Isolation**: Strictly enforced at the middleware layer; all store queries are scoped by `tenant_id`.
47
49
48
50
### 5. Git-like Data Lifecycle
49
51
-**Branching Engine**: Supports full and partial catalog branching.
API keys provide long-lived authentication for programmatic access.
126
+
API keys provide long-lived authentication specifically for **Service Users** (machine accounts). Regular human users cannot use API keys; they use Bearer tokens.
127
127
128
128
#### Header Format
129
129
```
130
130
X-API-Key: <api_key_value>
131
131
```
132
132
133
133
#### How It Works
134
-
1. Extract API key from `X-API-Key` header
135
-
2. Look up key in store via `get_api_key_by_value`
136
-
3. Verify key is not expired
137
-
4. Create session from key's user context
138
-
5. Insert session into request extensions
134
+
1. Extract API key from `X-API-Key` header.
135
+
2. Hash the key and look up the matching record in the store via `get_service_user_by_api_key_hash`.
136
+
3. Verify the service account is active and not expired.
137
+
4. Create a session with the service user's ID, tenant context, and role.
138
+
5. Track usage via `update_service_user_last_used`.
139
+
140
+
> [!TIP]
141
+
> Use Service Users for CI/CD pipelines, Spark clusters, or any non-interactive automation.
Beyond roles, Pangolin supports fine-grained permission grants at the Asset, Namespace, or Catalog level.
150
+
151
+
### Permission Structure
152
+
-**Scope**: Where the permission applies (Tenant, Catalog, Namespace, Asset, or Tag).
153
+
-**Actions**: What is allowed (`Read`, `Write`, `Create`, `Delete`, `ManageDiscovery`, etc.).
139
154
140
-
\u003e [!NOTE]
141
-
\u003e API keys are managed through the `/api/v1/users/{user_id}/tokens` endpoints.
155
+
### Multi-Tenant Isolation
156
+
The auth middleware automatically extracts the tenant context from the user's session or the `X-Pangolin-Tenant` header (for Root users). All subsequent storage operations are strictly scoped to this tenant ID.
-**Auto-Merge**: If changes are orthogonal (e.g., Branch A touched Table X, Branch B touched Table Y), they are merged automatically.
54
-
-**Manual**: If a conflict is detected, the merge operation pauses (`Conflicted` status) and requires API intervention to choose a winner (`TakeSource` or `TakeTarget`).
23
+
---
24
+
25
+
## Merge Lifecycle
26
+
27
+
Merging is managed via the `MergeOperation` model, which tracks the transition from initiation to completion.
28
+
29
+
### 1. Initiation
30
+
A merge is started between a `source` and `target` branch. Pangolin identifies the **Base Commit** (common ancestor) to perform a 3-way analysis.
31
+
32
+
### 2. Conflict Detection
33
+
Pangolin automatically detects:
34
+
-**Schema Conflict**: Incompatible evolution on both branches.
35
+
-**Data Conflict**: Concurrent writes to overlapping partitions.
-**Auto-Merge**: Orthogonal changes are applied automatically, and the operation moves to `Completed`.
40
+
-**Manual Intervention**: If conflicts are found, the operation enters `Conflicted` status. Users must use the API to resolve each conflict using a `ResolutionStrategy` (`TakeSource`, `TakeTarget`, or `ThreeWayMerge`).
41
+
42
+
### 4. Completion
43
+
Once all conflicts are resolved, the merge is finalized, creating a new commit on the target branch.
0 commit comments