- Introduced a new Lua-based REST API for darktable, allowing external applications to interact with the darktable library. - Implemented core functionalities including image listing, retrieval, and preview serving. - Added support for OAuth 2.0 authentication with token generation. - Created a simple HTTP router to handle API requests. - Included JSON encoding/decoding utilities for API responses. - Developed a script to launch the API server alongside darktable, ensuring seamless integration. - Added necessary configuration and setup for the API server, including CORS support and error handling.
32 lines
1.2 KiB
Lua
32 lines
1.2 KiB
Lua
local M = {}
|
|
|
|
local home = os.getenv("HOME") or "/root"
|
|
|
|
M.host = os.getenv("DT_API_HOST") or "127.0.0.1"
|
|
M.port = tonumber(os.getenv("DT_API_PORT")) or 7645
|
|
|
|
-- Darktable paths
|
|
M.library_db = os.getenv("DT_LIBRARY") or (home .. "/.config/darktable/library.db")
|
|
M.data_db = os.getenv("DT_DATA_DB") or (home .. "/.config/darktable/data.db")
|
|
M.cache_dir = os.getenv("DT_CACHE_DIR") or (home .. "/.cache/darktable")
|
|
|
|
-- JWT / OAuth
|
|
M.jwt_secret = os.getenv("DT_JWT_SECRET") or "change-this-secret-in-production"
|
|
M.token_ttl = tonumber(os.getenv("DT_TOKEN_TTL")) or 3600
|
|
|
|
-- OAuth 2.0 clients table: client_id -> { secret, scopes[] }
|
|
-- Additional clients can be registered by adding entries here or setting
|
|
-- DT_CLIENT_ID / DT_CLIENT_SECRET environment variables.
|
|
M.clients = {}
|
|
local default_id = os.getenv("DT_CLIENT_ID") or "darktable-client"
|
|
local default_secret = os.getenv("DT_CLIENT_SECRET") or "changeme"
|
|
M.clients[default_id] = {
|
|
secret = default_secret,
|
|
scopes = { "images:read", "previews:read", "tags:read", "films:read", "cache:refresh" },
|
|
}
|
|
|
|
-- Queue file the bridge plugin watches for cache-refresh requests.
|
|
M.refresh_queue = os.getenv("DT_REFRESH_QUEUE") or "/tmp/dt-api-refresh.queue"
|
|
|
|
return M
|