From f432ae5c3e87c588db2f27978fcd3cee1c958842 Mon Sep 17 00:00:00 2001 From: su080915 Date: Mon, 26 Aug 2024 18:14:30 +0900 Subject: [PATCH] fixed config --- .../config/security/SecurityConfig.java | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/crescendo-server/src/main/java/com/example/crescendoserver/global/config/security/SecurityConfig.java b/crescendo-server/src/main/java/com/example/crescendoserver/global/config/security/SecurityConfig.java index 7b15c83..d8158d0 100644 --- a/crescendo-server/src/main/java/com/example/crescendoserver/global/config/security/SecurityConfig.java +++ b/crescendo-server/src/main/java/com/example/crescendoserver/global/config/security/SecurityConfig.java @@ -1,5 +1,9 @@ package com.example.crescendoserver.global.config.security; +import com.example.crescendoserver.global.security.jwt.filter.JwtAuthenticationFilter; +import com.example.crescendoserver.global.security.jwt.filter.JwtExceptionFilter; +import com.example.crescendoserver.global.security.jwt.handler.JwtAccessDeniedHandler; +import com.example.crescendoserver.global.security.jwt.handler.JwtAuthenticationEntryPoint; import lombok.RequiredArgsConstructor; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -16,10 +20,10 @@ @RequiredArgsConstructor @EnableWebSecurity public class SecurityConfig { -// private final JwtAuthenticationEntryPoint jwtAuthenticationEntryPoint; -// private final JwtAccessDeniedHandler jwtAccessDeniedHandler; -// private final JwtAuthenticationFilter jwtAuthenticationFilter; -// private final JwtExceptionFilter jwtExceptionFilter; + private final JwtAuthenticationEntryPoint jwtAuthenticationEntryPoint; + private final JwtAccessDeniedHandler jwtAccessDeniedHandler; + private final JwtAuthenticationFilter jwtAuthenticationFilter; + private final JwtExceptionFilter jwtExceptionFilter; @Bean public PasswordEncoder passwordEncoder() { @@ -36,10 +40,10 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { .rememberMe(AbstractHttpConfigurer::disable) .logout(AbstractHttpConfigurer::disable) -// .exceptionHandling((configurer) -> configurer -// .accessDeniedHandler(jwtAccessDeniedHandler) -// .authenticationEntryPoint(jwtAuthenticationEntryPoint) -// ) + .exceptionHandling((configurer) -> configurer + .accessDeniedHandler(jwtAccessDeniedHandler) + .authenticationEntryPoint(jwtAuthenticationEntryPoint) + ) .authorizeHttpRequests((configurer) -> configurer .requestMatchers(HttpMethod.POST, "/auth/signup", "/auth/login", "/auth/reissue").anonymous() @@ -52,8 +56,8 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { .requestMatchers(HttpMethod.GET, "/chat").permitAll() ) -// .addFilterBefore(jwtAuthenticationFilter, UsernamePasswordAuthenticationFilter.class) -// .addFilterBefore(jwtExceptionFilter, JwtAuthenticationFilter.class) + .addFilterBefore(jwtAuthenticationFilter, UsernamePasswordAuthenticationFilter.class) + .addFilterBefore(jwtExceptionFilter, JwtAuthenticationFilter.class) .build(); } }