Repository navigation
feat(store): scope notes and settings per user - #25
Merged
Merged
Conversation
The notes and settings tables had no user dimension and the config has no allowlist, so any authenticated user could read and write every note of the instance. Add versioned migrations (PRAGMA user_version as the source of truth, embedded with embed.FS) with a verified VACUUM INTO backup taken before they run. Migration 002 adds the user column to notes and rebuilds settings with a (user, key) primary key; rows that predate the change are backfilled to OCNOTES_OWNER, and the service refuses to start without it rather than leave them invisible. The scoping key is the user's stable graph id, not the username: this deployment returns a null userPrincipalName, which made the username an empty string for every user. Every note and settings operation is now scoped, and cross-user access behaves as not-found. Closes #24
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.
Closes #24.
The notes and settings tables had no user dimension and the config has no allowlist, so any authenticated user could read and write every note of the instance (verified in the SQL).
Adds versioned migrations with
PRAGMA user_versionas the source of truth, embedded withembed.FSand applied at startup before serving. A pre-migrationVACUUM INTObackup is taken and verified withquick_check. Migration 002 adds the user column to notes and rebuilds settings with a(user, key)primary key; pre-existing rows are backfilled toOCNOTES_OWNER, and the service refuses to start without it rather than leave rows invisible.The scoping key is the user stable graph id, not the username: this deployment returns a null
userPrincipalName, so the username was an empty string for every user. Every note and settings operation is scoped, and cross-user access behaves as not-found (including DELETE, which previously answered 200).Verification:
go build ./...,go vet ./...andgo test -race ./...pass (11 store/migration tests)user_version2, the settings primary key is(user, key), the pre-migration backup verified withquick_check, 4 notes and 4 settings backfilled to the owner