Status: the Tuturuuu routes, storage, login confirmation, settings row and
Meet read route are implemented. Linking starts working once the
upskii app is registered and
Upskii ships its side. The catalog lists Upskii as internal early access.Decision
Link ceremony
Upskii starts every link, because Upskii owns the data being shared and shows the consent. The Tuturuuu Connect button opens Upskii settings.- In Upskii settings, the signed-in Upskii user
Uchooses Connect Tuturuuu account, which submits a CSRF-protectedPOST. Upskii shows the three read scopes. Its server then sets a__Host-cookie (HttpOnly,Secure,SameSite=Lax,Path=/, 10 minutes) holding{ state, U, sessionId, code_verifier }, sealed with an Upskii server key (AEAD). It redirects to the Tuturuuu login with its registered callback asreturnUrl(carryingstate), pluscode_challengeandcode_challenge_method=S256. - Tuturuuu shows a confirmation before it issues any handoff for an app whose grant is a link-only scope: the signed-in account, the app, what the link shares, Continue as, and Use another account. Such an app never auto-continues, even with strict PKCE. A user who is not signed in signs in first, which is the same explicit choice.
- The Upskii callback answers with
Referrer-Policy: no-referrer, keeps the token URL out of logs and analytics, and redirects as soon as it finishes. It opens the sealed cookie and refuses the link when the cookie is missing, expired or tampered, whenstatedoes not match (constant-time compare), or when the current Upskii session is notUandsessionId(LINK_SESSION_MISMATCH). It then callsPOST /api/v1/auth/app-token/exchangewith theupskiiapp id and secret, the token,codeVerifier, andrequestedScopes: ["upskii-link:write"]. - An exchange that issues a link-only scope returns a bearer that carries only
link scopes, lives at most 120 seconds, and comes with no refresh token.
With it, Upskii calls
POST /api/v1/integrations/upskii/linkwith{ upskiiUserId, upskiiEmail, scopes }. Tuturuuu checks that the bearer belongs to the enabledupskiiapp, carriesupskii-link:writeand postdates the app’s current secret. It applies the staff gate and stores the link for the bearer’s user, never a user named in the body. Each bearer links once: itsjtiis recorded on the row (link_jti, unique), and a later request with the same bearer gets401 LINK_BEARER_USED. - Upskii stores its own row
{ U, tuturuuuUserId, linkId, scopes, linkedAt }and discards the bearer.
upskii-link:write.
Registry settings for the upskii app: requirePkce=true (only after
migration 20261101090000 is confirmed applied in production),
callbackPaths: ["/api/upskii/integrations/tuturuuu/callback"] and
allowedScopes: ["upskii-link:write"].
The handoff confirmation is enforced by the login page, not by a
server-side nonce. A server nonce would add a second store and round trip,
while PKCE and Upskii’s sealed state already bind the handoff to the browser
that started it.
Mismatch and conflict handling
Storage
Tuturuuu storesprivate.external_account_links
(migration 20261124052100_external_account_links.sql), one row per link:
id, user_id (references auth.users with on delete cascade), provider
(upskii only), external_subject (the Upskii user id), external_email,
scopes (read scopes only), linked_at, revoked_at, revoked_by (user,
provider or admin). Partial unique indexes on (user_id, provider) and
(provider, external_subject) apply only while revoked_at is null; a plain
index on user_id keeps account deletion from scanning revoked history. The
migration runs with a 5-second lock timeout so it never queues sign-ins behind
the auth.users foreign key. RLS is
on with no policies; anon and authenticated have no access, and
service_role has select, insert and update only, so history cannot be
deleted through the API. Revoking a link clears external_email; the revoked
row keeps ids and times as the history.
Upskii stores the matching row in its own database. Neither row holds a token.
Routes
The app secret is read only from the
Authorization header, never from a
body. Each route admits requests per client IP and per app and secret digest
before the credential check. It paces failed secrets per app and IP, logs
every refused credential with console.warn, and counts verified calls per
app (and per user for link writes). Over a limit it answers 429 with
Retry-After.
Disconnect
- From Tuturuuu:
DELETE /api/v1/integrations/upskii/linksetsrevoked_by = 'user'. Reads stop at once, because Tuturuuu mints read tokens only for an active link and introspection answersactive: false. - From Upskii: Upskii deletes its row, then calls the unlink route with
{ linkId, upskiiUserId }. Tuturuuu setsrevoked_by = 'provider'. If that call fails, reads still stop, because Upskii refuses a link it no longer holds; Upskii retries the call. - Upskii learns of a Tuturuuu disconnect when introspection of a validly
signed token answers
active: falsewithrevoked: { linkId, upskiiUserId }, or the unlink route answersLINK_NOT_FOUND. It then deletes exactly that row. An invalid token never names a link, so it cannot delete anyone’s row. - Account deletion: deleting the Tuturuuu account deletes its links. Deleting an Upskii account calls the unlink route first.
- Secret rotation or disabling the app stops every read at once. Links stay stored and resume when the app works again.
Secret rotation runbook
The Upskii app secret lives only in Upskii’s server environment, never in aNEXT_PUBLIC_ or other client-exposed variable.
- Rotate the secret in Infrastructure → External apps (root admin). This also signs out every Upskii session that used Tuturuuu sign-in.
- Put the new secret in Upskii’s server secret store and deploy. Until then,
unlink and introspect answer
401, so Meet cannot read Upskii content. Links themselves are unaffected. - Confirm with one introspect call from Upskii’s server, then a Meet read.
Read API contract (for Meet)
Meet calls one server-only route with the user’s session:GET /api/v1/integrations/upskii/content?kind=classes|lessons|assessments&classId=<id>
- The link comes from the session user alone. The route takes no
userIdorlinkId, and clients never receive a read token or an Upskii credential. classIdis required forlessonsandassessments. Upskii authorises it against the introspectedupskiiUserIdand refuses a class the user cannot see.- Tuturuuu mints the read token server-side through
mintUpskiiReadTokenForUser, which re-checks the staff gate. It answers404 NOT_LINKED,403 EARLY_ACCESS_ONLYor403 SCOPE_NOT_GRANTED. - The Upskii base URL is pinned in server configuration, never taken from the
request, so the route cannot be pointed at another host. Production always
uses
https://app.upskii.com; other runtimes may setUPSKII_API_ORIGIN. - Listings cover what the linked user teaches: the classes they own or teach, and every lesson (including drafts) and assessment of one of those classes. Classes the user only attends as a learner are out of scope.
- Response:
{ items: Array<{ id, title, updatedAt, url, kind, classId? }> }, at most 100 items with titles cut to 300 characters; there is no paging yet. Eachurlmust be on Upskii’s exact origin with no credentials; anything else (includingjavascript:and other hosts) is dropped. Bodies and answers are never included. Upskii failures answer404 NOT_LINKED(Upskii confirmed the link is inactive),403 SCOPE_NOT_GRANTED(including an educator who is no longer eligible),404 CLASS_NOT_FOUNDor502 UPSKII_UNAVAILABLE. Anything Upskii could not answer or confirm (a timeout,429,5xxor a check Upskii could not make of this token) isUPSKII_UNAVAILABLE, neverNOT_LINKED, so an outage is not shown as an unlinked account. - In a Meet room only the presenter’s session fetches. Other participants see only what the presenter shares.
external_link_read token, not an
app-coordination bearer: target_app: "upskii", sub set to the Tuturuuu
user, one read scope, external-link:<linkId>, and for lessons and
assessments one upskii-class:<classId> scope naming the class it was minted
for. It expires 60 seconds after issue, with no clock-skew allowance. Introspection
returns that classId, and Upskii opens only that class with the token. The
token’s jti is not consumed: with the 60-second life and the class binding, a
captured token can only re-read one class’s metadata inside that minute. Consuming
it needs a shared store on the Upskii side and is a follow-up. Tuturuuu sends it to Upskii’s
GET /api/integrations/tuturuuu/v1/<kind>. Upskii checks it with the
introspect route, which answers
{ active, tuturuuuUserId, upskiiUserId, linkId, scopes, classId? }. The answer is
active only when the token is valid and unexpired, carries exactly one link
id, at most one class and only read scopes, and names an active link owned by its user that
still grants those scopes. Upskii serves the request only when its own row for
that linkId and user is still active.
Audit
Link, relink, disconnect and refused attempts are logged withconsole.info
or console.warn and the fields { event, provider, userId, linkId, side, reason }, with no emails or tokens. Revoked rows keep the history.
Regression coverage
apps/web/src/lib/integrations/upskii/link-service.test.ts: idempotent relink, bothLINK_CONFLICTsides, relink after disconnect, provider unlink limited to its own user and a valid link id, and read tokens refused when expired at 61 seconds, revoked mid-life, narrower than the link, naming another user’s link, carrying two link ids or an unknown scope, signed with another key, or replaced by an app bearer.apps/web/src/lib/integrations/upskii/read-token.test.ts: minting needs an active link, the staff gate and a granted scope, and a class-bound token names its class.link-service.test.tsalso covers a token naming two classes or an invalid class.apps/web/src/lib/integrations/upskii/access.test.ts: the staff gate (missing catalog entry, unconfirmed email, lookalike domain, QA account, another Azure tenant, failed lookup, explicitavailable) and Basic credential parsing.apps/web/src/app/api/v1/integrations/upskii/link/route.test.ts,unlink/route.test.tsandintrospect/route.test.ts: bearer and secret checks, credentials in the body ignored,429, write scopes, the staff gate, conflicts, a body naming another user, andLINK_NOT_FOUND.apps/web/src/lib/auth/external-app-exchange-response.test.ts: link-only exchanges get no refresh token and at most 120 seconds.apps/web/src/lib/app-coordination/link-only-scopes.test.ts: a link bearer is refused by every current-user session option and external-project mode, and only the link route names its scope.apps/web/src/app/[locale]/(auth)/login/login-view.server.test.tsandfocused-continue-step.test.tsx: a link app never auto-continues, and the confirmation names the link.packages/utils/src/app-coordination-token.test.ts: read tokens and app bearers never verify as each other.apps/web/src/lib/integrations/upskii/content.test.tsandapps/web/src/app/api/v1/integrations/upskii/content/route.test.ts: the pinned origin, links narrowed to Upskii’s origin, the item and title caps, status mapping, and a route that reads only for the session user.apps/database/supabase/tests/external-account-links.sql: RLS, noanonorauthenticatedaccess, noservice_roledelete, unique-active indexes, read-only scopes, and the account-deletion cascade.packages/satellite/src/components/account-settings/account-integrations-panel.test.tsx: the connect hand-off, coming soon, retry, and disconnect after confirmation.- Upskii: tampered or expired cookie, state mismatch,
LINK_SESSION_MISMATCH, no referrer leak, and a read refused for a deleted local row.