remove call to currentUserService to prevent 401 on not logged in users
LocationBasedServices/sumoc-backend/pipeline/head This commit looks good
LocationBasedServices/sumoc-backend/pipeline/head This commit looks good
This commit is contained in:
@@ -37,12 +37,6 @@ class RoutingAlternativeController {
|
||||
public ResponseEntity<List<RouteDTO>> requestAlternativeRoutes(@Valid @RequestBody RoutingAlternativeRequestDTO routingAlternativeRequestDTO) {
|
||||
try {
|
||||
|
||||
if (currentUserService.isAuthenticated()) {
|
||||
logger.info("Authenticaed user is making request: " + currentUserService.get().getEmail());
|
||||
} else {
|
||||
logger.info("Unauthenticated user is making request.");
|
||||
}
|
||||
|
||||
if (routingAlternativeRequestDTO.getRoutingPreferencesDTO() == null) {
|
||||
// This automatically uses default preferences for unauthenticated users
|
||||
routingAlternativeRequestDTO.setRoutingPreferencesDTO(routingPreferencesService.getRoutingPreferencesForCurrentUser());
|
||||
|
||||
@@ -41,8 +41,6 @@ import static org.springframework.security.config.Customizer.withDefaults;
|
||||
public class SecurityConfiguration {
|
||||
|
||||
private static final String[] AUTH_WHITELIST = {
|
||||
"/routing/alternative/request",
|
||||
"/routing/directions/request",
|
||||
"/api/v1/auth/**",
|
||||
"/v3/api-docs/**",
|
||||
"/v3/api-docs.yaml",
|
||||
|
||||
@@ -33,6 +33,7 @@ public class CurrentUserService {
|
||||
}
|
||||
|
||||
public boolean isAuthenticated() {
|
||||
// TODO request with auth no auth really result in not authenticated?
|
||||
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
|
||||
return auth != null && auth.isAuthenticated();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user