2 minutes

34. Bind Google Drive access to the owner session

Date: 2026-10-12

Status

Proposed

Context

The BFF runs Auth0 sign-in as optional, so no API route requires a signed-in user. It runs its own Google OAuth flow and keeps the resulting tokens on one client shared by the whole process. Once the owner has connected Google, any caller who reaches the API can list, download and publish the owner’s files. That flow asks for read and write access to the whole Drive, sends no state value on the callback, and keeps the tokens only in memory, so they are lost on every scale-to-zero restart.

The full analysis, with three options, is in the ArcKit record ARC-001-ADR-002 (projects/001-unicorn/decisions/ in the workspace).

Decision

We will require Auth0 sign-in on every API route and allow only the owner’s Auth0 account.

The Google Drive consent runs once per session, with state and PKCE, and asks only for read-only Drive access.

The Google tokens are stored per session on the server, through a new Dapr state component sessionstore scoped to the BFF, with a 24-hour expiry. Redis backs it locally and Cosmos DB in Azure. Each request builds its own Drive client from its session.

The rename endpoint goes away: exports are processed as Markdown whatever their extension. The session cookie is Secure, HttpOnly and SameSite=Lax, signed with a key from Key Vault (ADR 0033).

ADR 0014 still holds: Auth0 signs the owner in and Google grants Drive access.

--- config: look: handDrawn theme: neutral --- graph LR O[Owner] -->|sign in| A[Auth0] O --> B[BFF] B -->|owner only| A B -->|read-only consent| G[Google Drive] B -->|tokens per session| S[sessionstore]

Consequences

Only the owner can list and publish files, and the BFF holds read-only Drive access instead of read and write. Tokens survive restarts and never leave the server. Read-only access still covers the whole Drive; a service account limited to the export folder is the next step if that becomes a concern. The owner signs in once a day. The old Google grant must be revoked in the owner’s account before deploying. Requirement FR-003 and data model entity E-007 change, and the sessionstore component must be added to the IcePanel model with its connection tagged.