Skip to content

[codex] show plugin OAuth providers on login - #32

Merged
Quick104 merged 2 commits into
mainfrom
fix/login-oauth-providers
May 31, 2026
Merged

Quick104 merged 2 commits into
mainfrom
fix/login-oauth-providers

Conversation

@Quick104

@Quick104 Quick104 commented May 31, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #30 by preserving usable providers returned from /api/v1/auth/providers in the web auth context. Login.tsx already separates credential and OAuth providers, but the auth hook was filtering the list down to credential providers before the login page could render OAuth sign-in buttons.

This also keeps the backend provider list aligned with route availability: OAuth providers are only advertised when the router actually mounted the /api/v1/auth/oauth/{installation_id}/init flow. Servers without SILO_PUBLIC_URL configured will not show unusable OAuth buttons.

Impact

Custom auth plugins that declare OAuth-only login now appear on the login screen when OAuth is configured and submit through /api/v1/auth/oauth/{installation_id}/init as intended. If OAuth routes are unavailable, those providers stay hidden instead of leading users to a 404.

@thezak48 could you test this PR with your custom OAuth plugin and confirm the sign-in option now appears and starts the OAuth flow correctly on a server with SILO_PUBLIC_URL configured?

Validation

  • go test ./internal/api/handlers
  • go test ./internal/api
  • pnpm --dir web exec vitest run src/hooks/AuthProvider.test.tsx src/hooks/useAuth.test.ts
  • pnpm --dir web exec prettier --check src/hooks/AuthProvider.test.tsx src/hooks/useAuth.tsx
  • pnpm --dir web exec tsc -b --pretty false
  • Previous changed-file ESLint check: pnpm --dir web exec eslint src/hooks/useAuth.tsx src/hooks/AuthProvider.test.tsx

Summary by CodeRabbit

  • Bug Fixes

    • Authentication providers are now correctly filtered based on OAuth route availability. OAuth providers are hidden when routes are unavailable and displayed when available.
    • Provider list during setup now includes all available authentication methods.
  • Tests

    • Added test coverage for authentication provider filtering behavior.

@coderabbitai

coderabbitai Bot commented May 31, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: f35bc7e7-114f-4b10-b4b9-f25d2b91edfc

📥 Commits

Reviewing files that changed from the base of the PR and between 9bc5934 and 41d22ef.

📒 Files selected for processing (3)
  • internal/api/handlers/auth.go
  • internal/api/handlers/auth_providers_test.go
  • internal/api/router.go

📝 Walkthrough

Walkthrough

Frontend now preserves the full auth provider list returned by /auth/providers during AuthProvider initialization. Backend AuthHandler gains an oauthRoutesAvailable flag (set by the router) and conditionally omits oauth-mode providers from the providers response when OAuth routes are unavailable. Tests added for both frontend and backend behavior.

Changes

Provider List Preservation in Auth Context

Layer / File(s) Summary
Keep full provider list in AuthProvider
web/src/hooks/useAuth.tsx
setProviders now stores availableProviders ?? [] without filtering out non-credentials providers.
AuthProvider tests with mocked client
web/src/hooks/AuthProvider.test.tsx
New Vitest/RTL tests mock @/api/client, render AuthProvider with a probe using useAuth(), and assert the providers list includes both local:credentials and plugin:41:oidc:oauth entries.

Backend: OAuth gating and tests

Layer / File(s) Summary
AuthHandler oauthRoutesAvailable field and setter
internal/api/handlers/auth.go
Adds oauthRoutesAvailable bool to AuthHandler and an exported SetOAuthRoutesAvailable(available bool) method.
Conditionally omit oauth providers in HandleProviders
internal/api/handlers/auth.go
HandleProviders skips providers with mode == "oauth" when oauthRoutesAvailable is false, preventing them from appearing in the JSON response.
Router sets AuthHandler OAuth availability
internal/api/router.go
Router calls authHandler.SetOAuthRoutesAvailable(oauthHandler != nil) after building the optional OAuth handler.
Auth providers handler tests
internal/api/handlers/auth_providers_test.go
Tests register a local and an OAuth provider, toggle SetOAuthRoutesAvailable, call GET /auth/providers, and assert the response includes or omits the OAuth provider and validates its Mode and InstallationID.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐇 The filters fell, both near and far,

Local and OAuth now share the star,
Router whispers, "available" true,
Tests hop in to prove it too,
Login sees the fuller view.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main change: removing provider filtering to display OAuth providers on login.
Linked Issues check ✅ Passed The PR successfully addresses issue #30 by preserving all providers instead of filtering to credentials-only, enabling OAuth providers to display on login.
Out of Scope Changes check ✅ Passed Changes are limited to auth provider handling and related tests; all modifications directly address the linked issue without introducing unrelated functionality.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/login-oauth-providers

Comment @coderabbitai help to get the list of available commands and usage tips.

@thezak48

thezak48 commented May 31, 2026 •

Copy link
Copy Markdown
Contributor

Fixes the issue for #30

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9bc593471a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread web/src/hooks/useAuth.tsx
}
setSetupRequired(status.needs_setup);
setProviders((availableProviders ?? []).filter((entry) => entry.mode === "credentials"));
setProviders(availableProviders ?? []);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Hide OAuth providers when OAuth routes are unavailable

When a plugin declares OAuth-only auth on a server without PublicURL configured, this now exposes that provider to the login page, but the backend only registers /auth/oauth/{install_id}/init when deps.PublicURL != "" (and DB/JWT are available) in internal/api/router.go:1136-1140 and otherwise skips the route at internal/api/router.go:1182-1187, while /auth/providers remains registered unconditionally. In that configuration the newly visible button posts to a missing endpoint and users get a 404 instead of a usable sign-in path; either the provider list needs to reflect OAuth route availability or the UI should not surface these OAuth providers unless the route can actually handle them.

Useful? React with 👍 / 👎.

@Quick104
Quick104 marked this pull request as draft May 31, 2026 21:34
@Quick104
Quick104 marked this pull request as ready for review May 31, 2026 21:34
@Quick104
Quick104 merged commit 573e9c6 into main May 31, 2026
1 check was pending
@Quick104
Quick104 deleted the fix/login-oauth-providers branch May 31, 2026 21:34
Quick104 added a commit to thezak48/silo-server that referenced this pull request Jun 7, 2026
* fix(auth): show oauth login providers

* fix(auth): hide oauth providers when routes are unavailable
Quick104 added a commit that referenced this pull request Jun 11, 2026
* fix(auth): show oauth login providers

* fix(auth): hide oauth providers when routes are unavailable
Quick104 added a commit that referenced this pull request Jun 17, 2026
* fix(auth): show oauth login providers

* fix(auth): hide oauth providers when routes are unavailable
Quick104 added a commit that referenced this pull request Jun 17, 2026
* fix(auth): show oauth login providers

* fix(auth): hide oauth providers when routes are unavailable
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.

OAuth providers are filtered out in useAuth before Login.tsx renders, so plugin OAuth sign-in options never appear

2 participants