| | |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.ServletException; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | |
| | | /** |
| | | * Spring Security配置 |
| | |
| | | public class SecurityConfig extends WebSecurityConfigurerAdapter { |
| | | |
| | | public static final String[] FILTER_PATH = new String[]{ |
| | | "/api/**", |
| | | "/test/**", |
| | | "/rpc/**", |
| | | "/api/login", |
| | | "/druid/**", |
| | | "/swagger-ui.html", |
| | |
| | | static class JwtAccessDeniedHandler implements AccessDeniedHandler { |
| | | |
| | | @Override |
| | | public void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException e) |
| | | throws IOException, ServletException { |
| | | public void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException e) { |
| | | HttpUtils.responseError(response, Constants.UNAUTHORIZED_CODE, Constants.UNAUTHORIZED_MSG, e.getMessage()); |
| | | } |
| | | |
| | |
| | | static class JwtAuthenticationEntryPoint implements AuthenticationEntryPoint { |
| | | |
| | | @Override |
| | | public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException e) |
| | | throws IOException, ServletException { |
| | | public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException e) { |
| | | HttpUtils.responseError(response, Constants.UNAUTHENTICATED_CODE, Constants.UNAUTHENTICATED_MSG, |
| | | e.getMessage()); |
| | | } |