From e21396870f5e1167dc6bf861e4421120d04f657a Mon Sep 17 00:00:00 2001 From: RuoYi Date: Fri, 21 Oct 2022 11:56:15 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E8=8F=9C=E5=8D=95=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E6=B3=A8=E9=87=8A=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/ruoyi/common/core/domain/entity/SysMenu.java | 2 +- .../java/com/ruoyi/framework/config/ResourcesConfig.java | 4 +++- .../java/com/ruoyi/framework/config/SecurityConfig.java | 6 +++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysMenu.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysMenu.java index 229f41803..9f3a6f659 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysMenu.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysMenu.java @@ -54,7 +54,7 @@ public class SysMenu extends BaseEntity /** 显示状态(0显示 1隐藏) */ private String visible; - /** 菜单状态(0显示 1隐藏) */ + /** 菜单状态(0正常 1停用) */ private String status; /** 权限字符串 */ diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/ResourcesConfig.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/ResourcesConfig.java index ff1a5e519..4e067a7b1 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/ResourcesConfig.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/ResourcesConfig.java @@ -1,8 +1,10 @@ package com.ruoyi.framework.config; +import java.util.concurrent.TimeUnit; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.http.CacheControl; import org.springframework.web.cors.CorsConfiguration; import org.springframework.web.cors.UrlBasedCorsConfigurationSource; import org.springframework.web.filter.CorsFilter; @@ -34,7 +36,7 @@ public class ResourcesConfig implements WebMvcConfigurer /** swagger配置 */ registry.addResourceHandler("/swagger-ui/**") .addResourceLocations("classpath:/META-INF/resources/webjars/springfox-swagger-ui/") - .setCacheControl(CacheControl.maxAge(1, TimeUnit.DAYS).mustRevalidate().cachePrivate()).resourceChain(true); + .setCacheControl(CacheControl.maxAge(5, TimeUnit.HOURS).cachePublic());; } /** diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java index 3f7fc67cc..bdb7199fe 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java @@ -102,6 +102,8 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter httpSecurity // CSRF禁用,因为不使用session .csrf().disable() + // 禁用HTTP响应标头 + .headers().cacheControl().disable().and() // 认证失败处理类 .exceptionHandling().authenticationEntryPoint(unauthorizedHandler).and() // 基于token,所以不需要session @@ -109,7 +111,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter // 过滤请求 .authorizeRequests() // 对于登录login 注册register 验证码captchaImage 允许匿名访问 - .antMatchers("/login", "/register", "/captchaImage").anonymous() + .antMatchers("/login", "/register", "/captchaImage").permitAll() // 静态资源,可匿名访问 .antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll() .antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll() @@ -124,8 +126,6 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter // 添加CORS filter httpSecurity.addFilterBefore(corsFilter, JwtAuthenticationTokenFilter.class); httpSecurity.addFilterBefore(corsFilter, LogoutFilter.class); - // 禁用缓存 - httpSecurity.headers().cacheControl().disable(); } /**