Configuration

Configure Authority using environment variables.

Server Settings

Variable
Default
Description

CRYSTAL_ENV

development

Environment: development, production, test

PORT

4000

HTTP server port

HOST

0.0.0.0

Bind address

BASE_URL

http://localhost:4000

Public URL for redirects and links

CRYSTAL_WORKERS

4

Number of worker processes

Database

Variable
Default
Description

DATABASE_URL

Required

PostgreSQL connection string

Example connection strings:

# Local development
DATABASE_URL=postgres://localhost:5432/authority_db

# With credentials
DATABASE_URL=postgres://user:password@localhost:5432/authority_db

# With SSL
DATABASE_URL=postgres://user:password@host:5432/authority_db?sslmode=require

Security

Variable
Default
Description

SECRET_KEY

Required

JWT signing key (256-bit minimum)

Generate a secure key:

Token Lifetimes

Variable
Default
Description

ACCESS_TOKEN_TTL

3600

Access token lifetime (seconds)

CODE_TTL

600

Authorization code lifetime (seconds)

DEVICE_CODE_TTL

300

Device code lifetime (seconds)

Session

Variable
Default
Description

SESSION_KEY

session_id

Session cookie name

SESSION_DURATION_DAYS

7

Session lifetime (days)

SSL/TLS

Variable
Default
Description

SSL_CERT

Path to SSL certificate

SSL_KEY

Path to SSL private key

SSL_CA

Path to CA certificate

SSL_MODE

SSL mode: require, verify-ca, verify-full

Templates

Variable
Default
Description

TEMPLATES_PATH

./public/templates

Path to Jinja templates

Logging

Variable
Default
Description

CRYSTAL_LOG_LEVEL

debug

Log level: debug, info, warn, error

CRYSTAL_LOG_SOURCES

*

Log sources filter

Example Configuration

Development

Production

Loading Environment Variables

From File

Authority automatically loads .env.local in development:

From Shell

Docker

Or with env file:

Next Steps

Last updated

Was this helpful?