Repository navigation
feat(db): step 5 scope roles and their grants, phase 1 (step 5, U2) - #53
Merged
Merged
Conversation
… as a union (step 4.2, U1)
…ients through identity's ports (step 4.2, U3)
…rrection, behind the operator's menu link (step 4.2, U4)
…ration deletes the test companies (step 4.2, U5)
…' lines to the roadmap's ceiling
…of adding to it, so setup time never counts
…as the lock, not before
… journey runs in Chromium (step 4.2, U6)
…t, and native joins no longer protect a reachable path
This was referenced Oct 17, 2026
Merged
The scope roles hold UPDATE on the company, a member, a person or a session only to take a row lock. PostgreSQL needs UPDATE on one column for FOR SHARE and FOR NO KEY UPDATE, so each gets UPDATE on one column no command writes (data D12): created_at on the company and a member, updated_at on a person and a session.
…ovisional A (step 5, U2) Moved here from the build so the founder reads the whole list in one grant PR (D11): the role hub_administrators, its column grant on auth.user, the function auth.is_installation_administrator with EXECUTE for hub_operator only, and its ownership.
…-mail and stamp (step 5, U2) UPDATE on auth.user for hub_invitation narrows to the columns the password command writes; a person's role is not writable from the link scope.
…grants Main's step 4.2 replaces the old base branch's files; this branch keeps only its own roles, administrator check and grants.
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.
Step 5's card, unit U2: the scope roles and their grants, in a pull request of their own before the step's code (data D11). It waits for the founder's word on the exact list below, as PR 48 did. Nothing merges before it, and it merges before the build PR (#54), which carries these same commits.
What changes
20261017040314_company_scope_rolesis custom SQL; Drizzle generates neither a role nor a grant (data D5).hub_company,hub_person,hub_invitationandhub_operator, allNOLOGIN NOSUPERUSER NOINHERIT NOCREATEDB NOCREATEROLE NOBYPASSRLS.hub_runtime's migration does, because roles belong to the whole server and tests make many databases on one.hub_runtimeWITH INHERIT FALSE, SET TRUE: the login switches to one for a transaction and inherits nothing.hub_runtime's own grants do not change here; phase 2 (U7, feat(db): the Hub's login loses its reach on a company's tables, phase 2 (step 5, U7) #55) takes them away.20261017040400_installation_administrator_checkis custom SQL, provisional A, firstmate 2026-10-17. It is in this PR so you read the whole list in one place (review finding).hub_administrators(NOLOGIN) withSELECT (id, role)onauth."user".SECURITY DEFINERfunctionauth.is_installation_administrator(person), owned by that role, withsearch_path = pg_catalog, revoked from PUBLIC, andEXECUTEforhub_operatoronly.apps/server/database-grants.sql: the approved snapshot gains the lines below.The list, role by table by verb
This is the census from the U1 proof: the whole server suite run with these grants and the row policies, in phase 1 and in phase 2.
A command that only locks a row (
FOR SHARE,FOR NO KEY UPDATE) needs UPDATE, but on one column is enough, so those grants are one column no command writes (data D12; review finding):created_aton the company and a member,updated_aton a person and a session.hub_company(a company's routes)auth.companyauth.memberFOR SHAREauth.invitationauth."user"auth.sessionFOR SHAREof cancel and renewhub_person(the person's companies, the pace)auth.company,auth.member,auth.invitation,auth."user"hub_invitation(the invitation link)auth.companyauth.memberauth.invitationauth."user"auth.accountauth.sessionauth.verificationhub_operator(the Operations Central)auth.company,auth.invitationauth.memberauth."user"operations.clientauth.is_installation_administrator(text)hub_administrators(owns the function, cannot log in)auth."user"DELETEonauth.company,auth.member,auth.invitationandoperations.clientbelongs tohub_operatoralone (card, "O grant"; Q6).USAGE:authfor all five roles,operationsforhub_operator.Proof
catalog.test.tspasses with the snapshot equality.npm run migrationsis ok.