mirror of
https://github.com/LogicLabs-OU/OpenArchiver.git
synced 2026-04-06 00:31:57 +02:00
* feat(auth): Implement API key authentication This commit enables API access with an API key system. This change provides a better experience for programmatic access and third-party integrations. Key changes include: - **API Key Management:** Users can now generate, manage, and revoke persistent API keys through a new "API Keys" section in the settings UI. - **Authentication Middleware:** API requests are now authenticated via an `X-API-KEY` header instead of the previous `Authorization: Bearer` token. - **Backend Implementation:** Adds a new `api_keys` database table, along with corresponding services, controllers, and routes to manage the key lifecycle securely. - **Rate Limiting:** The API rate limiter now uses the API key to identify and track requests. - **Documentation:** The API authentication documentation has been updated to reflect the new method. * Add configurable API rate limiting Two new variables are added to `.env.example`: - `RATE_LIMIT_WINDOW_MS`: The time window in milliseconds for which requests are checked (defaults to 15 minutes). - `RATE_LIMIT_MAX_REQUESTS`: The maximum number of requests allowed from an IP within the window (defaults to 100). The installation documentation has been updated to reflect these new configuration options. --------- Co-authored-by: Wayne <5291640+ringoinca@users.noreply.github.com>
73 lines
2.8 KiB
Plaintext
73 lines
2.8 KiB
Plaintext
|
|
# --- Application Settings ---
|
|
# Set to 'production' for production environments
|
|
NODE_ENV=development
|
|
PORT_BACKEND=4000
|
|
PORT_FRONTEND=3000
|
|
# The frequency of continuous email syncing. Default is every minutes, but you can change it to another value based on your needs.
|
|
SYNC_FREQUENCY='* * * * *'
|
|
|
|
# --- Docker Compose Service Configuration ---
|
|
# These variables are used by docker-compose.yml to configure the services. Leave them unchanged if you use Docker services for Postgresql, Valkey (Redis) and Meilisearch. If you decide to use your own instances of these services, you can substitute them with your own connection credentials.
|
|
|
|
# PostgreSQL
|
|
POSTGRES_DB=open_archive
|
|
POSTGRES_USER=admin
|
|
POSTGRES_PASSWORD=password
|
|
DATABASE_URL="postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB}"
|
|
|
|
# Meilisearch
|
|
MEILI_MASTER_KEY=aSampleMasterKey
|
|
MEILI_HOST=http://meilisearch:7700
|
|
|
|
|
|
|
|
# Redis (We use Valkey, which is Redis-compatible and open source)
|
|
REDIS_HOST=valkey
|
|
REDIS_PORT=6379
|
|
REDIS_PASSWORD=defaultredispassword
|
|
# If you run Valkey service from Docker Compose, set the REDIS_TLS_ENABLED variable to false.
|
|
REDIS_TLS_ENABLED=false
|
|
|
|
|
|
# --- Storage Settings ---
|
|
# Choose your storage backend. Valid options are 'local' or 's3'.
|
|
STORAGE_TYPE=local
|
|
# The maximum request body size to accept in bytes including while streaming. The body size can also be specified with a unit suffix for kilobytes (K), megabytes (M), or gigabytes (G). For example, 512K or 1M. Defaults to 512kb. Or the value of Infinity if you don't want any upload limit.
|
|
BODY_SIZE_LIMIT=100M
|
|
|
|
# --- Local Storage Settings ---
|
|
# The path inside the container where files will be stored.
|
|
# This is mapped to a Docker volume for persistence.
|
|
# This is only used if STORAGE_TYPE is 'local'.
|
|
STORAGE_LOCAL_ROOT_PATH=/var/data/open-archiver
|
|
|
|
# --- S3-Compatible Storage Settings ---
|
|
# These are only used if STORAGE_TYPE is 's3'.
|
|
STORAGE_S3_ENDPOINT=
|
|
STORAGE_S3_BUCKET=
|
|
STORAGE_S3_ACCESS_KEY_ID=
|
|
STORAGE_S3_SECRET_ACCESS_KEY=
|
|
STORAGE_S3_REGION=
|
|
# Set to 'true' for MinIO and other non-AWS S3 services
|
|
STORAGE_S3_FORCE_PATH_STYLE=false
|
|
|
|
# --- Security & Authentication ---
|
|
|
|
# Rate Limiting
|
|
# The window in milliseconds for which API requests are checked. Defaults to 900000 (15 minutes).
|
|
RATE_LIMIT_WINDOW_MS=900000
|
|
# The maximum number of API requests allowed from an IP within the window. Defaults to 100.
|
|
RATE_LIMIT_MAX_REQUESTS=100
|
|
|
|
# JWT
|
|
# IMPORTANT: Change this to a long, random, and secret string in your .env file
|
|
JWT_SECRET=a-very-secret-key-that-you-should-change
|
|
JWT_EXPIRES_IN="7d"
|
|
|
|
|
|
# Master Encryption Key for sensitive data (Such as Ingestion source credentials and passwords)
|
|
# IMPORTANT: Generate a secure, random 32-byte hex string for this
|
|
# You can use `openssl rand -hex 32` to generate a key.
|
|
ENCRYPTION_KEY=
|