Skip to main content

Add your description here

Project description

RAJA

CI Integration Tests Coverage

Resource Authorization JWT Authority - Compile Cedar policies into JWT tokens for deterministic authorization.

What is RAJA?

RAJA compiles Cedar authorization policies into JWT tokens with explicit scopes. This means:

  • Authorization decisions are deterministic (same token + request = same result)
  • Tokens are transparent (you can see exactly what permissions are granted)
  • Enforcement is fast (simple scope checking, no policy evaluation)

Quick Start

Installation

git clone https://github.com/quiltdata/raja.git
cd raja
uv sync

Deploy to AWS (Control Plane)

# Deploy infrastructure
poe cdk-deploy --all

# Load Cedar policies
python scripts/load_policies.py

# Compile policies to scopes
export RAJA_API_URL="https://your-api.execute-api.us-east-1.amazonaws.com/prod"
python scripts/invoke_compiler.py

Control Plane UI

After deployment, open the API Gateway URL in your browser. The root path (/) renders a simple admin UI with live data from /principals, /policies, and /audit.

How It Works

Cedar Policies → Compiler → JWT Scopes → Library Enforcement
  1. Write Cedar policies that define who can do what
  2. Compiler converts policies into scope strings (e.g., Document:doc123:read)
  3. Token Service issues JWTs containing these scopes
  4. Applications validate tokens and check scopes locally

API Endpoints

When deployed to AWS, RAJA provides:

POST /compile - Compile Cedar policies into scopes

{}
 {"message": "Policies compiled successfully", "policies_compiled": 3}

POST /token - Issue a JWT token

{"principal": "alice"}
 {"token": "eyJ...", "scopes": ["Document:doc123:read"]}

GET /principals - List principals and their scopes

→ {"principals": [{"principal": "alice", "scopes": [...]}]}

**GET /policies** - List Cedar policies

```json
→ {"policies": [{"policyId": "..."}]}

GET /audit - View audit log entries


## Local Development

Use the Python library standalone (no AWS required):

```python
from raja import AuthRequest, create_token, enforce

# Create token with scopes
token = create_token(
    subject="alice",
    scopes=["Document:doc123:read"],
    secret="your-secret"
)

# Check authorization
decision = enforce(
    token_str=token,
    request=AuthRequest(resource_type="Document", resource_id="doc123", action="read"),
    secret="your-secret"
)
print(decision.allowed)  # True

Run Tests

poe test-unit      # Unit tests (no AWS)
poe test           # All tests
poe check-all      # Format, lint, typecheck

Scope Format

Scopes follow the pattern: {ResourceType}:{ResourceId}:{Action}

Examples:

  • Document:doc123:read - Read document doc123
  • Document:*:read - Read all documents
  • *:*:* - Full admin access

Project Structure

raja/
├── src/raja/           # Core Python library
├── lambda_handlers/    # AWS Lambda handlers
├── infra/             # CDK infrastructure
├── policies/          # Sample Cedar policies
└── tests/             # Test suite

Documentation

  • CLAUDE.md - Developer guide and architecture
  • specs/ - Design specifications
  • Module READMEs - See CLAUDE.md files in subdirectories

Contributing

See CLAUDE.md for development guidelines.

License

[License information to be added]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

raja-0.2.1.tar.gz (13.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

raja-0.2.1-py3-none-any.whl (15.9 kB view details)

Uploaded Python 3

File details

Details for the file raja-0.2.1.tar.gz.

File metadata

  • Download URL: raja-0.2.1.tar.gz
  • Upload date:
  • Size: 13.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.12

File hashes

Hashes for raja-0.2.1.tar.gz
Algorithm Hash digest
SHA256 4d2e16415d8918ecd6cc6a388f365c1de5f77e444db9c2589b1137cdaaa4f04f
MD5 774693b40c408f38ed7a900515a8160e
BLAKE2b-256 c9ed9b2a720d37597081e0ffa6540ced9796f91cb763ee23f4a5fd5787892ac2

See more details on using hashes here.

File details

Details for the file raja-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: raja-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 15.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.12

File hashes

Hashes for raja-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 02f38b0550cdd2fff6e7abf299cf0c97acce432e2c6ee9bace5aba90b58734a5
MD5 94671cf12b75ccf7ae36b2850d2e2910
BLAKE2b-256 00b241a5679144513ae8ecea242152ab68b00b4f39bea634d34fd9d85f18c72a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page