feat: update authentication configuration and documentation for local and Clerk modes
This commit is contained in:
@@ -89,16 +89,12 @@ This table is based on `backend/app/core/config.py`, `.env.example`, `backend/.e
|
|||||||
|---|---:|---|---|---|
|
|---|---:|---|---|---|
|
||||||
| `NEXT_PUBLIC_API_URL` | **yes** | Backend base URL used by the browser | `http://localhost:8000` | Must be browser-reachable |
|
| `NEXT_PUBLIC_API_URL` | **yes** | Backend base URL used by the browser | `http://localhost:8000` | Must be browser-reachable |
|
||||||
| `NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY` | **yes** | Enables Clerk in the frontend | (none) | Must be a real publishable key |
|
| `NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY` | **yes** | Enables Clerk in the frontend | (none) | Must be a real publishable key |
|
||||||
| `CLERK_SECRET_KEY` | **yes** | Clerk secret key used by the frontend (server-side) and E2E | (none) | Do not commit; required for Clerk-enabled operation |
|
|
||||||
| `NEXT_PUBLIC_CLERK_SIGN_IN_FORCE_REDIRECT_URL` | optional | Post-login redirect | `/boards` | — |
|
|
||||||
| `NEXT_PUBLIC_CLERK_SIGN_UP_FORCE_REDIRECT_URL` | optional | Post-signup redirect | `/boards` | — |
|
|
||||||
| `NEXT_PUBLIC_CLERK_SIGN_IN_FALLBACK_REDIRECT_URL` | optional | Fallback redirect | `/boards` | — |
|
| `NEXT_PUBLIC_CLERK_SIGN_IN_FALLBACK_REDIRECT_URL` | optional | Fallback redirect | `/boards` | — |
|
||||||
| `NEXT_PUBLIC_CLERK_SIGN_UP_FALLBACK_REDIRECT_URL` | optional | Fallback redirect | `/boards` | — |
|
|
||||||
| `NEXT_PUBLIC_CLERK_AFTER_SIGN_OUT_URL` | optional | Post-logout redirect | `/` | — |
|
| `NEXT_PUBLIC_CLERK_AFTER_SIGN_OUT_URL` | optional | Post-logout redirect | `/` | — |
|
||||||
|
|
||||||
## Operational footguns
|
## Operational footguns
|
||||||
|
|
||||||
- **Clerk placeholder keys**: `frontend/.env.example` contains non-empty Clerk placeholders. `compose.yml` intentionally does **not** load it, because it can accidentally flip Clerk “on”. Prefer user-managed `frontend/.env` (for Compose) or `frontend/.env.local` (for Next dev).
|
- **Frontend env template vs runtime env**: `frontend/.env.example` is a template and `compose.yml` intentionally does **not** load it at runtime. Use user-managed `frontend/.env` (for Compose) or `frontend/.env.local` (for Next dev).
|
||||||
- **`DB_AUTO_MIGRATE`**:
|
- **`DB_AUTO_MIGRATE`**:
|
||||||
- In `ENVIRONMENT=dev`, backend defaults `DB_AUTO_MIGRATE=true` if you didn’t set it explicitly.
|
- In `ENVIRONMENT=dev`, backend defaults `DB_AUTO_MIGRATE=true` if you didn’t set it explicitly.
|
||||||
- In production, consider disabling auto-migrate and running migrations as an explicit step.
|
- In production, consider disabling auto-migrate and running migrations as an explicit step.
|
||||||
|
|||||||
@@ -15,7 +15,9 @@ When running Compose, you get:
|
|||||||
- Health check: `GET /healthz`
|
- Health check: `GET /healthz`
|
||||||
- **Frontend UI** (Next.js) on `http://localhost:${FRONTEND_PORT:-3000}`
|
- **Frontend UI** (Next.js) on `http://localhost:${FRONTEND_PORT:-3000}`
|
||||||
|
|
||||||
Auth (Clerk) is **required** right now. You must configure Clerk keys for the frontend and backend (`CLERK_SECRET_KEY`).
|
Auth is configurable per deployment:
|
||||||
|
- `AUTH_MODE=local` (self-host default; shared bearer token)
|
||||||
|
- `AUTH_MODE=clerk` (Clerk JWT auth; backend requires `CLERK_SECRET_KEY`)
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
@@ -86,7 +88,7 @@ These persist across `docker compose down`.
|
|||||||
### Root `.env` (Compose)
|
### Root `.env` (Compose)
|
||||||
|
|
||||||
- Copy the template: `cp .env.example .env`
|
- Copy the template: `cp .env.example .env`
|
||||||
- Edit values as needed (ports, Clerk URLs/keys, etc.)
|
- Edit values as needed (ports, auth mode, tokens, API URL, etc.)
|
||||||
|
|
||||||
Compose is invoked with:
|
Compose is invoked with:
|
||||||
|
|
||||||
@@ -158,7 +160,6 @@ Create `frontend/.env` with at least:
|
|||||||
NEXT_PUBLIC_AUTH_MODE=clerk
|
NEXT_PUBLIC_AUTH_MODE=clerk
|
||||||
NEXT_PUBLIC_API_URL=http://localhost:8000
|
NEXT_PUBLIC_API_URL=http://localhost:8000
|
||||||
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=pk_test_your_real_key
|
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=pk_test_your_real_key
|
||||||
CLERK_SECRET_KEY=sk_test_your_real_key
|
|
||||||
```
|
```
|
||||||
|
|
||||||
**Security:** treat `LOCAL_AUTH_TOKEN` and `CLERK_SECRET_KEY` like passwords. Do not commit them.
|
**Security:** treat `LOCAL_AUTH_TOKEN` and `CLERK_SECRET_KEY` like passwords. Do not commit them.
|
||||||
|
|||||||
@@ -9,9 +9,5 @@ NEXT_PUBLIC_AUTH_MODE=local
|
|||||||
|
|
||||||
# Clerk auth (used when NEXT_PUBLIC_AUTH_MODE=clerk)
|
# Clerk auth (used when NEXT_PUBLIC_AUTH_MODE=clerk)
|
||||||
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=
|
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=
|
||||||
CLERK_SECRET_KEY=
|
|
||||||
NEXT_PUBLIC_CLERK_SIGN_IN_FORCE_REDIRECT_URL=/boards
|
|
||||||
NEXT_PUBLIC_CLERK_SIGN_UP_FORCE_REDIRECT_URL=/boards
|
|
||||||
NEXT_PUBLIC_CLERK_SIGN_IN_FALLBACK_REDIRECT_URL=/boards
|
NEXT_PUBLIC_CLERK_SIGN_IN_FALLBACK_REDIRECT_URL=/boards
|
||||||
NEXT_PUBLIC_CLERK_SIGN_UP_FALLBACK_REDIRECT_URL=/boards
|
|
||||||
NEXT_PUBLIC_CLERK_AFTER_SIGN_OUT_URL=/
|
NEXT_PUBLIC_CLERK_AFTER_SIGN_OUT_URL=/
|
||||||
|
|||||||
@@ -70,8 +70,8 @@ For `local` mode:
|
|||||||
For `clerk` mode, configure:
|
For `clerk` mode, configure:
|
||||||
|
|
||||||
- `NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY`
|
- `NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY`
|
||||||
- `CLERK_SECRET_KEY`
|
- optional `NEXT_PUBLIC_CLERK_SIGN_IN_FALLBACK_REDIRECT_URL`
|
||||||
- optional Clerk redirect env vars
|
- optional `NEXT_PUBLIC_CLERK_AFTER_SIGN_OUT_URL`
|
||||||
|
|
||||||
## How the frontend talks to the backend
|
## How the frontend talks to the backend
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user