Add self-service connector offboarding + approved-email-domain allowlist - #3
Merged
NextLevelManagementAdvisors merged 1 commit intoAug 5, 2026
Conversation
Offboarding was manual DBA work (README pointed at a raw DELETE), and the only access gate was GITHUB_ALLOWED_USERS — a per-login list, so admitting a whole company meant enumerating its people one at a time. Access control: - GITHUB_APPROVED_EMAIL_DOMAINS admits any user with a *verified* GitHub email on an approved domain, subdomains included. Unverified addresses never count; anyone can type someone@your-company.com into a GitHub profile. - OR'd with GITHUB_ALLOWED_USERS: named individuals via one list, whole companies via the other, both empty = open as before. - Fails closed when a domain gate is configured but /user/emails is unreadable, with an error telling the user to re-authorize. - Adds user:email to the default scopes and stores the admitting email on github_users, preserved across token refreshes. Offboarding — users turn their own connector off, on any approved domain: - GET /disconnect → POST /disconnect/start → GitHub → callback, reusing the existing redirect via a pending-state `purpose` column. - POST /disconnect for clients holding a bearer token. - Both delete every opaque token, in-flight auth code, the encrypted GitHub credentials and the tenants row in one transaction, then revoke the OAuth App grant on GitHub so the connector is off rather than merely forgotten. - audit_log rows are retained; they identify users only by a salted hash. - Deliberately not domain-gated: gating a privilege reduction would strand users whose domain was later removed from the allowlist. Verified against a scratch Postgres 16: migrations idempotent across reruns, 22 DB-layer assertions (including that a token refresh can't blank a stored email and that offboarding never touches a second user), the 15-case allowlist decision matrix, and the HTTP surface end to end. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HxTDjBKzBnaAvzMEY4DpQi
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.
Offboarding was manual DBA work (README pointed at a raw DELETE), and the
only access gate was GITHUB_ALLOWED_USERS — a per-login list, so admitting a
whole company meant enumerating its people one at a time.
Access control:
on an approved domain, subdomains included. Unverified addresses never count;
anyone can type someone@your-company.com into a GitHub profile.
companies via the other, both empty = open as before.
unreadable, with an error telling the user to re-authorize.
github_users, preserved across token refreshes.
Offboarding — users turn their own connector off, on any approved domain:
existing redirect via a pending-state
purposecolumn.credentials and the tenants row in one transaction, then revoke the OAuth App
grant on GitHub so the connector is off rather than merely forgotten.
users whose domain was later removed from the allowlist.
Verified against a scratch Postgres 16: migrations idempotent across reruns,
22 DB-layer assertions (including that a token refresh can't blank a stored
email and that offboarding never touches a second user), the 15-case
allowlist decision matrix, and the HTTP surface end to end.
Co-Authored-By: Claude Opus 5 noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_01HxTDjBKzBnaAvzMEY4DpQi