-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
feat: oidc launch url #14008
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: canary
Are you sure you want to change the base?
feat: oidc launch url #14008
Conversation
WalkthroughAdds OAuth launch functionality: a new OAuthLaunchComponent and page to orchestrate OAuth flows (native and web), exposes the component via the auth barrel file, and registers a new desktop route at /oauth/launch. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant App as App (Web/Native)
participant AuthSvc as AuthService
participant Popup as OAuth Popup
participant Provider as OAuth Provider
User->>App: Start OAuth (OAuthLaunchComponent)
App->>AuthSvc: log sign-in event
alt Native build
App->>AuthSvc: preflight OAuth / get client scheme
App->>Popup: open popup with native scheme
else Web build
App->>App: build OAuth URL (provider, redirect_uri)
App->>Popup: open popup window with URL
end
Popup->>Provider: Redirect to provider
Provider->>Popup: Redirect back with code/state
Popup->>AuthSvc: finalize authentication (exchange code)
AuthSvc-->>Popup: return session status
Popup->>App: notify authenticated (useLiveData/redirect)
App->>User: show success toast / close or navigate to redirect_uri
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (4)
packages/frontend/core/src/components/affine/auth/index.ts(1 hunks)packages/frontend/core/src/components/affine/auth/oauth-launch-component.tsx(1 hunks)packages/frontend/core/src/desktop/pages/auth/oauth-launch.tsx(1 hunks)packages/frontend/core/src/desktop/router.tsx(1 hunks)
🔇 Additional comments (2)
packages/frontend/core/src/components/affine/auth/index.ts (1)
1-1: Barrel export forOAuthLaunchComponentlooks correctRe-exporting from
./oauth-launch-componentis consistent with the existing auth barrel pattern and safely exposes the new component.packages/frontend/core/src/desktop/router.tsx (1)
153-157: New/oauth/launchroute wiring matches existing auth routesPath, lazy import, and
"auth"chunk naming align with/oauth/loginand/oauth/callback; no routing concerns from this addition.
packages/frontend/core/src/components/affine/auth/oauth-launch-component.tsx
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
♻️ Duplicate comments (1)
packages/frontend/core/src/desktop/pages/auth/oauth-launch.tsx (1)
43-60: Consider validatingredirectUrlbefore navigation.The
redirectUrloriginates from theredirect_uriquery parameter (line 24) and is passed directly tonavigate()without validation. While React Router may handle some edge cases, validating that the URL is a safe internal path (e.g., starts with/or matches an allowlist) would strengthen security posture and prevent potential navigation to unexpected destinations.Consider adding validation before navigation:
const handleAuthenticated = useCallback( (status: AuthSessionStatus) => { if (status === 'authenticated') { if (redirectUrl) { if (redirectUrl.toUpperCase() === 'CLOSE_POPUP') { window.close(); return; } + // Validate redirectUrl is an internal path + if (!redirectUrl.startsWith('/')) { + console.warn('Invalid redirect URL, falling back to index'); + handleClose(); + return; + } navigate(redirectUrl, { replace: true, }); } else { handleClose(); } } }, [handleClose, navigate, redirectUrl] );
🧹 Nitpick comments (1)
packages/frontend/core/src/components/affine/auth/oauth-launch-component.tsx (1)
87-87: Consider enhancing the UI for better user feedback.The current UI is minimal with just a heading. While functional, adding a loading spinner or more polished styling could improve the user experience during the OAuth flow.
Example enhancement:
- return <h1>Logging in with OIDC</h1>; + return ( + <div style={{ textAlign: 'center', padding: '2rem' }}> + <h1>Logging in with OIDC</h1> + <p>Please wait while we redirect you...</p> + {/* Add loading spinner component here */} + </div> + );
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (2)
packages/frontend/core/src/components/affine/auth/oauth-launch-component.tsx(1 hunks)packages/frontend/core/src/desktop/pages/auth/oauth-launch.tsx(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
packages/frontend/core/src/desktop/pages/auth/oauth-launch.tsx (3)
packages/frontend/core/src/components/hooks/use-navigate-helper.ts (1)
useNavigateHelper(24-268)packages/frontend/core/src/modules/cloud/entities/session.ts (1)
AuthSessionStatus(39-42)packages/frontend/core/src/components/affine/auth/oauth-launch-component.tsx (1)
OAuthLaunchComponent(13-88)
packages/frontend/core/src/components/affine/auth/oauth-launch-component.tsx (5)
packages/frontend/core/src/modules/cloud/entities/session.ts (1)
AuthSessionStatus(39-42)packages/common/infra/src/framework/react/index.tsx (1)
useService(15-17)packages/frontend/core/src/modules/url/services/url.ts (1)
UrlService(6-58)packages/frontend/core/src/components/hooks/affine-async-hooks.ts (1)
useAsyncCallback(18-30)packages/backend/server/src/base/error/def.ts (1)
UserFriendlyError(63-166)
🔇 Additional comments (13)
packages/frontend/core/src/desktop/pages/auth/oauth-launch.tsx (6)
1-13: LGTM!Imports are well-organized and appropriate for the OAuth launch page functionality.
15-24: LGTM!Component setup is clean with appropriate fallback from props to query parameters for the redirect URL.
26-35: LGTM!Error handling via toast notification is implemented correctly with proper internationalization support.
37-41: LGTM!The
handleClosecallback correctly uses replace navigation and preserves search parameters.
62-68: LGTM!Component render structure is clean with proper callback wiring to the underlying
OAuthLaunchComponent.
71-77: LGTM!The wrapper
Componentfollows the established pattern for desktop pages with appropriate layout composition.packages/frontend/core/src/components/affine/auth/oauth-launch-component.tsx (7)
1-11: LGTM!Imports are well-organized and cover all necessary dependencies for the OAuth launch flow.
13-24: LGTM!Component setup correctly initializes services and tracks authentication status using the infra framework's reactive patterns.
26-27: LGTM!The
effectiveRedirectUrlis correctly computed without mutating the prop, providing a sensible default callback URL.
29-69: LGTM!The
onContinuecallback properly handles both native and web OAuth flows with appropriate error handling for the native case and correct URL construction for the web case.
71-71: LGTM!The hard-coded OIDC provider aligns with the PR objectives for implementing OIDC Launch URL functionality.
73-81: LGTM!The status effect correctly handles authentication success notification and parent callback invocation without re-triggering the OAuth flow.
83-85: LGTM!The launch effect is properly separated to initiate the OAuth flow once on mount, preventing duplicate popup windows on status changes.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## canary #14008 +/- ##
==========================================
- Coverage 57.15% 56.49% -0.67%
==========================================
Files 2757 2757
Lines 137728 137728
Branches 21155 21019 -136
==========================================
- Hits 78724 77809 -915
- Misses 56776 58201 +1425
+ Partials 2228 1718 -510
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Implements feature outlined here
OIDC Launch URL
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.