application.yml
jwt:
tokenHeader: Authorization
JwtInterceptor
public class JwtInterceptor implements HandlerInterceptor {
@Value("${jwt.tokenHeader}")
private String tokenHeader;
@Value("${jwt.tokenHead}")
private String tokenHead;
InterceptorConfig
@Configuration
public InterceptorConfig implements WebMvcConfigurer {
@Bean
public JwtInterceptor jwtInterceptor() {
return new JwtInterceptor();
}
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(jwtInterceptor())
.excludePathPatterns("/login/**")
.addPathPatterns("/**");
}
}