diff --git a/ruoyi-admin/pom.xml b/ruoyi-admin/pom.xml index 9a4cde8fbda6bc99fa871f411b35477c8d2c8bfa..4546b73896f60fbbbe88625d9c7c366761417cef 100644 --- a/ruoyi-admin/pom.xml +++ b/ruoyi-admin/pom.xml @@ -37,6 +37,12 @@ 1.6.2 + + com.github.xiaoymin + knife4j-spring-boot-starter + 2.0.9 + + mysql @@ -80,17 +86,17 @@ - - org.apache.maven.plugins - maven-war-plugin - 3.1.0 + + org.apache.maven.plugins + maven-war-plugin + 3.1.0 false ${project.artifactId} - - + + ${project.artifactId} - \ No newline at end of file + diff --git a/ruoyi-admin/src/main/resources/application.yml b/ruoyi-admin/src/main/resources/application.yml index acb28b4218c99e62c1ac0da70bc3ae0c107dc237..0c5b6cfbae5f9da196a5ff07f1606a57be8613ca 100644 --- a/ruoyi-admin/src/main/resources/application.yml +++ b/ruoyi-admin/src/main/resources/application.yml @@ -53,7 +53,7 @@ spring: messages: # 国际化资源文件路径 basename: i18n/messages - profiles: + profiles: active: druid # 文件上传 servlet: @@ -76,7 +76,7 @@ spring: # 数据库索引 database: 0 # 密码 - password: + password: # 连接超时时间 timeout: 10s lettuce: @@ -98,7 +98,7 @@ token: secret: abcdefghijklmnopqrstuvwxyz # 令牌有效期(默认30分钟) expireTime: 30 - + # MyBatis配置 mybatis: # 搜索指定包别名 @@ -109,10 +109,16 @@ mybatis: configLocation: classpath:mybatis/mybatis-config.xml # PageHelper分页插件 -pagehelper: +pagehelper: helperDialect: mysql supportMethodsArguments: true - params: count=countSql + params: count=countSql + +# knife4j的增强配置 +knife4j: + enable: true + setting: + language: zh_cn # Swagger配置 swagger: @@ -122,7 +128,7 @@ swagger: pathMapping: /dev-api # 防止XSS攻击 -xss: +xss: # 过滤开关 enabled: true # 排除链接(多个用逗号分隔) diff --git a/ruoyi-admin/src/main/resources/logback.xml b/ruoyi-admin/src/main/resources/logback.xml index d69a5720739777fb1bc9feef127220071296d5ca..3174b21fb2933e5e005f517912709324d6c1b79f 100644 --- a/ruoyi-admin/src/main/resources/logback.xml +++ b/ruoyi-admin/src/main/resources/logback.xml @@ -3,7 +3,7 @@ - + @@ -11,7 +11,7 @@ ${log.pattern} - + ${log.path}/sys-info.log @@ -34,7 +34,7 @@ DENY - + ${log.path}/sys-error.log @@ -56,7 +56,7 @@ DENY - + ${log.path}/sys-user.log @@ -70,7 +70,7 @@ ${log.pattern} - + @@ -79,15 +79,15 @@ - + - + - \ No newline at end of file + 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 bdb7199fe9c9335c901b00a77eb89681fa1ab6cc..5557e560dbfee5810fb713a611296ec99c74181a 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 @@ -22,7 +22,7 @@ import com.ruoyi.framework.security.handle.LogoutSuccessHandlerImpl; /** * spring security配置 - * + * * @author ruoyi */ @EnableGlobalMethodSecurity(prePostEnabled = true, securedEnabled = true) @@ -33,7 +33,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter */ @Autowired private UserDetailsService userDetailsService; - + /** * 认证失败处理类 */ @@ -51,7 +51,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter */ @Autowired private JwtAuthenticationTokenFilter authenticationTokenFilter; - + /** * 跨域过滤器 */ @@ -114,7 +114,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter .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() + .antMatchers("/doc.html", "/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll() // 除上面外的所有请求全部需要鉴权认证 .anyRequest().authenticated() .and() diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/security/handle/AuthenticationEntryPointImpl.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/security/handle/AuthenticationEntryPointImpl.java index 9d86feab21db9bde2563372467de8b3746708c4d..db2c077b353739cce7b9d51062f233123911ff13 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/security/handle/AuthenticationEntryPointImpl.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/security/handle/AuthenticationEntryPointImpl.java @@ -4,6 +4,9 @@ import java.io.IOException; import java.io.Serializable; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.security.core.AuthenticationException; import org.springframework.security.web.AuthenticationEntryPoint; import org.springframework.stereotype.Component; @@ -15,20 +18,21 @@ import com.ruoyi.common.utils.StringUtils; /** * 认证失败处理类 返回未授权 - * + * * @author ruoyi */ @Component public class AuthenticationEntryPointImpl implements AuthenticationEntryPoint, Serializable { private static final long serialVersionUID = -8970718410437077606L; + private Logger logger = LoggerFactory.getLogger(getClass()); @Override public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException e) - throws IOException { int code = HttpStatus.UNAUTHORIZED; String msg = StringUtils.format("请求访问:{},认证失败,无法访问系统资源", request.getRequestURI()); + logger.info(msg); ServletUtils.renderString(response, JSON.toJSONString(AjaxResult.error(code, msg))); } } diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/TokenService.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/TokenService.java index cadeb4e37b36f92cd004d72f53fa306a83f113fb..4c499188c630803442280a191841e7ccbe9fe2e9 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/TokenService.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/TokenService.java @@ -4,6 +4,9 @@ import java.util.HashMap; import java.util.Map; import java.util.concurrent.TimeUnit; import javax.servlet.http.HttpServletRequest; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; @@ -50,6 +53,8 @@ public class TokenService @Autowired private RedisCache redisCache; + private Logger logger = LoggerFactory.getLogger(getClass()); + /** * 获取用户身份信息 * @@ -72,8 +77,10 @@ public class TokenService } catch (Exception e) { + logger.info("token:{}已过期或不合法", token); } } + logger.info("token:{} 为空", token); return null; } diff --git a/ruoyi-ui/src/views/tool/swagger/index.vue b/ruoyi-ui/src/views/tool/swagger/index.vue index 750189115c01fc3e28d1ed5d06a5b5d668922a8a..b782968781367eac4782ead929742f6d4eace69c 100644 --- a/ruoyi-ui/src/views/tool/swagger/index.vue +++ b/ruoyi-ui/src/views/tool/swagger/index.vue @@ -1,15 +1,15 @@ - - + +