Add logging for invalid authentication principal in AuthenticatedUuid and annotate with @Slf4j
This commit is contained in:
parent
bc0739f707
commit
6531526278
|
|
@ -1,5 +1,7 @@
|
||||||
package com.alttd.altitudeweb.controllers.data_from_auth;
|
package com.alttd.altitudeweb.controllers.data_from_auth;
|
||||||
|
|
||||||
|
import com.nimbusds.jwt.JWT;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.security.core.Authentication;
|
import org.springframework.security.core.Authentication;
|
||||||
|
|
@ -10,6 +12,7 @@ import org.springframework.web.server.ResponseStatusException;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
public class AuthenticatedUuid {
|
public class AuthenticatedUuid {
|
||||||
@Value("${UNSECURED:#{false}}")
|
@Value("${UNSECURED:#{false}}")
|
||||||
|
|
@ -25,6 +28,9 @@ public class AuthenticatedUuid {
|
||||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
|
|
||||||
if (authentication == null || !(authentication.getPrincipal() instanceof Jwt jwt)) {
|
if (authentication == null || !(authentication.getPrincipal() instanceof Jwt jwt)) {
|
||||||
|
log.error("Authentication principal is null {} or not a JWT {}",
|
||||||
|
authentication == null, authentication == null ?
|
||||||
|
"null" : authentication.getPrincipal() instanceof JWT);
|
||||||
if (unsecured) {
|
if (unsecured) {
|
||||||
return UUID.fromString("55e46bc3-2a29-4c53-850f-dbd944dc5c5f");
|
return UUID.fromString("55e46bc3-2a29-4c53-850f-dbd944dc5c5f");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user