Commit 6b27fdea by xty

250515

parent 8ef2634a
...@@ -6,7 +6,7 @@ spring: ...@@ -6,7 +6,7 @@ spring:
druid: druid:
# 主库数据源 # 主库数据源
master: master:
url: jdbc:mysql://192.168.31.167:3306/scientific_research_two?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&failOverReadOnly=false url: jdbc:mysql://192.168.31.167:3306/qianhe_hyqd?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&failOverReadOnly=false
username: root username: root
password: qianhe2024 password: qianhe2024
# 从库数据源 # 从库数据源
......
...@@ -16,7 +16,7 @@ ruoyi: ...@@ -16,7 +16,7 @@ ruoyi:
# 开发环境配置 # 开发环境配置
server: server:
# 服务器的HTTP端口,默认为8080 # 服务器的HTTP端口,默认为8080
port: 8080 port: 8082
servlet: servlet:
# 应用的访问路径 # 应用的访问路径
context-path: / context-path: /
...@@ -68,7 +68,7 @@ spring: ...@@ -68,7 +68,7 @@ spring:
# redis 配置 # redis 配置
redis: redis:
# 地址 # 地址
host: 1.116.38.25 host: 182.92.202.17
# 端口,默认为6379 # 端口,默认为6379
port: 7789 port: 7789
# 数据库索引 # 数据库索引
......
...@@ -53,6 +53,8 @@ public class SecurityConfig ...@@ -53,6 +53,8 @@ public class SecurityConfig
*/ */
@Autowired @Autowired
private JwtAuthenticationTokenFilter authenticationTokenFilter; private JwtAuthenticationTokenFilter authenticationTokenFilter;
/** /**
* 跨域过滤器 * 跨域过滤器
...@@ -66,6 +68,8 @@ public class SecurityConfig ...@@ -66,6 +68,8 @@ public class SecurityConfig
@Autowired @Autowired
private PermitAllUrlProperties permitAllUrl; private PermitAllUrlProperties permitAllUrl;
/** /**
* 身份验证实现 * 身份验证实现
*/ */
...@@ -111,9 +115,9 @@ public class SecurityConfig ...@@ -111,9 +115,9 @@ public class SecurityConfig
.authorizeHttpRequests((requests) -> { .authorizeHttpRequests((requests) -> {
permitAllUrl.getUrls().forEach(url -> requests.antMatchers(url).permitAll()); permitAllUrl.getUrls().forEach(url -> requests.antMatchers(url).permitAll());
// 对于登录login 注册register 验证码captchaImage 允许匿名访问 // 对于登录login 注册register 验证码captchaImage 允许匿名访问
requests.antMatchers("/login", "/register", "/captchaImage").permitAll() requests.antMatchers("/login", "/register", "/captchaImage", "/*/**").permitAll()
// 静态资源,可匿名访问 // 静态资源,可匿名访问
.antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll() .antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html","/**/*.css", "/**/**","/**/*.js", "/profile/**").permitAll()
.antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll() .antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll()
// 除上面外的所有请求全部需要鉴权认证 // 除上面外的所有请求全部需要鉴权认证
.anyRequest().authenticated(); .anyRequest().authenticated();
...@@ -128,6 +132,9 @@ public class SecurityConfig ...@@ -128,6 +132,9 @@ public class SecurityConfig
.build(); .build();
} }
/** /**
* 强散列哈希加密实现 * 强散列哈希加密实现
*/ */
......
...@@ -3,8 +3,11 @@ package com.ruoyi.framework.security.filter; ...@@ -3,8 +3,11 @@ package com.ruoyi.framework.security.filter;
import java.io.IOException; import java.io.IOException;
import javax.servlet.FilterChain; import javax.servlet.FilterChain;
import javax.servlet.ServletException; import javax.servlet.ServletException;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import com.ruoyi.framework.config.CreateTokenController;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.core.context.SecurityContextHolder;
...@@ -27,11 +30,13 @@ public class JwtAuthenticationTokenFilter extends OncePerRequestFilter ...@@ -27,11 +30,13 @@ public class JwtAuthenticationTokenFilter extends OncePerRequestFilter
@Autowired @Autowired
private TokenService tokenService; private TokenService tokenService;
@Override @Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws ServletException, IOException {
throws ServletException, IOException
{
LoginUser loginUser = tokenService.getLoginUser(request); LoginUser loginUser = tokenService.getLoginUser(request);
if (StringUtils.isNotNull(loginUser) && StringUtils.isNull(SecurityUtils.getAuthentication())) if (StringUtils.isNotNull(loginUser) && StringUtils.isNull(SecurityUtils.getAuthentication()))
{ {
tokenService.verifyToken(loginUser); tokenService.verifyToken(loginUser);
...@@ -39,6 +44,8 @@ public class JwtAuthenticationTokenFilter extends OncePerRequestFilter ...@@ -39,6 +44,8 @@ public class JwtAuthenticationTokenFilter extends OncePerRequestFilter
authenticationToken.setDetails(new WebAuthenticationDetailsSource().buildDetails(request)); authenticationToken.setDetails(new WebAuthenticationDetailsSource().buildDetails(request));
SecurityContextHolder.getContext().setAuthentication(authenticationToken); SecurityContextHolder.getContext().setAuthentication(authenticationToken);
} }
chain.doFilter(request, response); chain.doFilter(request, response);
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment