-
Notifications
You must be signed in to change notification settings - Fork 48
feat: Multi-provider social auth, proxy updates, and RBAC fixes (vertex app) #3575
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
Merged
Merged
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
1ff2486
Enable hCaptcha for prod/staging when site key set
Codebmk edfa491
Add social auth section and OAuth helpers
Codebmk 69b663b
Merge branch 'staging' into renable-hcaptcha-and-social-auth
Codebmk 762208b
Update auth redirects, middleware, and API proxy
Codebmk 7510be3
Enable hCaptcha in development
Codebmk 9508585
Add NETWORK.VIEW to role permissions
Codebmk 39c9899
Update changelog.md
Codebmk 0de31e7
Correct file paths to follow vertex changelog convention.
Codebmk 0486642
Merge branch 'staging' into renable-hcaptcha-and-social-auth
Codebmk f2e76bf
Merge branch 'staging' into renable-hcaptcha-and-social-auth
Codebmk ccbad26
Update changelog.md
Codebmk 7a886a4
Update changelog.md
Codebmk 1ce578e
Correct file paths to follow vertex changelog convention
Codebmk 7012b61
OAuth failure banner may not be visible on the email step
Codebmk 02e3d6d
Persist the selected provider before redirecting OAuth.
Codebmk 70799d6
Fix NextAuth auth gating in src/vertex/middleware.ts
Codebmk 8d5f5c9
Consolidate/mirror legacy redirects across Vertex Next.js configs
Codebmk b0612a7
Handle OAuth token handoff and middleware bypass
Codebmk 7eda50d
Update changelog.md
Codebmk 9eb0f12
Improve OAuth redirect handling in authProvider
Codebmk cfd1003
Update changelog.md
Codebmk 47acf76
Integrate group onboarding checklist sync
Codebmk 86ef263
Use secureApiProxy and auto-sync onboarding steps
Codebmk c9e6680
Add group hooks and use in welcome page
Codebmk 4574438
Update changelog.md
Codebmk 44c2f62
Add cleanup for setTimeout to prevent post-unmount execution.
Codebmk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 0 additions & 71 deletions
71
src/vertex/components/features/auth/google-auth-section.tsx
This file was deleted.
Oops, something went wrong.
160 changes: 160 additions & 0 deletions
160
src/vertex/components/features/auth/social-auth-section.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,160 @@ | ||
| 'use client'; | ||
|
|
||
| import { useCallback, useEffect, useState } from 'react'; | ||
| import { FaGithub, FaLinkedinIn } from 'react-icons/fa'; | ||
| import { FaXTwitter } from 'react-icons/fa6'; | ||
| import { FcGoogle } from 'react-icons/fc'; | ||
| import { | ||
| buildOAuthInitiationUrl, | ||
| getLastUsedOAuthProvider, | ||
| resolveOAuthRedirectAfterUrl, | ||
| setLastUsedOAuthProvider, | ||
| type SupportedSocialAuthProvider, | ||
| } from '@/core/auth/oauth-session'; | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| import { cn } from '@/lib/utils'; | ||
| import { useBanner } from '@/context/banner-context'; | ||
| import { getLastActiveModule } from '@/core/utils/userPreferences'; | ||
|
|
||
| interface SocialAuthSectionProps { | ||
| mode: 'login' | 'register'; | ||
| disabled?: boolean; | ||
| className?: string; | ||
| callbackUrl?: string | null; | ||
| } | ||
|
|
||
| const SOCIAL_PROVIDERS: Array<{ | ||
| provider: SupportedSocialAuthProvider; | ||
| label: string; | ||
| Icon: React.ComponentType<{ className?: string }>; | ||
| iconClassName?: string; | ||
| }> = [ | ||
| { | ||
| provider: 'google', | ||
| label: 'Google', | ||
| Icon: FcGoogle, | ||
| }, | ||
| { | ||
| provider: 'github', | ||
| label: 'GitHub', | ||
| Icon: FaGithub, | ||
| iconClassName: 'text-slate-950 dark:text-white', | ||
| }, | ||
| { | ||
| provider: 'linkedin', | ||
| label: 'LinkedIn', | ||
| Icon: FaLinkedinIn, | ||
| iconClassName: 'text-[#0A66C2]', | ||
| }, | ||
| { | ||
| provider: 'twitter', | ||
| label: 'X', | ||
| Icon: FaXTwitter, | ||
| iconClassName: 'text-slate-950 dark:text-white', | ||
| }, | ||
| ]; | ||
|
|
||
| export default function SocialAuthSection({ | ||
| mode, | ||
| disabled = false, | ||
| className, | ||
| callbackUrl, | ||
| }: SocialAuthSectionProps) { | ||
| const { showBanner } = useBanner(); | ||
| const actionLabel = mode === 'register' ? 'Continue with' : 'Sign in with'; | ||
| const lastModule = getLastActiveModule(); | ||
| const fallbackUrl = lastModule === 'admin' ? '/admin/networks' : '/home'; | ||
| const redirectPath = callbackUrl || fallbackUrl; | ||
| const [lastUsedProvider, setLastUsedProvider] = | ||
| useState<SupportedSocialAuthProvider | null>(null); | ||
|
|
||
| useEffect(() => { | ||
| setLastUsedProvider(getLastUsedOAuthProvider()); | ||
| }, []); | ||
|
|
||
| const orderedProviders = lastUsedProvider | ||
| ? [ | ||
| ...SOCIAL_PROVIDERS.filter( | ||
| ({ provider }) => provider === lastUsedProvider | ||
| ), | ||
| ...SOCIAL_PROVIDERS.filter( | ||
| ({ provider }) => provider !== lastUsedProvider | ||
| ), | ||
| ] | ||
| : SOCIAL_PROVIDERS; | ||
|
|
||
| const handleSocialAuth = useCallback( | ||
| (provider: SupportedSocialAuthProvider) => { | ||
| if (typeof window === 'undefined' || disabled) return; | ||
|
|
||
| const redirectAfter = resolveOAuthRedirectAfterUrl(redirectPath); | ||
| const queryParams: Record<string, string> = {}; | ||
|
|
||
| if (redirectAfter) { | ||
| queryParams.redirect_after = redirectAfter; | ||
| } | ||
|
|
||
|
|
||
| try { | ||
| setLastUsedOAuthProvider(provider); | ||
| window.location.replace(buildOAuthInitiationUrl(provider, queryParams)); | ||
| } catch (error) { | ||
| showBanner({ | ||
| severity: 'error', | ||
| message: `Social sign-in unavailable. Please try again in a moment.`, | ||
| scoped: true, | ||
| }); | ||
| console.error(`Failed to start ${provider} OAuth flow:`, error); | ||
| } | ||
| }, | ||
| [disabled, redirectPath, showBanner] | ||
| ); | ||
|
|
||
| return ( | ||
| <div className={cn('w-full space-y-4', className)}> | ||
| <div className="grid grid-cols-4 gap-2"> | ||
| {orderedProviders.map(({ provider, label, Icon, iconClassName }) => { | ||
| const isLastUsed = provider === lastUsedProvider; | ||
|
|
||
| return ( | ||
| <button | ||
| key={provider} | ||
| type="button" | ||
| disabled={disabled} | ||
| onClick={() => handleSocialAuth(provider)} | ||
| aria-label={`${actionLabel} ${label}`} | ||
| title={`${actionLabel} ${label}`} | ||
| className={cn( | ||
| 'relative flex h-10 items-center justify-center overflow-hidden rounded-md border bg-white px-1.5 text-gray-900 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-primary/40 disabled:cursor-not-allowed disabled:border-slate-300 disabled:bg-white disabled:text-gray-400 dark:bg-transparent dark:text-gray-100 dark:disabled:border-slate-700 dark:disabled:bg-transparent dark:disabled:text-gray-500', | ||
| isLastUsed | ||
| ? 'border-primary/50 bg-primary/5 hover:bg-primary/10 dark:border-primary/50 dark:bg-slate-900' | ||
| : 'border-slate-300 hover:bg-slate-50 hover:text-gray-900 dark:border-slate-700 dark:hover:bg-slate-800 dark:hover:text-gray-100' | ||
| )} | ||
| > | ||
| <Icon | ||
| className={cn( | ||
| 'h-4 w-4 transition-transform duration-200 sm:h-[17px] sm:w-[17px]', | ||
| iconClassName, | ||
| isLastUsed && 'scale-105' | ||
| )} | ||
| /> | ||
| {isLastUsed ? ( | ||
| <span className="absolute right-1 top-1 rounded-full bg-primary/10 px-1 py-0 text-[8px] font-semibold uppercase tracking-[0.08em] text-primary dark:bg-primary/15 dark:text-primary-foreground"> | ||
| Last used | ||
| </span> | ||
| ) : null} | ||
| <span className="sr-only">{`${actionLabel} ${label}`}</span> | ||
| </button> | ||
| ); | ||
| })} | ||
| </div> | ||
|
|
||
| <div className="flex items-center gap-4"> | ||
| <span className="h-px flex-1 bg-border" /> | ||
| <span className="text-xs font-bold uppercase tracking-[0.2em] text-muted-foreground"> | ||
| Or | ||
| </span> | ||
| <span className="h-px flex-1 bg-border" /> | ||
| </div> | ||
| </div> | ||
| ); | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.