Add log for auth
This commit is contained in:
@@ -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));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user