Skip to content

feat: add site-admin account creation mode for GHES#172

Open
c1-dev-bot[bot] wants to merge 1 commit into
mainfrom
feat/site-admin-create-user
Open

feat: add site-admin account creation mode for GHES#172
c1-dev-bot[bot] wants to merge 1 commit into
mainfrom
feat/site-admin-create-user

Conversation

@c1-dev-bot
Copy link
Copy Markdown
Contributor

@c1-dev-bot c1-dev-bot Bot commented Jun 4, 2026

Summary

  • Adds account-creation-mode config option (invitation default, or site_admin_create) and site-admin-token secret config option
  • When mode is site_admin_create, CreateAccount calls the GHES site-admin POST /admin/users endpoint via AdminService.CreateUser using a separate site-admin PAT, bypassing the email invitation flow entirely
  • Returns a SuccessResult with the created user resource (immediately active, no invitation acceptance needed)
  • Adjusts Metadata account creation schema: in site_admin_create mode, github_username becomes required and email becomes optional (matches GHES behavior under LDAP/SAML/CAS auth)
  • Handles "user already exists" errors gracefully via AlreadyExistsResult

This unblocks SSO/LDAP-enforced GHES customers (e.g., environments with ~100 orgs where email-based org invitations are disallowed by enterprise policy) from using ConductorOne for account provisioning.

Fixes: CXH-1594

Test plan

  • Verify existing invitation-based account creation still works (default mode)
  • Test account-creation-mode=site_admin_create with site-admin-token against a GHES instance
  • Test that missing github_username in site_admin_create mode returns a clear error
  • Test that missing site-admin-token when mode is site_admin_create fails at startup
  • Test "user already exists" case returns AlreadyExistsResult
  • Verify connector validates account-creation-mode values at startup

Automated PR Notice

This PR was automatically created by c1-dev-bot as a potential implementation.

This code requires:

  • Human review of the implementation approach
  • Manual testing to verify correctness
  • Approval from the appropriate team before merging

Add an alternative account-creation path that uses the GHES site-admin
POST /admin/users endpoint instead of org invitations. This supports
SSO/LDAP-enforced GHES environments where email-based org invitations
are disallowed by policy.

New config options:
- account-creation-mode: "invitation" (default) or "site_admin_create"
- site-admin-token: separate PAT with site-admin privileges for GHES

When mode is site_admin_create, CreateAccount calls Admin.CreateUser
with the provided github_username as the login. The user is created
immediately (no invitation email, no acceptance required), which
enables downstream team/repo grants in the same provisioning tick.

Fixes: CXH-1594
@c1-dev-bot c1-dev-bot Bot requested a review from a team June 4, 2026 20:57
@linear-code
Copy link
Copy Markdown

linear-code Bot commented Jun 4, 2026

CXH-1594

orgs []string
accountCreationMode string
siteAdminClient *github.Client
instanceURL string
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Suggestion: instanceURL is stored on the struct and passed through InvitationBuilderParams, but no method on invitationResourceType ever reads it. Consider removing it to avoid dead code (R2).

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 4, 2026

Connector PR Review: feat: add site-admin account creation mode for GHES

Blocking Issues: 0 | Suggestions: 2 | Threads Resolved: 0
Review mode: full
View review run

Review Summary

This PR adds a site_admin_create account creation mode for GHES environments where email-based org invitations are disallowed. The implementation is clean: config validation happens at startup, the CreateAccount dispatch is straightforward, and idempotency is handled correctly for the "already exists" case. The control flow refactor in NewLambdaConnector (early return to if/else) correctly ensures site-admin setup applies to both PAT and GitHub App auth paths. No security or correctness issues found.

Security Issues

None found.

Correctness Issues

None found.

Suggestions

  • pkg/connector/invitation.go:101instanceURL field is stored on invitationResourceType but never read by any method; dead code.
  • docs/connector.mdx — Does not document the new account-creation-mode or site-admin-token configuration fields, and the account provisioning description only mentions invitation-based flow (D3/D4).
Prompt for AI agents
Verify each finding against the current code and only fix it if needed.

## Suggestions

In `pkg/connector/invitation.go`:
- Around line 101: The `instanceURL` field on `invitationResourceType` is never read by any
  method. Remove it from the struct definition (line 101), from `InvitationBuilderParams`
  (line 633), and from the `InvitationBuilder` constructor (line 643). Also remove the
  `instanceURL` argument from the `InvitationBuilder` call site in `connector.go` (line 144).

In `docs/connector.mdx`:
- Around line 26: The account provisioning description says "New accounts will send an
  invitation to the account owner" without mentioning the alternative site-admin creation
  mode. Update to note that GHES instances can use `account-creation-mode=site_admin_create`
  with a `site-admin-token` to create accounts directly. Document both new config fields
  in the credentials/configuration section.

Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No blocking issues found.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants