aegis-server
REST API server for the Aegis Database Platform.
Overview
aegis-server provides the HTTP API layer built on Axum, featuring authentication, authorization, and endpoints for all database operations. It serves both the programmatic API and the web dashboard backend.
Features
- REST API - Full CRUD operations for all data paradigms
- TLS/HTTPS - Native TLS support with certificate-based encryption
- Authentication - Username/password (Argon2id), MFA, LDAP, OAuth2/OIDC
- Authorization - Role-based access control (RBAC)
- Rate Limiting - Token bucket rate limiting for API protection
- Secrets Management - HashiCorp Vault integration
- Audit Logging - Comprehensive activity tracking
- Admin API - Cluster management and monitoring
Architecture
┌─────────────────────────────────────────────┐
│ HTTP Server │
│ (Axum) │
├─────────────────────────────────────────────┤
│ Middleware Layer │
│ ┌─────────┬──────────┬─────────────────┐ │
│ │ Auth │ Logging │ Rate Limiting │ │
│ └─────────┴──────────┴─────────────────┘ │
├─────────────────────────────────────────────┤
│ Route Handlers │
│ ┌───────┬───────┬────────┬────────────┐ │
│ │ Query │ KV │ Docs │ Admin │ │
│ └───────┴───────┴────────┴────────────┘ │
├─────────────────────────────────────────────┤
│ Application State │
│ (Storage, Config, Auth) │
└─────────────────────────────────────────────┘
Modules
| Module | Description |
|---|---|
router |
Route definitions and API structure |
handlers |
Request handlers for all endpoints |
auth |
Authentication providers (local, LDAP, OAuth2) |
middleware |
Auth, logging, CORS, rate limiting middleware |
secrets |
HashiCorp Vault and environment secrets |
admin |
Cluster administration endpoints |
activity |
Activity logging and audit trail |
state |
Shared application state |
config |
Server configuration |
API Endpoints
Core
| Method | Endpoint | Description |
|---|---|---|
| GET | /health |
Health check |
| POST | /api/v1/query |
Execute SQL query |
| GET | /api/v1/tables |
List tables |
Authentication
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/v1/auth/login |
User login |
| POST | /api/v1/auth/mfa/verify |
Verify MFA code |
| POST | /api/v1/auth/logout |
User logout |
| GET | /api/v1/auth/session |
Validate session |
| GET | /api/v1/auth/me |
Current user info |
Key-Value Store
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/v1/kv/keys |
List keys |
| POST | /api/v1/kv/keys |
Set key |
| DELETE | /api/v1/kv/keys/:key |
Delete key |
Documents
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/v1/documents/collections |
List collections |
| GET | /api/v1/documents/collections/:name |
Get documents |
Admin
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/v1/admin/cluster |
Cluster status |
| GET | /api/v1/admin/nodes |
Node list |
| GET | /api/v1/admin/stats |
Statistics |
| GET | /api/v1/admin/alerts |
Active alerts |
Usage
Running the Server
# Using the CLI
# Or directly with cargo
# With custom host
Command-Line Options
aegis-server [OPTIONS]
Options:
-H, --host <HOST> Host to bind to [default: 127.0.0.1]
-p, --port <PORT> Port to listen on [default: 9090]
-d, --data-dir <DIR> Data directory for persistence
--node-id <ID> Unique node ID
--node-name <NAME> Node display name
--peers <PEERS> Comma-separated peer addresses
--cluster <NAME> Cluster name [default: aegis-cluster]
--tls Enable TLS/HTTPS
--tls-cert <PATH> TLS certificate file (PEM)
--tls-key <PATH> TLS private key file (PEM)
-h, --help Print help
TLS/HTTPS Mode
# With command-line arguments
# With environment variables
Configuration
[]
= "127.0.0.1"
= 9090
= 1000
= "30s"
[]
= "local" # local, ldap, oauth2
= "30m"
= false
[]
= true
= "/etc/aegis/tls.crt"
= "/etc/aegis/tls.key"
[]
= 1000
= 30
Environment Variables
| Variable | Description |
|---|---|
AEGIS_TLS_CERT |
Path to TLS certificate (PEM) |
AEGIS_TLS_KEY |
Path to TLS private key (PEM) |
VAULT_ADDR |
HashiCorp Vault server address |
VAULT_TOKEN |
Vault authentication token |
VAULT_ROLE_ID |
Vault AppRole role ID |
VAULT_SECRET_ID |
Vault AppRole secret ID |
HashiCorp Vault Integration
For enterprise secrets management, the server integrates with HashiCorp Vault:
# Configure Vault
# Secrets are read from: secret/data/aegis/*
# Falls back to environment variables if Vault unavailable
Authentication
Configuring Credentials
Set credentials via environment variables before starting the server:
Local Authentication
Using the Token
Security Features
Password Hashing
Passwords are hashed using Argon2id with:
- Memory cost: 19 MiB
- Time cost: 2 iterations
- Parallelism: 1
- Unique random salt per password
Rate Limiting
Token bucket algorithm protects against brute force:
- Login endpoints: 30 requests/minute/IP
- General API: 1000 requests/minute/IP
Session Tokens
Secure random tokens generated using rand::thread_rng() with cryptographically secure random number generation.
Tests
Test count: 54 tests (unit + integration)
License
Business Source License 1.1 (BSL) - See LICENSE for details.