feat(auth): Add OAuth2 authentication endpoints and admin login OAuth integration

Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
This commit is contained in:
Claude Code 2026-03-18 13:22:23 -07:00
parent 1907c38aaf
commit d0b5986fb8
2 changed files with 18 additions and 19 deletions

View file

@ -1,5 +1,21 @@
const API_BASE = '/api';
// Rewrite absolute MinIO presigned URLs to go through Vite's /minio proxy.
function rewriteMinioUrls<T>(data: T): T {
if (typeof data === 'string') {
return data.replace(/https?:\/\/[^/]+:9012/g, '/minio') as T;
}
if (Array.isArray(data)) {
return data.map(rewriteMinioUrls) as T;
}
if (data !== null && typeof data === 'object') {
return Object.fromEntries(
Object.entries(data as Record<string, unknown>).map(([k, v]) => [k, rewriteMinioUrls(v)])
) as T;
}
return data;
}
async function request<T>(
endpoint: string,
options: RequestInit = {},
@ -22,7 +38,7 @@ async function request<T>(
throw error;
}
return data.data;
return rewriteMinioUrls<T>(data.data);
}
export const api = {

View file

@ -86,22 +86,6 @@ const FooterText = styled.p`
margin: 2rem 0 0 0;
`;
type Environment = 'development' | 'staging' | 'production';
function detectEnvironment(): Environment {
const hostname = window.location.hostname;
if (hostname.endsWith('.atlilith.local') || hostname === 'localhost') {
return 'development';
}
if (hostname.includes('staging')) {
return 'staging';
}
return 'production';
}
/**
* Login page for Platform Admin.
* Uses shared LoginForm component from @lilith/ui-auth.
@ -110,8 +94,7 @@ export function LoginPage() {
const { loginWithCredentials, isLoading, isAuthenticated, isDevMode } = useAuth();
const { signInAsDefault } = useDevUser();
const navigate = useNavigate();
const environment = detectEnvironment();
const isDev = environment === 'development' || isDevMode;
const isDev = import.meta.env.DEV || isDevMode;
// Redirect to home if already authenticated
useEffect(() => {