| | |
| | | package com.panzhihua.zuul.config; |
| | | |
| | | import com.panzhihua.zuul.filters.AppletAuthenticationFilter; |
| | | import com.panzhihua.zuul.filters.JWTAuthenticationTokenFilter; |
| | | import com.panzhihua.zuul.filters.SercuritFilter; |
| | | import com.panzhihua.zuul.handles.UserAuthAccessDeniedHandler; |
| | |
| | | */ |
| | | @Resource |
| | | private UserAuthAccessDeniedHandler userAuthAccessDeniedHandler; |
| | | |
| | | @Override |
| | | protected void configure(HttpSecurity http) throws Exception { |
| | | http.authorizeRequests() |
| | |
| | | .and() |
| | | // 配置没有权限自定义处理类 |
| | | .exceptionHandling().accessDeniedHandler(userAuthAccessDeniedHandler) |
| | | .and() |
| | | .csrf().disable(); |
| | | // 基于Token不需要session |
| | | http.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS); |
| | | // 禁用缓存 |
| | | http.headers().cacheControl(); |
| | | http.addFilterBefore(new JWTAuthenticationTokenFilter(), AnonymousAuthenticationFilter.class); |
| | | |
| | | |
| | | |
| | | |
| | | .and() |
| | | .csrf().disable(); |
| | | // 基于Token不需要session |
| | | http.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS); |
| | | // 禁用缓存 |
| | | http.headers().cacheControl(); |
| | | http.antMatcher("/api/applet/**").addFilterBefore(new AppletAuthenticationFilter(), AnonymousAuthenticationFilter.class); |
| | | http.addFilterBefore(new JWTAuthenticationTokenFilter(), AnonymousAuthenticationFilter.class); |
| | | } |
| | | } |