-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathWebConfig.java
30 lines (24 loc) · 1.17 KB
/
WebConfig.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package nextstep.app.config;
import nextstep.security.interceptor.BasicAuthInterceptor;
import nextstep.security.interceptor.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class WebConfig implements WebMvcConfigurer {
private final LoginInterceptor loginInterceptor;
private final BasicAuthInterceptor basicAuthInterceptor;
@Autowired
public WebConfig(LoginInterceptor loginInterceptor, BasicAuthInterceptor basicAuthInterceptor) {
this.loginInterceptor = loginInterceptor;
this.basicAuthInterceptor = basicAuthInterceptor;
}
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(loginInterceptor)
.addPathPatterns("/login"); // ID/비밀번호 인증에 대한 경로
registry.addInterceptor(basicAuthInterceptor)
.addPathPatterns("/members"); // Basic 인증에 대한 경로
}
}