Development
Getting Started
These steps bring up a local database, generate JWT keys, configure the service, build it, and run tests.
Prerequisites
- CMake, Ninja, a C++20 compiler, and Python.
- Docker for local Postgres, or a compatible local Postgres instance.
- Submodules initialized with
git submodule update --init.
Local Environment
Create a local .env for Docker Compose:
POSTGRES_DB=smirkly_auth
POSTGRES_USER=smirkly_auth
POSTGRES_PASSWORD=smirkly_auth
Create configs/config_vars.yaml. Keep this file untracked because it may contain secrets.
worker-threads: 4
worker-fs-threads: 2
logger-level: info
server-port: 8080
AUTH_JWT_AUDIENCE: smirkly-api
AUTH_JWT_KEY_ID: smirkly-auth-local-rs256
AUTH_JWT_PRIVATE_KEY_PATH: ./configs/secrets/auth_jwt_private.pem
AUTH_JWT_PUBLIC_KEY_PATH: ./configs/secrets/auth_jwt_public.pem
AUTH_SMTP_HOST: smtp.localhost
AUTH_SMTP_PORT: 587
AUTH_SMTP_TLS_MODE: starttls
AUTH_SMTP_USERNAME: local-dev-user
AUTH_SMTP_APP_PASSWORD: local-dev-password
AUTH_SMTP_FROM_EMAIL: no-reply@localhost
AUTH_SMTP_FROM_NAME: Smirkly
JWT Keys
mkdir -p configs/secrets
openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:2048 \
-out configs/secrets/auth_jwt_private.pem
openssl rsa -in configs/secrets/auth_jwt_private.pem \
-pubout -out configs/secrets/auth_jwt_public.pem
chmod 600 configs/secrets/auth_jwt_private.pem
Database
docker compose up -d smirkly-postgres
The local compose file mounts migrations/ into the Postgres init directory.
This is convenient for first boot only. Production environments should use an explicit
migration runner.
Build and Test
make cmake-debug
make build-debug
make test-debug
Equivalent direct CMake workflow:
cmake -S . -B cmake-build-debug -G Ninja -DCMAKE_BUILD_TYPE=Debug
cmake --build cmake-build-debug -j$(nproc)
ctest --test-dir cmake-build-debug --output-on-failure
Run the Service
./cmake-build-debug/smirkly-auth \
--config ./configs/static_config.yaml
Do not commit real SMTP credentials, JWT private keys, database passwords, or production
hostnames into repository files. Use the deployment platform's secret store.