From 140098f2515d5fd72c13f5f728b036e71e30f99e Mon Sep 17 00:00:00 2001 From: Bennett Date: Thu, 19 Mar 2026 11:26:35 +0300 Subject: [PATCH 1/2] release: Fix error loading session users --- .../flextuma/core/config/DataInitializer.java | 1 + .../core/config/RequestLoggingFilter.java | 47 +++++++++++++++++-- src/main/resources/application.properties | 4 ++ 3 files changed, 49 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/flexcodelabs/flextuma/core/config/DataInitializer.java b/src/main/java/com/flexcodelabs/flextuma/core/config/DataInitializer.java index 3605ae1..2f5df14 100644 --- a/src/main/java/com/flexcodelabs/flextuma/core/config/DataInitializer.java +++ b/src/main/java/com/flexcodelabs/flextuma/core/config/DataInitializer.java @@ -17,6 +17,7 @@ public class DataInitializer implements CommandLineRunner { @Override public void run(String... args) { + log.info("🚀🚀🚀 DataInitializer.run() called! 🚀🚀🚀"); log.info("🚀 FLEXTUMA: Application started - checking system data seeds..."); try { log.info("🌱 FLEXTUMA: Calling seeder service..."); diff --git a/src/main/java/com/flexcodelabs/flextuma/core/config/RequestLoggingFilter.java b/src/main/java/com/flexcodelabs/flextuma/core/config/RequestLoggingFilter.java index e6741a5..5f9f756 100644 --- a/src/main/java/com/flexcodelabs/flextuma/core/config/RequestLoggingFilter.java +++ b/src/main/java/com/flexcodelabs/flextuma/core/config/RequestLoggingFilter.java @@ -20,6 +20,7 @@ public class RequestLoggingFilter extends OncePerRequestFilter { private static final Logger log = LoggerFactory.getLogger("FLEXTUMA"); + private static final String USERNAME_KEY = "username"; @Override protected boolean shouldNotFilterErrorDispatch() { @@ -80,7 +81,7 @@ private void logRequest(HttpServletRequest request, HttpServletResponse response String coloredMethod = logColor + request.getMethod() + reset; String coloredUri = logColor + fullUri + reset; - org.slf4j.MDC.put("username", username); + org.slf4j.MDC.put(USERNAME_KEY, username); try { if (isError) { log.error("{} {} {} {} {}ms - Status: {}", statusLog, userInfo, coloredMethod, coloredUri, duration, @@ -90,15 +91,55 @@ private void logRequest(HttpServletRequest request, HttpServletResponse response status); } } finally { - org.slf4j.MDC.remove("username"); + org.slf4j.MDC.remove(USERNAME_KEY); } } private String getUsername() { Authentication auth = SecurityContextHolder.getContext().getAuthentication(); + + // Debug logging to understand the authentication context + if (auth != null) { + log.debug("Auth class: {}", auth.getClass().getSimpleName()); + log.debug("Auth authenticated: {}", auth.isAuthenticated()); + log.debug("Auth principal: {}", auth.getPrincipal()); + log.debug("Auth name: {}", auth.getName()); + log.debug("Auth details: {}", auth.getDetails()); + } else { + log.debug("Authentication is null"); + } + if (auth != null && auth.isAuthenticated() && !"anonymousUser".equals(auth.getPrincipal())) { - return auth.getName(); + String username = auth.getName(); + // Don't return "SYSTEM" for actual authenticated users + if (username != null && !username.trim().isEmpty() && !"SYSTEM".equalsIgnoreCase(username)) { + return username; + } + } + + // For login requests, try to extract username from request parameters + HttpServletRequest request = getCurrentRequest(); + if (request != null && request.getRequestURI().contains("/login")) { + String loginUsername = request.getParameter(USERNAME_KEY); + if (loginUsername != null && !loginUsername.trim().isEmpty()) { + return loginUsername; + } } + return "SYSTEM"; } + + private HttpServletRequest getCurrentRequest() { + // Try to get current request from RequestContextHolder + try { + org.springframework.web.context.request.RequestAttributes attrs = org.springframework.web.context.request.RequestContextHolder + .getRequestAttributes(); + if (attrs instanceof org.springframework.web.context.request.ServletRequestAttributes servletRequestAttributes) { + return servletRequestAttributes.getRequest(); + } + } catch (Exception e) { + // Ignore - can't get current request + } + return null; + } } \ No newline at end of file diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 639fee6..44cdcea 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -8,6 +8,10 @@ logging.config=classpath:logback-spring.xml spring.output.ansi.enabled=ALWAYS spring.devtools.restart.enabled=true +# Enable INFO logging to see startup and seeding +logging.level.com.flexcodelabs.flextuma=INFO +logging.level.org.springframework.boot.autoconfigure=INFO + spring.data.redis.host=${REDIS_HOST:redis} spring.data.redis.port=${REDIS_PORT:6379} spring.data.redis.repositories.enabled=false From 9f296f5e34d68c67863b9fd58810d36856efb1b0 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 19 Mar 2026 08:27:08 +0000 Subject: [PATCH 2/2] Release v0.0.25 [skip ci] --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 56f5483..7ee8ece 100644 --- a/build.gradle +++ b/build.gradle @@ -8,7 +8,7 @@ plugins { } group = 'com.flexcodelabs' -version = '0.0.24' +version = '0.0.25' description = 'Flextuma App' java {