Skip to content

Directory sync creates, takes over, and deactivates users - #4469

Merged
craig-dt merged 1 commit into
mainfrom
cursor/factory-4423-directory-sync-turns-on-and-a-pushed-user-is-created-taken-over-disabled-and-sign-b566
Nov 16, 2026
Merged

craig-dt merged 1 commit into
mainfrom
cursor/factory-4423-directory-sync-turns-on-and-a-pushed-user-is-created-taken-over-disabled-and-sign-b566

Conversation

@craig-dt

Copy link
Copy Markdown
Collaborator

Closes #4423

A provider can push people into Vigil. Turning directory sync on from Single sign-on mints one token for a service account that holds only directory.sync. While sync is on, sign-in does not create accounts and does not link by email. A push creates a passwordless person, or takes over the account whose externalId is already on a link. active: false and DELETE deactivate through deactivate_account with route sync. The account leaves SCIM and stays in Vigil. The last person who can manage roles stays active, and that refusal is listed on the card until it no longer applies.

SCIM is /scim/v2. Compose publishes the backend itself, so that path reaches the API. A GET that misses is JSON, not the app shell.

python -m core.auth.directory_sync_off turns sync off and leaves the token in place. Sign-in can create accounts again. A placeholder subject (still the externalId) is replaced with the token's sub on the first real sign-in, including after sync is off, so an Entra oid does not strand that person.

Left for a follow-up, as the groom scoped: the pending-push table, linking a push to an existing person, reactivating a window of sync deactivations, and removing a never-used sync account.

Directory sync on, with a refused last-manager deactivation

Quill deactivated by directory sync

Verification

Ran

  • Turned directory sync on from the Single sign-on card (SSO already on, one confirmation, one step-up) and read the vgl_api_ token once. The card then showed sync on, no push yet, a token expiry about a year out, and /scim/v2.
  • With that bearer, POST /scim/v2/Users returned 201 for Quill. Signing in through a local OpenID Connect provider landed in the console as that account. PATCH active to false returned 200; the next /api/auth/me with that session was 403 and the browser returned to the login screen.
  • DELETE returned 204. GET returned 404. Team & access still showed Quill as Deactivated, Directory sync, at 1920. At 360 the accounts table scrolls inside its card, which is how that table already behaves; the status is on the row.
  • POST of an email an existing local account already holds returned 409 scimType: uniqueness. One account remained.
  • PATCH active: false on the last role manager returned 409, left the account active, and listed quill.user on the sync card (1920 and 360). A retry that also renamed them still returned 409 and did not keep the rename or move the version.
  • Minting from Tokens of directory-sync returned 403, "Directory sync's token is minted from Single sign-on". The role editor shows directory.sync disabled, with "not grantable", at 1920 and 360.
  • python -m core.auth.directory_sync_off with a reason turned sync off and said the token was left in place. An SSO sign-in for someone the push had never created then created nova.user and opened the console.
  • While sync was still on, an SSO sign-in for someone with no link showed "Your account hasn't been set up in Vigil from your identity provider yet. If this lasts, ask your admin." at 1920 and 360. The sentence wraps inside the alert; the page does not scroll sideways.
  • A managed account whose subject was still the externalId (oid-erna) and whose token sub was different signed in, replaced the subject with sub, left directory_id and the stored name unchanged.
  • The API log has the SCIM status lines only. It has no copy of the token, no Authorization header, and no externalId or display name from the request body.
  • Checked Single sign-on and Team & access at 1920 and at 360. The sync status stacks in one column at 360. The long discovery URL scrolls inside its own field. A product tour popover still covers the top of Settings until it is skipped; that tour is unchanged.

Did not run

  • The repo's CI checks. They run on the PR.
  • Live Entra ID and Okta. Nothing here can sign in to either. The card says both are unverified until an operator runs them.

Blocked by the machine

  • The checked-in .env sets VIGIL_COOKIE_SECURE=true, so the HTTP console on this machine refused the CSRF cookie until the API was started with VIGIL_COOKIE_SECURE=false.
  • VIGIL_FRONTEND_URL was empty, so the SSO callback went to the API port and the sign-in cookie, set on the web port, was missing (no_state_cookie). The live sign-in used VIGIL_FRONTEND_URL=http://127.0.0.1:6988.
  • Applying 0074_directory_sync needed VIGIL_UPGRADE_ACK_VERSION and VIGIL_UPGRADE_ACK_REASON. The API worker that reloaded before that upgrade exited on the schema mismatch and stayed a zombie until that process was restarted.

To show artifacts inline, enable in settings.

Open in Web Open in Cursor 

…vates users.

SSO sign-in stops creating accounts while sync is on, and a managed account no longer takes its name, email, or role from the token. The last role manager stays active.

Co-authored-by: craig-dt <craig@deeptempo.ai>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

factory Opened by the software factory

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Directory sync turns on, and a pushed user is created, taken over, disabled, and signed in as that account

2 participants