🌐 US-Proxy
class="logged-out env-production page-responsive" style="word-wrap: break-word;" >
Skip to content

fix: explain default GitHub app org visibility on login rejection - #27374

Merged
matifali merged 2 commits into
mainfrom
fix-github-default-app-allowed-orgs
Jul 21, 2026
Merged

fix: explain default GitHub app org visibility on login rejection#27374
matifali merged 2 commits into
mainfrom
fix-github-default-app-allowed-orgs

Conversation

@matifali

@matifali matifali commented Jul 21, 2026

Copy link
Copy Markdown
Member

Problem

On a fresh deployment with no custom GitHub OAuth app, Coder falls back to the default Coder-managed GitHub app. That app can only see organization memberships in organizations where it has been installed. If CODER_OAUTH2_GITHUB_ALLOWED_ORGS is set but the app isn't installed in the allowed organizations, the membership list comes back empty and every login, including the first admin login, is rejected with a bare "You aren't a member of the authorized Github organizations!" with no hint about the actual cause. This leaves fresh deployments in an apparently broken state.

Fix

  • Append a remediation hint to the login rejection when the default provider is configured, pointing at the app installation page and at configuring a custom GitHub OAuth app.
  • Log a startup warning when the default provider is combined with CODER_OAUTH2_GITHUB_ALLOWED_ORGS, listing the allowed orgs and the install URL.
  • Document the installation requirement next to the CODER_OAUTH2_GITHUB_ALLOWED_ORGS step in the GitHub auth docs.

Access-control behavior is unchanged; the org check still rejects logins as before, it just explains why and how to fix it.

Testing

  • New TestUserOAuth2Github/NotInAllowedOrganizationDefaultProvider asserts the hint appears when DefaultProviderConfigured is set; the existing NotInAllowedOrganization subtest asserts it does not leak into the custom-app path.

Fixes #17752

…tion

When a fresh deployment falls back to the default Coder GitHub app and
CODER_OAUTH2_GITHUB_ALLOWED_ORGS is set, the app can only see
memberships in organizations that have installed it. Logins from
allowed organizations were rejected with a bare "You aren't a member"
error, bricking first login with no hint about the missing app
installation.

Add a remediation hint to the login rejection when the default provider
is configured, warn at server startup when the default provider is
combined with allowed orgs, and document the installation requirement.

Fixes #17752
@github-actions

Copy link
Copy Markdown

Docs preview

📖 View docs preview for docs/admin/users/github-auth.md

@matifali
matifali requested review from bpmct and nickvigilante July 21, 2026 13:11
@linear-code
linear-code Bot marked this pull request as ready for review July 21, 2026 13:11

@nickvigilante nickvigilante left a comment

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.

Approved with changes. Thanks for this! :shipit: 🚀

Comment thread cli/server.go Outdated
Comment thread coderd/userauth.go
Comment thread docs/admin/users/github-auth.md Outdated
Comment thread coderd/userauth_test.go
Extract the install URL and remediation sentence into shared constants so
the login rejection, server startup warning, and docs stay in sync. Add the
same remediation hint to the team-membership rejection, which has the same
root cause when the default GitHub app isn't installed in an organization.
Cover the device-flow rejection branch with a test asserting the hint is
returned in the response Detail.
@matifali
matifali merged commit 48e9bb3 into main Jul 21, 2026
31 of 33 checks passed
@matifali
matifali deleted the fix-github-default-app-allowed-orgs branch July 21, 2026 15:43
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 21, 2026
@matifali matifali changed the title fix(coderd): explain default GitHub app org visibility on login rejection fix: explain default GitHub app org visibility on login rejection Jul 21, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: CODER_OAUTH2_GITHUB_ALLOWED_ORGS breaks first login via GitHub

2 participants