plane
plane copied to clipboard
[WEB-5324] refactor: add Unified OAuth Configuration and Missing Gitea Options
Description
- Replaced the AuthenticationModes component with a more streamlined implementation using AuthenticationMethodCard.
- Removed obsolete authentication modes files from the codebase.
- Enhanced the AuthRoot component to utilize the new OAuth configuration hook for better management of authentication options.
- Updated type definitions for instance authentication modes to reflect the new structure.
Type of Change
- [x] Code refactoring
Summary by CodeRabbit
-
New Features
- Added LDAP authentication option and instance-level upgrade path
- Theme-aware OAuth icons and dynamic OAuth provider buttons
-
Refactoring
- Authentication UI now renders individual authentication method cards for clearer management
- OAuth configuration unified into hook-driven flow for consistent behavior across apps
- Authentication modes reorganized for more reliable retrieval and ordering
Walkthrough
Authentication handling was refactored: admin auth modes moved from an exported array/component to a map + hook; UI now renders AuthenticationMethodCard list after theme resolution. OAuth configuration for Web/Space was moved to composable hooks (core + extended + composer). Several barrel re-exports and a UX UpgradeButton file were removed. Types were tightened to a finite set of core auth keys and new OAuth config types were added.
Changes
| Cohort / File(s) | Summary |
|---|---|
Admin authentication page apps/admin/app/(all)/(dashboard)/authentication/page.tsx |
Added theme resolution; compute resolvedTheme; use useAuthenticationModes(...); delay data fetch until theme resolved; render dynamic list of AuthenticationMethodCard components instead of previous AuthenticationModes component. |
Admin core OAuth / auth modes (map) apps/admin/core/hooks/oauth/core.tsx |
Replaced array-returning getAuthenticationModes with getCoreAuthenticationModesMap returning a Record keyed by mode key; removed AuthenticationModes component and related props; exposed mode map with keys: unique-codes, passwords-login, google, github, gitlab, gitea; updated asset/icon usage and removed OIDC/SAML/UpgradeButton entries. |
Admin auth hook & types apps/admin/core/hooks/oauth/index.ts, apps/admin/core/hooks/oauth/types.ts |
Added useAuthenticationModes hook returning ordered modes array derived from core map; introduced TGetAuthenticationModeProps (disabled, updateConfig, resolvedTheme). |
Barrel export removals (authentication) apps/admin/ce/components/authentication/index.ts, apps/admin/ee/components/authentication/index.ts, apps/admin/ee/components/authentication/authentication-modes.tsx |
Removed export * from "./authentication-modes" re-exports, reducing public surface for those barrels. |
Removed UpgradeButton file & related re-export apps/admin/ce/components/common/upgrade-button.tsx, apps/admin/ce/components/common/index.ts |
Deleted upgrade-button.tsx file and removed its re-export from common index; UpgradeButton is no longer exported from CE common barrel. |
Space & Web core OAuth hooks apps/space/core/hooks/oauth/core.tsx, apps/web/core/hooks/oauth/core.tsx |
Added useCoreOAuthConfig(oauthActionText) returning { isOAuthEnabled, oAuthOptions } built from instance config; provider options (google, github, gitlab, gitea) include theme-aware icons and redirect handlers that include next_path. |
Space & Web extended OAuth hooks (stub) apps/space/core/hooks/oauth/extended.tsx, apps/web/core/hooks/oauth/extended.tsx |
Added useExtendedOAuthConfig(_oauthActionText) returning a stubbed { isOAuthEnabled:false, oAuthOptions:[] } for extension points. |
Space & Web OAuth composition hook apps/space/core/hooks/oauth/index.ts, apps/web/core/hooks/oauth/index.ts |
Added useOAuthConfig(oauthActionText = "Continue") that composes core + extended configs (OR for isOAuthEnabled, concat for oAuthOptions). |
Auth-root components updated (Web & Space) apps/web/core/components/account/auth-forms/auth-root.tsx, apps/space/core/components/account/auth-forms/auth-root.tsx |
Replaced hard-coded OAuth button configs and asset usage with useOAuthConfig() hook; render OAuthOptions from merged options; removed direct theme/image imports and provider-specific click handlers. |
Types tightened / new OAuth types packages/types/src/instance/auth.ts, packages/types/src/instance/auth-ee.ts |
Introduced TCoreInstanceAuthenticationModeKeys union (unique-codes,passwords-login,google,github,gitlab,gitea), `TInstanceAuthenticationModeKeys = TCore... |
Sequence Diagram(s)
sequenceDiagram
autonumber
participant Page as Admin auth page
participant Theme as Theme resolver
participant Hook as useAuthenticationModes
participant Core as getCoreAuthenticationModesMap
participant UI as AuthenticationMethodCard...
Page->>Theme: resolveGeneralTheme(resolvedThemeAdmin)
Page->>Hook: useAuthenticationModes({ disabled,isSubmitting,updateConfig,resolvedTheme })
activate Hook
Hook->>Core: getCoreAuthenticationModesMap(props)
Core-->>Hook: modes map (keys: unique-codes, passwords-login, google, github, gitlab, gitea)
Hook-->>Page: ordered modes array
deactivate Hook
Page->>UI: render AuthenticationMethodCard for each mode
sequenceDiagram
autonumber
participant AuthRoot as auth-root.tsx
participant UseOAuth as useOAuthConfig("Continue")
participant Core as useCoreOAuthConfig
participant Ext as useExtendedOAuthConfig
participant Instance as useInstance()
AuthRoot->>UseOAuth: invoke
activate UseOAuth
UseOAuth->>Core: useCoreOAuthConfig("Continue")
activate Core
Core->>Instance: read provider flags
Instance-->>Core: config (google, github, gitlab, gitea)
Core-->>UseOAuth: { isOAuthEnabled, oAuthOptions }
deactivate Core
UseOAuth->>Ext: useExtendedOAuthConfig("Continue")
activate Ext
Ext-->>UseOAuth: { isOAuthEnabled:false, oAuthOptions:[] }
deactivate Ext
rect rgb(230,245,230)
Note over UseOAuth: compose -> isOAuthEnabled = Core.isOAuthEnabled OR Ext.isOAuthEnabled
Note over UseOAuth: oAuthOptions = Core.oAuthOptions ++ Ext.oAuthOptions
end
UseOAuth-->>AuthRoot: merged configs
deactivate UseOAuth
AuthRoot->>AuthRoot: render OAuthOptions based on merged oAuthOptions
Estimated code review effort
๐ฏ 4 (Complex) | โฑ๏ธ ~45 minutes
Areas to pay extra attention:
apps/admin/core/hooks/oauth/core.tsxโ verify the new Record shape, mode keys, and that callers now use keyed access or the new hook.packages/types/src/instance/auth.tsโ ensure the stricter key union and new OAuth types are compatible across the codebase.- Barrel export removals and deleted
upgrade-button.tsxโ search for imports relying on removed re-exports or the deleted component. - OAuth next_path propagation and theme-dependent icon selection in core hooks for Web and Space.
Poem
๐ฐ I hopped through hooks and tightened keys,
Maps now hum where arrays used to be,
OAuth buttons learn to gather and play,
Barrels trimmed, the code finds light of day,
A little rabbit cheers the tidy tree โจ
Pre-merge checks and finishing touches
โ Passed checks (3 passed)
| Check name | Status | Explanation |
|---|---|---|
| Title check | โ Passed | The title clearly and specifically describes the main changes: refactoring to add unified OAuth configuration and Gitea options support across the authentication system. |
| Description check | โ Passed | The description covers the main changes and includes the required 'Type of Change' section with 'Code refactoring' selected, though it could provide more technical depth about the OAuth configuration unification. |
| Docstring Coverage | โ Passed | No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. |
โจ Finishing touches
- [ ] ๐ Generate docstrings
๐งช Generate unit tests (beta)
- [ ] Create PR with unit tests
- [ ] Post copyable unit tests in a comment
- [ ] Commit unit tests in branch
refactor-oauth-options
[!TIP]
๐ Customizable high-level summaries are now available in beta!
You can now customize how CodeRabbit generates the high-level summary in your pull requests โ including its content, structure, tone, and formatting.
- Provide your own instructions using the
high_level_summary_instructionssetting.- Format the summary however you like (bullet lists, tables, multi-section layouts, contributor stats, etc.).
- Use
high_level_summary_in_walkthroughto move the summary from the description to the walkthrough section.Example instruction:
"Divide the high-level summary into five sections:
- ๐ Description โ Summarize the main change in 50โ60 words, explaining what was done.
- ๐ References โ List relevant issues, discussions, documentation, or related PRs.
- ๐ฆ Dependencies & Requirements โ Mention any new/updated dependencies, environment variable changes, or configuration updates.
- ๐ Contributor Summary โ Include a Markdown table showing contributions:
| Contributor | Lines Added | Lines Removed | Files Changed |- โ๏ธ Additional Notes โ Add any extra reviewer context. Keep each section concise (under 200 words) and use bullet or numbered lists for clarity."
Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands and usage tips.