1
0
forked from baron/baron-sso

style: fix formatting issues caught by biome in adminfront

This commit is contained in:
2026-04-21 17:11:08 +09:00
parent 4427ab1f85
commit 7f955e2122
6 changed files with 44 additions and 19 deletions

View File

@@ -80,7 +80,11 @@ function AppLayout() {
}; };
}, []); }, []);
const { data: profile, isLoading: isProfileLoading, error: profileError } = useQuery({ const {
data: profile,
isLoading: isProfileLoading,
error: profileError,
} = useQuery({
queryKey: ["me"], queryKey: ["me"],
queryFn: async () => { queryFn: async () => {
console.debug("[AppLayout] Fetching profile..."); console.debug("[AppLayout] Fetching profile...");
@@ -184,7 +188,7 @@ function AppLayout() {
console.debug("[AppLayout] Auth state check:", { console.debug("[AppLayout] Auth state check:", {
isLoading: auth.isLoading, isLoading: auth.isLoading,
isAuthenticated: auth.isAuthenticated, isAuthenticated: auth.isAuthenticated,
isTest isTest,
}); });
if (!auth.isLoading && !auth.isAuthenticated && !isTest) { if (!auth.isLoading && !auth.isAuthenticated && !isTest) {

View File

@@ -11,7 +11,7 @@ function AuthCallbackPage() {
console.debug("[AuthCallbackPage] State:", { console.debug("[AuthCallbackPage] State:", {
isAuthenticated: auth.isAuthenticated, isAuthenticated: auth.isAuthenticated,
isLoading: auth.isLoading, isLoading: auth.isLoading,
error: auth.error error: auth.error,
}); });
if (auth.isAuthenticated) { if (auth.isAuthenticated) {
// Save token to localStorage for existing API clients that might still use it // Save token to localStorage for existing API clients that might still use it
@@ -26,7 +26,10 @@ function AuthCallbackPage() {
typeof auth.user.state.returnTo === "string" typeof auth.user.state.returnTo === "string"
? auth.user.state.returnTo ? auth.user.state.returnTo
: "/"; : "/";
console.info("[AuthCallbackPage] Auth successful, navigating to", returnTo); console.info(
"[AuthCallbackPage] Auth successful, navigating to",
returnTo,
);
navigate(returnTo, { replace: true }); navigate(returnTo, { replace: true });
} else if (auth.error) { } else if (auth.error) {
console.error("[AuthCallbackPage] Auth Error:", auth.error); console.error("[AuthCallbackPage] Auth Error:", auth.error);

View File

@@ -23,10 +23,13 @@ function LoginPage() {
console.debug("[LoginPage] Auth state check:", { console.debug("[LoginPage] Auth state check:", {
isAuthenticated: auth.isAuthenticated, isAuthenticated: auth.isAuthenticated,
isLoading: auth.isLoading, isLoading: auth.isLoading,
returnTo returnTo,
}); });
if (auth.isAuthenticated) { if (auth.isAuthenticated) {
console.info("[LoginPage] User is authenticated, redirecting to", returnTo); console.info(
"[LoginPage] User is authenticated, redirecting to",
returnTo,
);
navigate(returnTo, { replace: true }); navigate(returnTo, { replace: true });
} }
}, [auth.isAuthenticated, navigate, returnTo, auth.isLoading]); }, [auth.isAuthenticated, navigate, returnTo, auth.isLoading]);

View File

@@ -11,7 +11,8 @@ const apiClient = axios.create({
apiClient.interceptors.request.use(async (config) => { apiClient.interceptors.request.use(async (config) => {
// IdP 중립 Auth 레이어 연동: oidc-client의 userManager에서 최신 토큰을 가져옵니다. // IdP 중립 Auth 레이어 연동: oidc-client의 userManager에서 최신 토큰을 가져옵니다.
const user = await userManager.getUser(); const user = await userManager.getUser();
const sessionToken = user?.access_token || window.localStorage.getItem("admin_session"); const sessionToken =
user?.access_token || window.localStorage.getItem("admin_session");
if (sessionToken) { if (sessionToken) {
config.headers.Authorization = `Bearer ${sessionToken}`; config.headers.Authorization = `Bearer ${sessionToken}`;
@@ -38,7 +39,9 @@ apiClient.interceptors.response.use(
(response) => response, (response) => response,
async (error) => { async (error) => {
if (error.response?.status === 401) { if (error.response?.status === 401) {
console.warn("[apiClient] 401 Unauthorized detected. Clearing session state."); console.warn(
"[apiClient] 401 Unauthorized detected. Clearing session state.",
);
// 로컬 스토리지의 세션 키 제거 // 로컬 스토리지의 세션 키 제거
window.localStorage.removeItem("admin_session"); window.localStorage.removeItem("admin_session");
@@ -51,7 +54,10 @@ apiClient.interceptors.response.use(
const isLoginPath = window.location.pathname === "/login"; const isLoginPath = window.location.pathname === "/login";
if (!isAuthPath && !isLoginPath) { if (!isAuthPath && !isLoginPath) {
console.info("[apiClient] Redirecting to /login from", window.location.pathname); console.info(
"[apiClient] Redirecting to /login from",
window.location.pathname,
);
window.location.href = "/login"; window.location.href = "/login";
} }
} }

View File

@@ -2,8 +2,7 @@ import { UserManager, WebStorageStateStore } from "oidc-client-ts";
import type { AuthProviderProps } from "react-oidc-context"; import type { AuthProviderProps } from "react-oidc-context";
export const oidcConfig: AuthProviderProps = { export const oidcConfig: AuthProviderProps = {
authority: authority: import.meta.env.VITE_OIDC_AUTHORITY || "https://sso.hmac.kr/oidc", // Gateway Proxy URL
import.meta.env.VITE_OIDC_AUTHORITY || "https://sso.hmac.kr/oidc", // Gateway Proxy URL
client_id: import.meta.env.VITE_OIDC_CLIENT_ID || "adminfront", client_id: import.meta.env.VITE_OIDC_CLIENT_ID || "adminfront",
redirect_uri: `${window.location.origin}/auth/callback`, redirect_uri: `${window.location.origin}/auth/callback`,
response_type: "code", response_type: "code",

View File

@@ -29,7 +29,9 @@ export function shouldAttemptSlidingSessionRenew({
} }
if (typeof expiresAtSec !== "number") { if (typeof expiresAtSec !== "number") {
console.debug("[sessionSliding] expiresAtSec is not a number, skipping renew"); console.debug(
"[sessionSliding] expiresAtSec is not a number, skipping renew",
);
return false; return false;
} }
@@ -50,7 +52,9 @@ export function shouldAttemptSlidingSessionRenew({
return false; return false;
} }
console.info(`[sessionSliding] Attempting sliding session renewal. Remaining: ${remainingMin}m`); console.info(
`[sessionSliding] Attempting sliding session renewal. Remaining: ${remainingMin}m`,
);
return true; return true;
} }
@@ -70,7 +74,9 @@ export function shouldAttemptUnlimitedSessionRenew({
} }
if (typeof expiresAtSec !== "number") { if (typeof expiresAtSec !== "number") {
console.debug("[sessionSliding] expiresAtSec is not a number, skipping unlimited renew"); console.debug(
"[sessionSliding] expiresAtSec is not a number, skipping unlimited renew",
);
return false; return false;
} }
@@ -78,7 +84,9 @@ export function shouldAttemptUnlimitedSessionRenew({
const remainingMin = Math.floor(remainingMs / 1000 / 60); const remainingMin = Math.floor(remainingMs / 1000 / 60);
if (remainingMs <= 0) { if (remainingMs <= 0) {
console.debug("[sessionSliding] Session already expired, skipping unlimited renew"); console.debug(
"[sessionSliding] Session already expired, skipping unlimited renew",
);
return false; return false;
} }
@@ -91,6 +99,8 @@ export function shouldAttemptUnlimitedSessionRenew({
return false; return false;
} }
console.info(`[sessionSliding] Attempting unlimited session renewal. Remaining: ${remainingMin}m`); console.info(
`[sessionSliding] Attempting unlimited session renewal. Remaining: ${remainingMin}m`,
);
return true; return true;
} }