| Crates.io | cedrus |
| lib.rs | cedrus |
| version | 0.1.0 |
| created_at | 2025-11-01 15:00:39.493305+00 |
| updated_at | 2025-11-01 15:00:39.493305+00 |
| description | Cedrus REST API server for Cedar Policy |
| homepage | https://github.com/stratusmedia/cedrus |
| repository | https://github.com/stratusmedia/cedrus |
| max_upload_size | |
| id | 1912074 |
| size | 230,177 |

Cedrus is a REST API server for Cedar Policy authorization, designed for internal infrastructure. It provides a multi-tenant authorization service inspired by Amazon Verified Permissions.
Cedrus allows you to:
cedrus provides a production-ready HTTP server that exposes Cedrus Core functionality through a RESTful API. It includes:
The server exposes the following endpoint groups:
Cedrus requires a database to persist policies and entities. Supported options:
CouchDB (recommended for local development):
docker run --name cedrus-couchdb \
-e COUCHDB_USER=admin \
-e COUCHDB_PASSWORD=admin \
-p 5984:5984 \
-d couchdb
DynamoDB (recommended for AWS deployments):
For production deployments with multiple instances:
Valkey/Redis:
docker run --name cedrus-cache \
-p 6379:6379 \
-d valkey/valkey:latest
Cedrus is an authorization server and requires an authentication provider (OIDC).
Keycloak (example):
docker run --name cedrus-keycloak \
-p 8080:8080 \
-e KC_BOOTSTRAP_ADMIN_USERNAME=admin \
-e KC_BOOTSTRAP_ADMIN_PASSWORD=admin \
quay.io/keycloak/keycloak:26.4.2 start-dev
After starting Keycloak:
# Clone the repository
git clone <repository-url>
cd cedrus
# Build release binary
cargo build --release
# Install binary (optional)
sudo cp target/release/cedrus /usr/local/bin/
Create a configuration file (e.g., cedrus.config.json):
{
"server": {
"port": 3000,
"host": "0.0.0.0",
"apiKey": "YOUR_BASE64_ADMIN_API_KEY"
},
"db": {
"couchDbConfig": {
"dbName": "cedrus",
"uri": "http://localhost:5984",
"username": "admin",
"password": "admin"
}
},
"identitySource": {
"principalEntityType": "Cedrus::User",
"configuration": {
"openIdConnectConfiguration": {
"issuer": "http://localhost:8080/realms/myrealm",
"tokenSelection": {
"identityTokenOnly": {
"clientIds": ["myclient"],
"principalIdClaim": "sub"
}
},
"groupConfiguration": {
"groupClaim": "groups",
"groupEntityType": "Cedrus::Group"
}
}
}
}
}
{
"server": {
"port": 3000,
"host": "0.0.0.0",
"apiKey": "YOUR_BASE64_ADMIN_API_KEY"
},
"db": {
"dynamoDbConfig": {
"tableName": "cedrus-table",
"region": "us-east-1"
}
},
"cache": {
"valKeyConfig": {
"urls": ["redis://localhost:6379"],
"cluster": false
}
},
"pubsub": {
"valKeyConfig": {
"urls": ["redis://localhost:6379/?protocol=resp3"],
"channelName": "cedrus",
"cluster": false
}
},
"identitySource": {
"principalEntityType": "Cedrus::User",
"configuration": {
"cognitoUserPoolConfiguration": {
"userPoolArn": "arn:aws:cognito-idp:us-east-1:123456789:userpool/us-east-1_ABC123",
"clientIds": ["your-client-id"],
"groupConfiguration": {
"groupEntityType": "Cedrus::Group"
}
}
}
}
}
port: HTTP server port (default: 3000)host: Bind address (use "0.0.0.0" for all interfaces)apiKey: Admin API key for Cedrus management (base64 encoded)Generate a secure API key:
head -c128 /dev/urandom | base64 --wrap=0
CouchDB:
dbName: Database nameuri: CouchDB server URLusername: Admin usernamepassword: Admin passwordDynamoDB:
tableName: DynamoDB table nameregion: AWS region (optional, uses default AWS config)endpointUrl: Custom endpoint for DynamoDB Local (optional)urls: List of Valkey/Redis server URLscluster: Enable cluster mode (true/false)urls: List of Valkey/Redis server URLs for pub/subchannelName: Channel name for cluster synchronizationcluster: Enable cluster mode (true/false)OpenID Connect:
{
"openIdConnectConfiguration": {
"issuer": "https://your-oidc-provider.com",
"tokenSelection": {
"identityTokenOnly": {
"clientIds": ["client-id"],
"principalIdClaim": "sub"
}
},
"groupConfiguration": {
"groupClaim": "groups",
"groupEntityType": "Cedrus::Group"
}
}
}
AWS Cognito:
{
"cognitoUserPoolConfiguration": {
"userPoolArn": "arn:aws:cognito-idp:region:account:userpool/pool-id",
"clientIds": ["client-id"],
"groupConfiguration": {
"groupEntityType": "Cedrus::Group"
}
}
}
See config/cedrus-local.config.json for a complete example.
# Using the binary
cedrus /path/to/cedrus.config.json
# Or with cargo
cargo run --release -- /path/to/cedrus.config.json
The server will start on the configured port (default: http://localhost:3000).
Once running, access the interactive API documentation:
Swagger UI: http://localhost:3000/swagger-ui/
The Swagger UI provides:
Cedrus supports two authentication methods:
Bearer Token (for end users): Use JWT tokens from your OIDC provider
Authorization: Bearer <jwt-token>
API Key (for service accounts): Use project-specific API keys
X-API-KEY: <project-api-key>
curl -X POST http://localhost:3000/v1/projects \
-H "X-API-KEY: YOUR_ADMIN_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "My Application",
"owner": {
"type": "Cedrus::User",
"id": "user-123"
}
}'
curl -X PUT http://localhost:3000/v1/projects/{project-id}/schema \
-H "X-API-KEY: YOUR_PROJECT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"MyApp": {
"entityTypes": {
"User": {},
"Document": {
"shape": {
"type": "Record",
"attributes": {
"owner": {
"type": "Entity",
"name": "User"
}
}
}
}
},
"actions": {
"viewDocument": {
"appliesTo": {
"principalTypes": ["User"],
"resourceTypes": ["Document"]
}
}
}
}
}'
curl -X POST http://localhost:3000/v1/projects/{project-id}/entities \
-H "X-API-KEY: YOUR_PROJECT_API_KEY" \
-H "Content-Type: application/json" \
-d '[
{
"uid": {"type": "MyApp::User", "id": "alice"},
"attrs": {},
"parents": []
},
{
"uid": {"type": "MyApp::Document", "id": "doc1"},
"attrs": {
"owner": {"type": "MyApp::User", "id": "alice"}
},
"parents": []
}
]'
curl -X POST http://localhost:3000/v1/projects/{project-id}/policies \
-H "X-API-KEY: YOUR_PROJECT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"owner-can-view": {
"effect": "permit",
"principal": {"op": "All"},
"action": {
"op": "==",
"entity": {"type": "MyApp::Action", "id": "viewDocument"}
},
"resource": {"op": "All"},
"conditions": [{
"kind": "when",
"body": {
"==": {
"left": {".": {"left": {"Var": "resource"}, "attr": "owner"}},
"right": {"Var": "principal"}
}
}
}]
}
}'
curl -X POST http://localhost:3000/v1/projects/{project-id}/is-authorized \
-H "X-API-KEY: YOUR_PROJECT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"principal": {"type": "MyApp::User", "id": "alice"},
"action": {"type": "MyApp::Action", "id": "viewDocument"},
"resource": {"type": "MyApp::Document", "id": "doc1"}
}'
Response:
{
"decision": "Allow",
"diagnostics": {
"reason": ["owner-can-view"],
"errors": []
}
}
┌─────────────────────────────────────────────────────────┐
│ Cedrus HTTP Server │
├─────────────────────────────────────────────────────────┤
│ Axum Router │
│ ├─ Authentication Middleware │
│ ├─ CORS Layer │
│ ├─ Compression Layer │
│ └─ Tracing Layer │
├─────────────────────────────────────────────────────────┤
│ REST API Handlers │
│ ├─ Projects │
│ ├─ Schemas │
│ ├─ Entities │
│ ├─ Policies │
│ └─ Authorization │
├─────────────────────────────────────────────────────────┤
│ Cedrus Core (Business Logic) │
└─────────────────────────────────────────────────────────┘
Applied to all /v1/projects/* routes:
Checks for X-API-KEY header
If no API key, checks for Authorization: Bearer header
Cedrus::User entityInjects principal EntityUid into request extensions
Allows cross-origin requests:
Automatically compresses responses for better performance.
Logs all HTTP requests with:
cargo test
cargo build --release
The binary will be available at target/release/cedrus.
Cedrus implements a multi-tenant model:
Use DashMap cache (in-memory, no external dependencies):
{
"cache": {"dashMapConfig": {}},
"pubsub": {"dummyConfig": {}}
}
Use Valkey/Redis for distributed cache and pub/sub:
{
"cache": {
"valKeyConfig": {
"urls": ["redis://cache-server:6379"],
"cluster": true
}
},
"pubsub": {
"valKeyConfig": {
"urls": ["redis://cache-server:6379/?protocol=resp3"],
"channelName": "cedrus",
"cluster": true
}
}
}
principalIdClaim matches the claim in your JWTaxum: Web frameworkcedrus-core: Business logiccedrus-cedar: Type definitionstower-http: HTTP middlewareutoipa: OpenAPI documentationutoipa-swagger-ui: Swagger UI integrationjwt-authorizer: JWT validationtokio: Async runtimeThis server can be:
Apache-2.0
Stratus Media Solutions SL. All Rights Reserved.