nebari-dev / nebari-dev/nebari-frames
Track membership provenance so default-provisioned rows are distinguishable
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 2
- Forks
- 1
- Avg merge
- 10h 55m
- Merged PRs (30d)
- 9
Description
Problem
With auth.defaultRole set (#22), a user who merely signed in gets a persisted membership row that is byte-for-byte indistinguishable from one an admin deliberately created. Several behaviors have to guess as a result:
seed.Runcannot tell "already configured" from "just signed in". #22 works around this by promoting the configured admin only whenCountAdminsreturns zero. That is a targeted fix for the break-glass case, not a general answer.AddOrgMemberfails instead of upgrading. Adding a user who has already signed in returnsAlreadyExists("a member with that email already exists"), which reads like a duplicate-invite error rather than "this person is already here at the baseline, change their role." Documented as a caveat in the README today.- A pending invite created after first login can never activate.
ResolveCalleronly consults the invite table when there is no sub-keyed membership. Worst case is a token with noemailclaim: the baseline row storesemail NULL, soAddOrgMemberdoes not even detect the collision, and the admin sees an invite that will silently never apply.
Suggested direction
Add provenance to org_memberships, e.g. source TEXT NOT NULL DEFAULT 'explicit' with values explicit (admin invite, seed, or an admin-set role) and default (auto-provisioned by auth.defaultRole). Then:
seed.Runcan promote adefaultrow unconditionally, and leaveexplicitrows alone - noCountAdminsheuristic.AddOrgMembercan upgrade adefaultrow in place instead of erroring.ResolveCallercan let a later invite win over adefaultrow, restoring the "an invite always outranks the baseline" contract even when the baseline row already exists.- Unsetting
auth.defaultRolecould optionally prunedefaultrows, making the setting genuinely reversible.
Notes
This preserves the property that motivated persisting the row in the first place (baseline users appear in ListOrgMembers and are promotable) while removing the ambiguity it introduced. Needs a migration, which is why it was deliberately kept out of #22.
Raised by review of #22.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing seed.Run, AddOrgMember, and ResolveCaller, then inspect the org_memberships schema and existing migration approach. Define how provenance affects default rows, explicit memberships, later invites, and optional pruning; done means the migration and all three flows preserve the stated precedence and upgrade behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- authentication, backend, databases
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 47/100