-
Notifications
You must be signed in to change notification settings - Fork 3.3k
feat(sso): add support for login with SAML/SSO #1489
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
13 commits
Select commit
Hold shift + click to select a range
97594f1
feat(sso): added login with SAML/SSO
waleedlatif1 fbacd9f
restore env
waleedlatif1 0843ccd
fixed login styling
waleedlatif1 f503796
upgrade deps, update UI
waleedlatif1 941dcc9
more styling improvements
waleedlatif1 8c82a88
reran migrations, tested with script
c5eb080
improvement(auth): created SSO page
emir-karabeg d71667c
improvement(auth): remove email option for SSO if not enabled
emir-karabeg 59287df
cleanup
669d77e
cleaned up, added documentation for SSO/SAML config + tested register…
96260b6
cleanup
cb262b1
ack PR comments
1d930a0
move sso known providers to consts
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
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,53 @@ | ||
| 'use client' | ||
|
|
||
| import { useRouter } from 'next/navigation' | ||
| import { Button } from '@/components/ui/button' | ||
| import { env, isTruthy } from '@/lib/env' | ||
| import { cn } from '@/lib/utils' | ||
|
|
||
| interface SSOLoginButtonProps { | ||
| callbackURL?: string | ||
| className?: string | ||
| // Visual variant for button styling and placement contexts | ||
| // - 'primary' matches the main auth action button style | ||
| // - 'outline' matches social provider buttons | ||
| variant?: 'primary' | 'outline' | ||
| // Optional class used when variant is primary to match brand/gradient | ||
| primaryClassName?: string | ||
| } | ||
|
|
||
| export function SSOLoginButton({ | ||
| callbackURL, | ||
| className, | ||
| variant = 'outline', | ||
| primaryClassName, | ||
| }: SSOLoginButtonProps) { | ||
| const router = useRouter() | ||
|
|
||
| if (!isTruthy(env.NEXT_PUBLIC_SSO_ENABLED)) { | ||
| return null | ||
| } | ||
|
|
||
| const handleSSOClick = () => { | ||
| const ssoUrl = `/sso${callbackURL ? `?callbackUrl=${encodeURIComponent(callbackURL)}` : ''}` | ||
| router.push(ssoUrl) | ||
| } | ||
|
|
||
| const primaryBtnClasses = cn( | ||
| primaryClassName || 'auth-button-gradient', | ||
| 'flex w-full items-center justify-center gap-2 rounded-[10px] border font-medium text-[15px] text-white transition-all duration-200' | ||
| ) | ||
|
|
||
| const outlineBtnClasses = cn('w-full rounded-[10px] shadow-sm hover:bg-gray-50') | ||
|
|
||
| return ( | ||
| <Button | ||
| type='button' | ||
| onClick={handleSSOClick} | ||
| variant={variant === 'outline' ? 'outline' : undefined} | ||
| className={cn(variant === 'outline' ? outlineBtnClasses : primaryBtnClasses, className)} | ||
| > | ||
| Sign in with SSO | ||
| </Button> | ||
| ) | ||
| } | ||
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
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.
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.
style: Consider using
callbackUrlfor consistency with Next.js conventions and other auth componentsPrompt To Fix With AI