Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,17 @@ is one record in `people_persons`; their roles are rows in `people_assignments`,
- **A record that isn't linked yet**: its assignments stay `pending` in the backend, and are sent when the record is
linked, acting as whoever links it by hand or, for an invite, as whoever made each assignment.

A record is linked to a login account in exactly two ways, never by matching emails, names or Telegram:

- **Email invite** (`people:write`, or the Lead of one of the person's teams): a single-use link to the contact
email, stored hashed, valid for 14 days; a new invite revokes the previous one. Any signed-in account can open it
(`me.invite`) and accept it (`me.acceptInvite`), with no People permission and whatever its email.
- **By hand** (`admin:access` + `people:link`): search the IdP directory and link an account; nobody links their own.

Unlinking (`people:link`) takes the record's roles back in Auth with a role command, then detaches the account; its
assignments go back to `pending`. `linking.recent` lists the links of the last 30 days, with method, date and who
made them, so a mistake or a forwarded invite is easy to spot and undo.

The backend checks every role change with the same rules as Auth (`src/people/rules.ts`, shaped like Auth's
`src/auth/people-binding.ts`): no self-grants, the right permission per kind, and bounded delegation against the
role's permissions. A concept with no role bound in Auth, or with more than one, can't be assigned. Writes are
Expand Down
6 changes: 6 additions & 0 deletions drizzle/0032_people_linking.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
ALTER TABLE "people_persons" ADD COLUMN "linked_at" timestamp with time zone;--> statement-breakpoint
ALTER TABLE "people_persons" ADD COLUMN "linked_by" text;--> statement-breakpoint
ALTER TABLE "people_persons" ADD COLUMN "link_method" text;--> statement-breakpoint
ALTER TABLE "people_role_commands" ADD COLUMN "purpose" text DEFAULT 'roles' NOT NULL;--> statement-breakpoint
ALTER TABLE "people_role_commands" ADD CONSTRAINT "people_role_commands_purpose_check" CHECK ("people_role_commands"."purpose" in ('roles', 'unlink'));--> statement-breakpoint
UPDATE "people_persons" SET "link_method" = 'auth', "linked_by" = 'auth', "linked_at" = "created_at" WHERE "account_sub" IS NOT NULL AND "created_by" = 'auth' AND "link_method" IS NULL;
Loading
Loading