update loket dan monitoring

This commit is contained in:
Fanrouver
2026-01-19 15:27:50 +07:00
parent f2efd8355e
commit 81b877bb7f
5 changed files with 383 additions and 175 deletions

No files matched your search

+20 -5
View File
@@ -38,13 +38,27 @@ export default defineEventHandler(async (event) => {
// Construct the Keycloak logout URL with proper parameters
// IMPORTANT: The post_logout_redirect_uri must be registered in Keycloak client settings
const logoutUrl = new URL(`${config.keycloakIssuer}/protocol/openid-connect/logout`);
// Use custom logout URI from env if provided, otherwise use default
const logoutPath = config.keycloakLogoutUri || `${config.keycloakIssuer}/protocol/openid-connect/logout`;
const logoutUrl = new URL(logoutPath);
// Debug: Log the authUrl being used
// Debug: Log the authUrl and logout URI being used
console.log('🔧 Using authUrl from config:', config.public.authUrl);
if (config.keycloakLogoutUri) {
console.log('🔧 Using custom logout URI from env:', config.keycloakLogoutUri);
} else {
console.log('🔧 Using default logout URI:', logoutPath);
}
// Build the redirect URI - must match what's configured in Keycloak
const postLogoutRedirectUri = `${config.public.authUrl}/LoginPage?logout=success`;
// Use custom post-logout redirect URI from env if provided, otherwise use default
const postLogoutRedirectUri = config.postLogoutRedirectUri || `${config.public.authUrl}/LoginPage?logout=success`;
if (config.postLogoutRedirectUri) {
console.log('🔧 Using custom post-logout redirect URI from env:', config.postLogoutRedirectUri);
} else {
console.log('🔧 Using default post-logout redirect URI:', postLogoutRedirectUri);
}
// Add required parameters for proper Keycloak logout
logoutUrl.searchParams.set('client_id', config.keycloakClientId);
@@ -77,8 +91,9 @@ export default defineEventHandler(async (event) => {
// Even if there's an error, try to provide a basic logout URL
const config = useRuntimeConfig();
const postLogoutRedirectUri = `${config.public.authUrl}/LoginPage?logout=success`;
const fallbackLogoutUrl = new URL(`${config.keycloakIssuer}/protocol/openid-connect/logout`);
const postLogoutRedirectUri = config.postLogoutRedirectUri || `${config.public.authUrl}/LoginPage?logout=success`;
const logoutPath = config.keycloakLogoutUri || `${config.keycloakIssuer}/protocol/openid-connect/logout`;
const fallbackLogoutUrl = new URL(logoutPath);
fallbackLogoutUrl.searchParams.set('client_id', config.keycloakClientId);
fallbackLogoutUrl.searchParams.set('post_logout_redirect_uri', postLogoutRedirectUri);