Add log for auth
This commit is contained in:
@@ -1,6 +1,9 @@
|
|||||||
package com.olympus.hermione.security.controllers;
|
package com.olympus.hermione.security.controllers;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.security.oauth2.jwt.Jwt;
|
import org.springframework.security.oauth2.jwt.Jwt;
|
||||||
import org.springframework.security.core.annotation.AuthenticationPrincipal;
|
import org.springframework.security.core.annotation.AuthenticationPrincipal;
|
||||||
@@ -12,6 +15,7 @@ import com.olympus.hermione.security.services.JwtService;
|
|||||||
@RequestMapping("/msauth")
|
@RequestMapping("/msauth")
|
||||||
public class AuthController {
|
public class AuthController {
|
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(AuthController.class);
|
||||||
|
|
||||||
private final JwtService jwtService;
|
private final JwtService jwtService;
|
||||||
|
|
||||||
@@ -21,6 +25,11 @@ public class AuthController {
|
|||||||
|
|
||||||
@PostMapping("/exchange")
|
@PostMapping("/exchange")
|
||||||
public ResponseEntity<?> exchangeToken(@AuthenticationPrincipal Jwt azureJwt) {
|
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);
|
String internalToken = jwtService.generateInternalToken(azureJwt);
|
||||||
return ResponseEntity.ok(Map.of("token", internalToken));
|
return ResponseEntity.ok(Map.of("token", internalToken));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user