Repository navigation
Conversation
… open Entering edit mode ran the full Ory Hydra + data-proxy STS mint on every enable, after a 100ms artificial delay, and switching to "Read Only" discarded credentials that were still valid for up to an hour. The provider now keeps minted credentials per scope until they have under 15 minutes left, shares an in-flight mint between callers, and pressing the edit-mode menu trigger starts the mint so it is usually finished by the time "Edit Mode" is chosen. readProxyCredentials accepts the identity of an already-resolved session, which spares getTemporaryCredentials and deleteProduct a second Ory whoami. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Claude finished @alukach's task in 20s —— View job ✅ No blocking issues — safe to merge. The cache logic holds up. Concurrent mints are shared through Non-blocking notes
Simplify (ponytail)
DocsThe description names ADR 004 and ADR 005 and 💰 Estimated review cost: $0.15 · 0m19s · 5 turns |
The upload SDK's credential provider called getTemporaryCredentials directly, so the first upload after entering edit mode minted again; it now uses the provider's cache, which re-mints below 15 minutes left. View Credentials goes through the cache too, so it never shows keys from a cache hit that have since expired. getTemporaryCredentials hands out the cookie's credentials only with at least 15 minutes left, matching the browser's floor, so a re-mint can't return the same short-lived keys. The prefetch moves from onPointerDown to the menu's onOpenChange, which covers keyboard opens and ignores pointer-downs that open nothing, and clearAllCredentials now empties the cache as well. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Not sufficiently performant |
Why
Turning on Edit Mode is slow. Every enable ran
getTemporaryCredentials, which on a cookie miss drives a server-side Ory Hydra authorization-code flow (4–6 sequential HTTP calls through the admin API) and then a data-proxy/.stsAssumeRoleWithWebIdentity. Four things made it worse than it needs to be. The client waited a deliberate 100ms before calling the action. Switching to "Read Only" threw away credentials that were still valid for up to an hour, so the next enable minted again. The upload SDK's credential provider called the action directly, so the first upload after entering edit mode minted once more. And the action resolved the Ory session twice: once ingetPageSession, again insidereadProxyCredentials.What changes
CredentialsProviderkeeps minted credentials in a ref-held cache per scope and reuses them while they have at least 15 minutes left. "Read Only" still takes the scope out of edit mode but keeps the credentials, so re-enabling within the hour is instant. In-flight mints are shared, so concurrent callers mint once.clearAllCredentialsempties the cache too. The 100ms sleep is gone.loadCredentialsbacks the upload SDK's credential provider inUploadProvider, and its 15-minute floor sits above the SDK's own 5-minute refresh window, so long uploads still rotate before expiry. "View Credentials" also goes through it, so it re-mints rather than showing keys about to expire.prefetchCredentialswarms the cache without turning edit mode on.FetchCredentialsButtoncalls it from the menu'sonOpenChange, which covers pointer and keyboard opens and nothing else, so the mint runs while the user reads the menu. A failed prefetch is silent: a click that joins the failing mint reports the failure, and the next click mints again.getTemporaryCredentialshands out thesc_proxy_credscookie's credentials only if they have at least 15 minutes left, matching the browser's floor, so a re-mint never returns the same short-lived keys.readProxyCredentials(sessionIdentityId?)takes the identity of an already-verified session and skips its own whoami.getTemporaryCredentialsanddeleteProductpasssession.identity_id; render-path callers are unchanged.Known tradeoffs
getTemporaryCredentials'WriteRepositoryDatacheck. If write access is revoked mid-session, the UI can show edit mode until the credentials near expiry. The data proxy authorizes every request itself (ADR-005), so the writes are refused all the same.Considered and rejected
A review across performance, security and OAuth practice ruled out:
/.stsrepeatedly, making it a credential that mints credentials, and it would usually expire before the user opened Edit Mode anyway.sc_proxy_credscookie on mint ingetTemporaryCredentials. In Next 15.5,cookies().setin an action marks the path revalidated, so every mint, including the upload SDK's hourly refresh, would re-render the product page server-side.FetchCredentialsButtonsits in the[[...path]]layout and remounts on every folder navigation. That would cost a whoami plus DB reads per click, and a full mint for writers who never use Edit Mode.DurationSeconds. Issued credentials can't be revoked short of rotating the proxy's signing key, and logout only clears the cookie.The larger win, replacing the Hydra admin-API flow with an app-signed short-lived JWT the proxy trusts, moves an ADR-004 decision and is proposed separately in data.source.coop#249 (ADR-015).
Docs and ADRs
Checked the data-proxy ADRs: 004 (STS) and 005 (authorization) still describe the model. Credentials are still minted the same way and still cover the user, and this PR only changes how long the browser keeps them. Checked docs.source.coop
docs/using-source/; the upload flow a user walks through is unchanged.Storybook
FetchCredentialsButtonhas no story and renders in none, and nothing changes visually. The only UI difference is when the mint starts.Testing
As of 8427eb0:
npm run type-checkpasses.npm run lintshows no new warnings in the touched files.jest --forceExitonsrc/lib/actions/credentials.test.ts,src/lib/services/proxy-credentials-read.test.ts,src/lib/actions/products.test.ts,src/lib/services/upload-queue-manager.test.tsandsrc/components/features/uploader: 51 tests pass. New cases cover:clearAllCredentialsforgetting it🤖 Generated with Claude Code