Skip to content
This repository has been archived by the owner on Jul 29, 2024. It is now read-only.

[BE] fix: AuthInterceptor "/auth/token/refresh" 경로 제외 #431

Merged
merged 1 commit into from
Sep 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
import lombok.RequiredArgsConstructor;
import org.donggle.backend.application.repository.TokenRepository;
import org.donggle.backend.domain.auth.JwtTokenProvider;
import org.donggle.backend.ui.common.AuthInterceptor;
import org.donggle.backend.ui.common.RefreshTokenAuthInterceptor;
import org.donggle.backend.ui.common.TokenArgumentResolver;
import org.donggle.backend.ui.common.MDCInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpHeaders;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
Expand All @@ -23,16 +19,6 @@ public class WebMvcConfig implements WebMvcConfigurer {
private final JwtTokenProvider jwtTokenProvider;
private final TokenRepository tokenRepository;

@Override
public void addCorsMappings(final CorsRegistry registry) {
registry.addMapping("/**")
.allowedOrigins("*")
.allowedMethods("*")
.allowedHeaders("*")
.exposedHeaders(HttpHeaders.LOCATION)
.maxAge(3600);
}

@Override
public void addInterceptors(final InterceptorRegistry registry) {
registry.addInterceptor(mdcInterceptor)
Expand All @@ -41,14 +27,24 @@ public void addInterceptors(final InterceptorRegistry registry) {

registry.addInterceptor(new AuthInterceptor(jwtTokenProvider))
.addPathPatterns("/member/**", "/writings/**", "/categories/**", "/trash/**", "/connections/**", "/auth/**")
.excludePathPatterns("/connections/**/redirect", "/auth/login/**")
.excludePathPatterns("/connections/**/redirect", "/auth/login/**", "/auth/token/refresh")
.order(2);

registry.addInterceptor(new RefreshTokenAuthInterceptor(jwtTokenProvider, tokenRepository))
.addPathPatterns("/token/refresh")
.addPathPatterns("/auth/token/refresh")
.order(3);
}

@Override
public void addCorsMappings(final CorsRegistry registry) {
registry.addMapping("/**")
.allowedOrigins("*")
.allowedMethods("*")
.allowedHeaders("*")
.exposedHeaders(HttpHeaders.LOCATION)
.maxAge(3600);
}

@Override
public void addArgumentResolvers(final List<HandlerMethodArgumentResolver> resolvers) {
resolvers.add(new TokenArgumentResolver(jwtTokenProvider));
Expand Down