From 317e7c2a7e41b44f242d2f471272609f755de8ee Mon Sep 17 00:00:00 2001 From: Emanuele Ferrelli Date: Wed, 4 Jun 2025 10:09:14 +0200 Subject: [PATCH] Add log for auth --- .../apollo/security/controllers/AuthController.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/java/com/olympus/apollo/security/controllers/AuthController.java b/src/main/java/com/olympus/apollo/security/controllers/AuthController.java index f31ddce..f78f51b 100644 --- a/src/main/java/com/olympus/apollo/security/controllers/AuthController.java +++ b/src/main/java/com/olympus/apollo/security/controllers/AuthController.java @@ -1,6 +1,10 @@ package com.olympus.apollo.security.controllers; import com.olympus.apollo.security.services.JwtService; +import com.olympus.apollo.services.DeletionService; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.http.ResponseEntity; import org.springframework.security.core.annotation.AuthenticationPrincipal; import org.springframework.security.oauth2.jwt.Jwt; @@ -14,6 +18,7 @@ import java.util.Map; @RequestMapping("/msauth") public class AuthController { + private static final Logger logger = LoggerFactory.getLogger(AuthController.class); private final JwtService jwtService; @@ -23,6 +28,11 @@ public class AuthController { @PostMapping("/exchange") public ResponseEntity exchangeToken(@AuthenticationPrincipal Jwt azureJwt) { + if (azureJwt == null) { + logger.info("azureJwt is null! Authentication failed."); + return ResponseEntity.status(401).body(Map.of("error", "Invalid or missing JWT")); + } + logger.info("Received JWT: " + azureJwt.getTokenValue()); String internalToken = jwtService.generateInternalToken(azureJwt); return ResponseEntity.ok(Map.of("token", internalToken)); }