Part 2 of #260 (MVP-0.7), dashboard side. Closes#260 together with #302.
#302 is merged, and this PR is rebased onto main, so it is a single commit. Deploy order:platform/orca-platform#25 (merged; sets DASHBOARD_SESSION_KEY) must be deployed on the master first. A hardened dashboard refuses to start without the key.
Problem
The session cookie was signed with a key generated at every start, and sessions lived in process memory. Every redeploy logged everyone out.
Cookies weren't Secure.
/auth?redirect_url=https://evil.example sent the user to any site after a genuine login (open redirect).
Every GET /auth added an entry to an in-memory map that was never pruned. The endpoint is unauthenticated.
The webhook proxy forwarded to the agent's API port and dropped the tenant id, so it never worked.
Change
Mongo session store (session_store.rs, collection dashboard_sessions, TTL index on expires_at).
Sessions contain the user's Keycloak access and refresh tokens, so each record is sealed before it's written. It uses compliance_core::secret_box (moved there in #302) under the encryption half of DASHBOARD_SESSION_KEY; the signing half signs the cookie.
A database dump shows no token.
After a key change, old sessions read as "not logged in" rather than as errors.
Expired records don't load even before Mongo's TTL monitor removes them. Id collisions redraw the id instead of overwriting another user's session.
DASHBOARD_SESSION_KEY (128 hex characters, from openssl rand -hex 64) is required in staging and production, and a malformed key is refused everywhere. In dev a missing key is generated, with a warning.
Open redirect: only a single leading / path is accepted. https://…, //host, /\host, \\host, javascript:, and control characters (browsers strip tabs and newlines, so /\t/host becomes //host) all fall back to /. The check runs at login and again at the callback.
Pending logins: a 10-minute expiry and a 10,000 cap (oldest dropped first). Constant-time lookup; the queue is only pruned from the front.
Webhook proxy removed. Webhooks come back end to end in #305. Agent-side receivers already fail closed (#302).
Verification
cargo fmt --check and clippy -D warnings pass on all CI targets.
Dashboard tests pass: 28 (server) and 16 (web).
New tests:
The redirect sanitizer, including every external-URL case above.
Pending logins: taken once, expire, capped.
Session key: required when hardened, malformed keys refused, deterministic halves.
sessions_survive_in_mongo_sealed_until_they_expire, against a real Mongo (it skips within 2 s when none is reachable, as in CI):
a new store instance, standing in for a restart, loads the session;
the stored document is enc:v1:… and doesn't contain the token;
an expired record doesn't load;
another key reads it as "not logged in";
delete works.
Real binary:
APP_ENV=staging without the key gives DASHBOARD_SESSION_KEY is required in staging.
In dev with a key it starts and creates the TTL index (expires_at_1, expireAfterSeconds 0).
/auth?redirect_url=https://evil.example still goes to Keycloak, with the URL dropped.
POST /webhook/github/… gives 405 (route gone).
A full browser login needs a Keycloak, which I don't have locally, so the session round trip is covered by the Mongo test and needs a check on staging after deploy.
Part 2 of #260 (MVP-0.7), dashboard side. Closes #260 together with #302.
> #302 is merged, and this PR is rebased onto `main`, so it is a single commit.
> **Deploy order:** platform/orca-platform#25 (merged; sets `DASHBOARD_SESSION_KEY`) must be deployed on the master first. A hardened dashboard refuses to start without the key.
## Problem
- The session cookie was signed with a key generated at every start, and sessions lived in process memory. **Every redeploy logged everyone out.**
- Cookies weren't `Secure`.
- `/auth?redirect_url=https://evil.example` sent the user to any site after a genuine login (**open redirect**).
- Every `GET /auth` added an entry to an in-memory map that was never pruned. The endpoint is unauthenticated.
- The webhook proxy forwarded to the agent's API port and dropped the tenant id, so it never worked.
## Change
- **Mongo session store** (`session_store.rs`, collection `dashboard_sessions`, TTL index on `expires_at`).
- Sessions contain the user's Keycloak access and refresh tokens, so each record is **sealed** before it's written. It uses `compliance_core::secret_box` (moved there in #302) under the encryption half of `DASHBOARD_SESSION_KEY`; the signing half signs the cookie.
- A database dump shows no token.
- After a key change, old sessions read as "not logged in" rather than as errors.
- Expired records don't load even before Mongo's TTL monitor removes them. Id collisions redraw the id instead of overwriting another user's session.
- **`DASHBOARD_SESSION_KEY`** (128 hex characters, from `openssl rand -hex 64`) is required in staging and production, and a malformed key is refused everywhere. In dev a missing key is generated, with a warning.
- **Cookies:** `Secure` outside dev, `HttpOnly`, `SameSite=Lax`.
- **Open redirect:** only a single leading `/` path is accepted. `https://…`, `//host`, `/\host`, `\\host`, `javascript:`, and control characters (browsers strip tabs and newlines, so `/\t/host` becomes `//host`) all fall back to `/`. The check runs at login and again at the callback.
- **Pending logins:** a 10-minute expiry and a 10,000 cap (oldest dropped first). Constant-time lookup; the queue is only pruned from the front.
- **Webhook proxy removed.** Webhooks come back end to end in #305. Agent-side receivers already fail closed (#302).
## Verification
- `cargo fmt --check` and clippy `-D warnings` pass on all CI targets.
- Dashboard tests pass: 28 (server) and 16 (web).
- New tests:
- The redirect sanitizer, including every external-URL case above.
- Pending logins: taken once, expire, capped.
- Session key: required when hardened, malformed keys refused, deterministic halves.
- `sessions_survive_in_mongo_sealed_until_they_expire`, against a real Mongo (it skips within 2 s when none is reachable, as in CI):
- a new store instance, standing in for a restart, loads the session;
- the stored document is `enc:v1:…` and doesn't contain the token;
- an expired record doesn't load;
- another key reads it as "not logged in";
- delete works.
- Real binary:
- `APP_ENV=staging` without the key gives `DASHBOARD_SESSION_KEY is required in staging`.
- In dev with a key it starts and creates the TTL index (`expires_at_1`, expireAfterSeconds 0).
- `/auth?redirect_url=https://evil.example` still goes to Keycloak, with the URL dropped.
- `POST /webhook/github/…` gives 405 (route gone).
- A full browser login needs a Keycloak, which I don't have locally, so the session round trip is covered by the Mongo test and needs a check on staging after deploy.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
- Sessions survive a redeploy. They are stored in Mongo (`dashboard_sessions`,
with a TTL index) instead of process memory, and the cookie is signed with
DASHBOARD_SESSION_KEY instead of a key generated at startup. A hardened
dashboard refuses to start without the key. In dev a missing key is
generated.
- Sessions hold the user's Keycloak access and refresh tokens, so each record
is sealed (`compliance_core::secret_box`) with the key's encryption half.
The signing half signs the cookie. A record that no longer opens after a key
change reads as "not logged in".
- Cookies are Secure outside dev, HttpOnly and SameSite=Lax.
- `/auth?redirect_url=` accepts only same-site paths. `https://…`, `//host`,
`/\host` and control characters fall back to `/`.
- Pending logins expire after 10 minutes and are capped at 10,000. `/auth` is
unauthenticated, and the map used to grow on every request.
- The webhook proxy is removed. It sent deliveries to the API port without the
tenant id, so it never worked. Webhooks return with #305.
Part 2 of #260 (dashboard). Stacked on #302.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Part 2 of #260 (MVP-0.7), dashboard side. Closes #260 together with #302.
Problem
Secure./auth?redirect_url=https://evil.examplesent the user to any site after a genuine login (open redirect).GET /authadded an entry to an in-memory map that was never pruned. The endpoint is unauthenticated.Change
session_store.rs, collectiondashboard_sessions, TTL index onexpires_at).compliance_core::secret_box(moved there in #302) under the encryption half ofDASHBOARD_SESSION_KEY; the signing half signs the cookie.DASHBOARD_SESSION_KEY(128 hex characters, fromopenssl rand -hex 64) is required in staging and production, and a malformed key is refused everywhere. In dev a missing key is generated, with a warning.Secureoutside dev,HttpOnly,SameSite=Lax./path is accepted.https://…,//host,/\host,\\host,javascript:, and control characters (browsers strip tabs and newlines, so/\t/hostbecomes//host) all fall back to/. The check runs at login and again at the callback.Verification
cargo fmt --checkand clippy-D warningspass on all CI targets.sessions_survive_in_mongo_sealed_until_they_expire, against a real Mongo (it skips within 2 s when none is reachable, as in CI):enc:v1:…and doesn't contain the token;APP_ENV=stagingwithout the key givesDASHBOARD_SESSION_KEY is required in staging.expires_at_1, expireAfterSeconds 0)./auth?redirect_url=https://evil.examplestill goes to Keycloak, with the URL dropped.POST /webhook/github/…gives 405 (route gone).🤖 Generated with Claude Code
https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
bea08d2dbftoe93e4a43e9