8.8 Security — edge login, the gateway, sign-in, IAM and secrets¶
FeeCheck's security, layer by layer from the browser inwards. The API gateway becomes the only
service that accepts requests from the internet and takes the sign-in over from the backend
(ADR-0010 (docs/adr/adr-0010-api-gateway-and-api-contract.md)); the Status column says
which layer is built.
| Layer | What it does | Where it is | Source | Status |
|---|---|---|---|---|
| Edge login | Cloudflare Access logs the person in before any request is forwarded, so an anonymous request starts no Cloud Run instance. A Cloudflare Worker exchanges the Access token through Workload Identity Federation — no key — for an ID token of a service account that holds only roles/run.invoker on feecheck, and forwards the request with it |
PUBLIC_APP_URL, the web app's public address; edge/feecheck-app/worker.js (edge/feecheck-app/worker.js) |
Cloudflare edge login guide (docs/guides/cloudflare-edge-login.md); ADR-0010 §3 point 3 |
built |
| One public service | Only the gateway accepts requests from the internet; the backend grants the invoker role to the gateway's service account | the gateway's Cloud Run service | ADR-0010 | planned |
| IAM-only services | feecheck and docling-serve keep Cloud Run's IAM check: a request without an ID token of an allowed service account is refused with 403; allUsers is never granted (organization policy). The backend calls docling-serve with its own ID token (intake.docling.auth=google-id-token). Whether /mcp keeps an IAM path of its own is open |
Cloud Run, europe-west6 |
ADR-0006 (docs/adr/adr-0006-services-on-google-cloud.md), ADR-0010 §3 point 1; 7.1.2 |
built |
| Sign-in | Spring Security's OIDC code flow against Google, with an allowlist of accounts checked on every request. The person lives in a server-side session behind an HttpOnly cookie; no token reaches the browser (spec 100 AC-2). Without a session /api/** answers 401, every other path leads to /sign-in; a refused account lands on /no-access. The provider stays configuration |
in the backend: the signin module, SignInConfiguration, AllowedAccounts, GET /api/me; at the gateway the same flow, allowlist and session |
ADR-0008 (docs/adr/adr-0008-google-sign-in-and-backend-on-cloud-run.md); ADR-0010 supersedes ADR-0008's sign-in in the backend |
built in the backend; at the gateway planned |
| Roles | Reviewer and approver come from two configured lists of Google addresses, held as secrets like the allowlist; an admitted account on a list gets ROLE_REVIEWER or ROLE_APPROVER at sign-in, and the allowlist stays the gate |
the signin module, Roles, GET /api/me |
ADR-0015 (docs/adr/adr-0015-reviewer-and-approver-roles.md) |
built in the backend |
| Token relay | The backend is a resource server: a call without a valid token of the signed-in person is refused, so being inside the network is not enough | the backend, behind the gateway | ADR-0010 | planned |
| Forwarded headers | Redirects name the public host from X-Forwarded-Host and X-Forwarded-Proto; how the backend handles them is in the sign-in setup guide (docs/guides/google-sign-in-setup.md) |
the backend's sign-in configuration | — | built |
| Push token check | The queue's push endpoints accept a push only with a Google-signed OIDC token for the configured audience, issued to the push subscription's own service account (PushTokenCheck); the check is on in the Cloud Run profile only, because the emulator signs no token |
the consumer module, CasePushController, PushTokenCheck; with the event backbone the inbound push adapter in cases (8.16.3) |
ADR-0009 (docs/adr/adr-0009-async-intake-pubsub-bucket-firestore.md) §5, spec 264 (docs/specs/264-google-case-adapters.md) |
built |
| Secrets | The sign-in's Google client secret, the allowlist and the Mistral key are held in Secret Manager and mounted into the backend as environment variables when an instance starts; never in the image, the workflow or the log | --update-secrets in the deploy job of build.yml (.github/workflows/build.yml) |
7.1.2 | built |
| Deploy identity | The deploy jobs sign in to Google Cloud through Workload Identity Federation, with no long-lived key; the website's job as a service account that may only deploy Hosting | build.yml, site.yml |
deploy guide (docs/guides/feecheck-cloud-run.md); website guide (docs/guides/website-firebase-hosting.md) |
built |
| What the database holds | The tables carry contract content and a person's address: case_pages.markdown is the converted contract, page by page, and cases.uploader is the verified email of the person who uploaded it, and the case's result holds the extracted values. The data is synthetic in every environment, and a case is kept until a reviewer or an approver soft-deletes it, its rows and pages staying after that too, so the contract text stays in the table (8.3); cases.deleted_by is the email of the person who deleted it; the database is therefore treated as holding contract content, and no test or log copies a row |
the case database | ADR-0013, ADR-0006 | built |
| Database network and sign-in | The Cloud SQL instance has a private IP only; the backend reaches it through Cloud Run's direct VPC egress and the Cloud SQL Java connector, and signs in by IAM database authentication as its runtime service account, so there is no password to keep. The runtime role holds cloudsqlsuperuser, which the first migration needs for the vector extension and which also lets the running service change the schema: a trade-off for development and test, to be narrowed (ADR-0013 (docs/adr/adr-0013-postgresql-on-cloud-sql.md) open point 8) |
the instance, the backend's runtime account | ADR-0013 | built |
| No contract content in the database's logs | NFR-4 on the database side, because a logged statement carries the contract text it writes. As the instance is created, only the IAM authentication flag is set, so statement logging, pgaudit and Query Insights stay at the Cloud SQL defaults, which are off; this is the create command's state, not a live reading of the instance. The rule: none of them is switched on, and Query Insights, if it ever is, runs without query parameters |
the instance's flags | NFR-4, G-6 in 8.2 | built |
| No contract content in a log | holds for every layer above, the gateway included | every logger; ExtractionLogTest for the extraction path |
G-6 in 8.2 | built for the extraction path |