Repository navigation
store: rekey authors to the signed principal at sign-in (no issuer required) - #13
Merged
Merged
Conversation
The startup backfill needs the historical issuer of every legacy subject, which ink cannot prove (the old schema never stored it). A wrong issuer would compute wrong principals and silently detach every user from their author. Sign-in delivers the signed principal next to the verified bearer subject, so RekeyAuthorOnSignIn binds the legacy row to that principal in one write transaction; already-keyed authors cost one SELECT. A principal already linked to a different subject is a 409 author_principal_conflict. MEMO_LEGACY_OIDC_ISSUER is now optional: unset skips the backfill; set keeps it for operators who can prove the issuer. Un-rekeyed rows are inert.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Identity.Access.Principaltogether with its verifiedIdentity.Principal.Subject.Do not derive caller principals from an unproven historical issuer.
principal IS NULLcan beselected by subject and rekeyed, under a row lock in one write transaction.
Retain author ULIDs, articles, likes, follows, and Directory links.
still refresh changed OIDC profile fields; Directory names stay authoritative.
Ownership and social actions keep using the resolved author ULID, and platform
role checks are unchanged.
violation: HTTP 409,
author_principal_conflict,The signed principal is already linked to another author.MEMO_LEGACY_OIDC_ISSUERoptional. Unset/empty skips startup backfill andleaves legacy principals NULL; the existing explicit-issuer backfill remains
available only when the historical issuer can be proven.
instructions. No module version change or new migration is needed.
Deployment
signed-principal prerequisite remains). Record the old Memo image and take a
PostgreSQL backup; retain both through the rollback window.
environment variable is required. Mixed-version rollout is still disallowed:
old binaries continue writing subject-keyed rows.
Directory link, existing likes/follows, and owner/admin restrictions. Authors
who do not sign in remain inert with NULL principals; their published content
and relationships are preserved, and they do not block startup.
Optional: if an operator can prove the exact issuer of every historical
subject, set
MEMO_LEGACY_OIDC_ISSUERfor the existing transactional startupbackfill and remove it after verification. The old schema never recorded issuer;
do not guess from the current URL or email. Unknown/mixed histories should use
lazy rekeying without this setting.
Rollback (unchanged)
historical subject. In one transaction drop
authors.principal, restoreauthors.subject NOT NULL, and remove only002_author_principal.sqlfrommemo_schema_migrations. Restart the recorded old image. IDs and relationshipsremain intact.
writes with a backup. New rows contain only a principal; SHA-256 is not
reversible. Obtain a verified issuer/subject crosswalk, match it using the
exact platform hash, stop writers, populate only missing legacy subjects, and
verify complete/unique subjects before the same rollback. If a mapping is
unknown or two issuers share a subject, retain all data and use a forward fix.
Do not invent subjects or discard rows.
This app binary still requires a #7087-capable platform.
Full operator instructions: README, “Signed author keys: upgrade and rollback”.
Verification
Using
~/.codex/skills/serialize-vm-tests/scripts/serialize-vm-tests --withSERIALIZE_VM_TESTS_TARGET=local:go build ./...— PASS (exit 0), via the wrapper's--class shortadmission.go vet ./cmd/server/...— PASS (exit 0).go test ./cmd/server/... -count=1— PASS (exit 0), including real PostgreSQLstore tests and the SDK OIDC/exchange/signature API path.
failed with the previous mandatory
MEMO_LEGACY_OIDC_ISSUERstartup error.neither build nor vet executed in that attempt. The successful build used the
documented short-job class for this small Go module, without bypassing the
wrapper's pressure admission or locks.
BUILTIN_APPSERVER_TEST_DATABASE_URLpointed only to the task-local PostgreSQLserver through
.tmp/rekey-pg-socket(port 55439); the integration tests did notskip for lack of a database. Per-test schemas were isolated and cleaned. The
server was stopped and its task-owned data, socket directory, and logs removed.
Coverage includes stable ULIDs and relationships, no repeat author write
(
xminunchanged), principal-first lookup, rejection of subject fallback forrekeyed authors, sequential/concurrent conflicting claims, the real principal
unique constraint, concurrent same-subject sign-in, optional issuer startup,
explicit backfill, and unchanged owner/admin/social restrictions.
No commit, push, tag, publication, or live cluster access was performed.