forked from baron/baron-sso
feat: SSO 로그인 리다이렉션 흐름 구현 (userfront & adminfront 연동) #243
This commit is contained in:
@@ -29,10 +29,16 @@ function LoginPage() {
|
||||
return () => window.removeEventListener("message", handleMessage);
|
||||
}, [navigate]);
|
||||
|
||||
const handleSSOLogin = () => {
|
||||
const handleSSOLogin = (mode: "popup" | "redirect" = "popup") => {
|
||||
const userfrontUrl = import.meta.env.USERFRONT_URL || "https://sso.hmac.kr";
|
||||
const loginUrl = `${userfrontUrl}/ssologin?source=adminfront`;
|
||||
const callbackUrl = `${window.location.origin}/auth/callback`;
|
||||
const loginUrl = `${userfrontUrl}/ssologin?source=adminfront&redirect_uri=${encodeURIComponent(callbackUrl)}`;
|
||||
|
||||
if (mode === "redirect") {
|
||||
window.location.href = loginUrl;
|
||||
return;
|
||||
}
|
||||
|
||||
const width = 500;
|
||||
const height = 700;
|
||||
const left = window.screen.width / 2 - width / 2;
|
||||
@@ -54,7 +60,8 @@ function LoginPage() {
|
||||
}
|
||||
}, 1000);
|
||||
} else {
|
||||
alert("팝업 차단이 설정되어 있습니다. 팝업 허용 후 다시 시도해 주세요.");
|
||||
// If popup blocked, fallback to redirect
|
||||
window.location.href = loginUrl;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -83,9 +90,9 @@ function LoginPage() {
|
||||
Baron 통합 인증(SSO)을 통해 관리자 페이지에 접속합니다.
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent className="pt-4 pb-8">
|
||||
<CardContent className="pt-4 pb-8 space-y-3">
|
||||
<Button
|
||||
onClick={handleSSOLogin}
|
||||
onClick={() => handleSSOLogin("popup")}
|
||||
className="w-full h-14 text-lg font-semibold flex gap-3 shadow-lg"
|
||||
disabled={isLoggingIn}
|
||||
>
|
||||
@@ -97,11 +104,20 @@ function LoginPage() {
|
||||
) : (
|
||||
<>
|
||||
<ShieldHalf size={22} />
|
||||
SSO 계정으로 로그인
|
||||
팝업창으로 로그인
|
||||
<ExternalLink size={16} className="opacity-50" />
|
||||
</>
|
||||
)}
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
variant="outline"
|
||||
onClick={() => handleSSOLogin("redirect")}
|
||||
className="w-full h-12 text-base font-medium flex gap-3"
|
||||
disabled={isLoggingIn}
|
||||
>
|
||||
현재 창에서 로그인 (리다이렉트)
|
||||
</Button>
|
||||
|
||||
<p className="mt-6 text-xs text-center text-muted-foreground leading-relaxed">
|
||||
관리자 전역 세션은 보안을 위해 15분간 유지됩니다.<br />
|
||||
|
||||
Reference in New Issue
Block a user