From d03a9e5eea144232c459eb330b3fd96ee2e8894c Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Sun, 21 Jan 2024 15:42:02 -0800 Subject: [PATCH] Fix controller loading. --- .../com/wisemapping/config/rest/RestAppConfig.java | 12 ++++++++---- .../java/com/wisemapping/rest/AdminController.java | 4 +--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/wise-webapp/src/main/java/com/wisemapping/config/rest/RestAppConfig.java b/wise-webapp/src/main/java/com/wisemapping/config/rest/RestAppConfig.java index 015a3535..3441dac4 100644 --- a/wise-webapp/src/main/java/com/wisemapping/config/rest/RestAppConfig.java +++ b/wise-webapp/src/main/java/com/wisemapping/config/rest/RestAppConfig.java @@ -1,6 +1,7 @@ package com.wisemapping.config.rest; import com.wisemapping.rest.MindmapController; +import jakarta.servlet.http.HttpServletResponse; import org.jetbrains.annotations.NotNull; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.Bean; @@ -11,14 +12,13 @@ import org.springframework.security.config.annotation.web.configurers.AbstractHt import org.springframework.security.config.http.SessionCreationPolicy; import org.springframework.security.web.SecurityFilterChain; import org.springframework.security.web.servlet.util.matcher.MvcRequestMatcher; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; import org.springframework.web.servlet.handler.HandlerMappingIntrospector; import static org.springframework.security.config.Customizer.withDefaults; -@SpringBootApplication -@Import({MindmapController.class, ServletConfig.class}) +@SpringBootApplication(scanBasePackageClasses = MindmapController.class) +@Import({ServletConfig.class, InterceptorsConfig.class}) @EnableWebSecurity public class RestAppConfig { @Bean @@ -29,6 +29,7 @@ public class RestAppConfig { @Bean SecurityFilterChain apiSecurityFilterChain(@NotNull final HttpSecurity http, @NotNull final MvcRequestMatcher.Builder mvc) throws Exception { return http + .securityMatcher("/**") .authorizeHttpRequests(auth -> auth .requestMatchers(mvc.pattern("/api/restfull/users/")).permitAll() .requestMatchers(mvc.pattern("/api/restfull/users/resetPassword")).permitAll() @@ -38,7 +39,10 @@ public class RestAppConfig { .requestMatchers(mvc.pattern("/**")).hasAnyRole("USER", "ADMIN") .anyRequest().authenticated() ) - + .logout(logout -> logout.permitAll() + .logoutSuccessHandler((request, response, authentication) -> { + response.setStatus(HttpServletResponse.SC_OK); + })) .csrf(AbstractHttpConfigurer::disable) .sessionManagement(session -> session.sessionCreationPolicy(SessionCreationPolicy.STATELESS)) .httpBasic(withDefaults()) diff --git a/wise-webapp/src/main/java/com/wisemapping/rest/AdminController.java b/wise-webapp/src/main/java/com/wisemapping/rest/AdminController.java index ca09ec29..cd199ad5 100644 --- a/wise-webapp/src/main/java/com/wisemapping/rest/AdminController.java +++ b/wise-webapp/src/main/java/com/wisemapping/rest/AdminController.java @@ -26,15 +26,13 @@ import com.wisemapping.model.User; import com.wisemapping.rest.model.RestUser; import com.wisemapping.service.MindmapService; import com.wisemapping.service.UserService; +import jakarta.servlet.http.HttpServletResponse; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpStatus; import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.*; -import jakarta.servlet.http.HttpServletResponse; import java.io.IOException; import java.util.List;