fix(auth): make founding-admin bootstrap atomic #96
No reviewers
Labels
No labels
area:api
area:core
area:docs
area:infra
area:ux
dependencies
documentation
duplicate
good first issue
help wanted
invalid
question
rust
status:complete
status:partial
status:planned
type:bug
type:design
type:feature
type:infra
type:refactor
type:refactor
type:research
type:ux
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
icub3d/decentcom!96
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feature/79-bootstrap-race"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Fixes #79. The first user became admin via a check-then-act:
create_user, thenif list_users().len() == 1. Two concurrent first-time registrations can interleave (A creates, B creates, then A lists → 2) so that neither becomes admin — leaving the server with no administrator (or, with the opposite interleaving, two admins).Fix
New
try_claim_admin(user_id)runs a single atomic conditional insert:It grants
@adminonly if no member already holds it and returns whether this call won.verifyuses the boolean to decide the founding-admin path. Exactly one registration wins regardless of concurrency.Tests
only_one_user_can_claim_admin(storage): second claim returns false; exactly one admin.concurrent_first_registrations_produce_exactly_one_admin(e2e): twotokio::join!-ed registrations yield exactly one@admin.Full server suite green (117 tests);
clippy -D warningsclean.Closes #79