Commit 6686ded18b1919c172cd25dd4733f2279fecd827
1 parent
cd205a60
修复 admin 服务的全局登录的拦截
Showing
7 changed files
with
16 additions
and
21 deletions
yudao-admin-server/src/main/resources/application-dev.yaml
| @@ -44,13 +44,13 @@ spring: | @@ -44,13 +44,13 @@ spring: | ||
| 44 | datasource: | 44 | datasource: |
| 45 | master: | 45 | master: |
| 46 | name: ruoyi-vue-pro | 46 | name: ruoyi-vue-pro |
| 47 | - url: jdbc:mysql://400-infra.server.iocoder.cn:3306/${spring.datasource.dynamic.datasource.master.name}?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT | 47 | + url: jdbc:mysql://400-infra.server.iocoder.cn:3306/${spring.datasource.dynamic.datasource.master.name}?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT |
| 48 | driver-class-name: com.mysql.jdbc.Driver | 48 | driver-class-name: com.mysql.jdbc.Driver |
| 49 | username: root | 49 | username: root |
| 50 | password: 3WLiVUBEwTbvAfsh | 50 | password: 3WLiVUBEwTbvAfsh |
| 51 | slave: # 模拟从库,可根据自己需要修改 # 模拟从库,可根据自己需要修改 | 51 | slave: # 模拟从库,可根据自己需要修改 # 模拟从库,可根据自己需要修改 |
| 52 | name: ruoyi-vue-pro | 52 | name: ruoyi-vue-pro |
| 53 | - url: jdbc:mysql://400-infra.server.iocoder.cn:3306/${spring.datasource.dynamic.datasource.slave.name}?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT | 53 | + url: jdbc:mysql://400-infra.server.iocoder.cn:3306/${spring.datasource.dynamic.datasource.slave.name}?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT |
| 54 | driver-class-name: com.mysql.jdbc.Driver | 54 | driver-class-name: com.mysql.jdbc.Driver |
| 55 | username: root | 55 | username: root |
| 56 | password: 3WLiVUBEwTbvAfsh | 56 | password: 3WLiVUBEwTbvAfsh |
yudao-admin-server/src/main/resources/application-local.yaml
| @@ -44,13 +44,13 @@ spring: | @@ -44,13 +44,13 @@ spring: | ||
| 44 | datasource: | 44 | datasource: |
| 45 | master: | 45 | master: |
| 46 | name: ruoyi-vue-pro | 46 | name: ruoyi-vue-pro |
| 47 | - url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.master.name}?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT | 47 | + url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.master.name}?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT |
| 48 | driver-class-name: com.mysql.jdbc.Driver | 48 | driver-class-name: com.mysql.jdbc.Driver |
| 49 | username: root | 49 | username: root |
| 50 | password: 123456 | 50 | password: 123456 |
| 51 | slave: # 模拟从库,可根据自己需要修改 | 51 | slave: # 模拟从库,可根据自己需要修改 |
| 52 | name: ruoyi-vue-pro | 52 | name: ruoyi-vue-pro |
| 53 | - url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.slave.name}?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT | 53 | + url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.slave.name}?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT |
| 54 | driver-class-name: com.mysql.jdbc.Driver | 54 | driver-class-name: com.mysql.jdbc.Driver |
| 55 | username: root | 55 | username: root |
| 56 | password: 123456 | 56 | password: 123456 |
yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/config/YudaoSecurityAutoConfiguration.java
| 1 | package cn.iocoder.yudao.framework.security.config; | 1 | package cn.iocoder.yudao.framework.security.config; |
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.security.core.aop.PreAuthenticatedAspect; | 3 | import cn.iocoder.yudao.framework.security.core.aop.PreAuthenticatedAspect; |
| 4 | -import cn.iocoder.yudao.framework.security.core.filter.JwtAuthenticationTokenFilter; | 4 | +import cn.iocoder.yudao.framework.security.core.filter.JWTAuthenticationTokenFilter; |
| 5 | import cn.iocoder.yudao.framework.security.core.handler.AccessDeniedHandlerImpl; | 5 | import cn.iocoder.yudao.framework.security.core.handler.AccessDeniedHandlerImpl; |
| 6 | import cn.iocoder.yudao.framework.security.core.handler.AuthenticationEntryPointImpl; | 6 | import cn.iocoder.yudao.framework.security.core.handler.AuthenticationEntryPointImpl; |
| 7 | import cn.iocoder.yudao.framework.security.core.handler.LogoutSuccessHandlerImpl; | 7 | import cn.iocoder.yudao.framework.security.core.handler.LogoutSuccessHandlerImpl; |
| @@ -80,9 +80,9 @@ public class YudaoSecurityAutoConfiguration { | @@ -80,9 +80,9 @@ public class YudaoSecurityAutoConfiguration { | ||
| 80 | * Token 认证过滤器 Bean | 80 | * Token 认证过滤器 Bean |
| 81 | */ | 81 | */ |
| 82 | @Bean | 82 | @Bean |
| 83 | - public JwtAuthenticationTokenFilter authenticationTokenFilter(SecurityAuthFrameworkService securityFrameworkService, | 83 | + public JWTAuthenticationTokenFilter authenticationTokenFilter(SecurityAuthFrameworkService securityFrameworkService, |
| 84 | GlobalExceptionHandler globalExceptionHandler) { | 84 | GlobalExceptionHandler globalExceptionHandler) { |
| 85 | - return new JwtAuthenticationTokenFilter(securityProperties, securityFrameworkService, globalExceptionHandler); | 85 | + return new JWTAuthenticationTokenFilter(securityProperties, securityFrameworkService, globalExceptionHandler); |
| 86 | } | 86 | } |
| 87 | 87 | ||
| 88 | } | 88 | } |
yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/config/YudaoWebSecurityConfigurerAdapter.java
| 1 | package cn.iocoder.yudao.framework.security.config; | 1 | package cn.iocoder.yudao.framework.security.config; |
| 2 | 2 | ||
| 3 | -import cn.iocoder.yudao.framework.security.core.filter.JwtAuthenticationTokenFilter; | ||
| 4 | -import cn.iocoder.yudao.framework.security.core.handler.AbstractSignUpUrlAuthenticationSuccessHandler; | 3 | +import cn.iocoder.yudao.framework.security.core.filter.JWTAuthenticationTokenFilter; |
| 5 | import cn.iocoder.yudao.framework.security.core.service.SecurityAuthFrameworkService; | 4 | import cn.iocoder.yudao.framework.security.core.service.SecurityAuthFrameworkService; |
| 6 | import cn.iocoder.yudao.framework.web.config.WebProperties; | 5 | import cn.iocoder.yudao.framework.web.config.WebProperties; |
| 7 | -import org.springframework.beans.factory.annotation.Autowired; | ||
| 8 | -import org.springframework.beans.factory.annotation.Value; | ||
| 9 | import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; | 6 | import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; |
| 10 | import org.springframework.context.annotation.Bean; | 7 | import org.springframework.context.annotation.Bean; |
| 11 | import org.springframework.context.annotation.Configuration; | 8 | import org.springframework.context.annotation.Configuration; |
| @@ -21,7 +18,6 @@ import org.springframework.security.config.http.SessionCreationPolicy; | @@ -21,7 +18,6 @@ import org.springframework.security.config.http.SessionCreationPolicy; | ||
| 21 | import org.springframework.security.crypto.password.PasswordEncoder; | 18 | import org.springframework.security.crypto.password.PasswordEncoder; |
| 22 | import org.springframework.security.web.AuthenticationEntryPoint; | 19 | import org.springframework.security.web.AuthenticationEntryPoint; |
| 23 | import org.springframework.security.web.access.AccessDeniedHandler; | 20 | import org.springframework.security.web.access.AccessDeniedHandler; |
| 24 | -import org.springframework.security.web.authentication.AuthenticationSuccessHandler; | ||
| 25 | import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; | 21 | import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; |
| 26 | import org.springframework.security.web.authentication.logout.LogoutSuccessHandler; | 22 | import org.springframework.security.web.authentication.logout.LogoutSuccessHandler; |
| 27 | 23 | ||
| @@ -68,7 +64,7 @@ public class YudaoWebSecurityConfigurerAdapter extends WebSecurityConfigurerAdap | @@ -68,7 +64,7 @@ public class YudaoWebSecurityConfigurerAdapter extends WebSecurityConfigurerAdap | ||
| 68 | * Token 认证过滤器 Bean | 64 | * Token 认证过滤器 Bean |
| 69 | */ | 65 | */ |
| 70 | @Resource | 66 | @Resource |
| 71 | - private JwtAuthenticationTokenFilter authenticationTokenFilter; | 67 | + private JWTAuthenticationTokenFilter authenticationTokenFilter; |
| 72 | /** | 68 | /** |
| 73 | * 自定义的权限映射 Bean | 69 | * 自定义的权限映射 Bean |
| 74 | * | 70 | * |
| @@ -154,11 +150,10 @@ public class YudaoWebSecurityConfigurerAdapter extends WebSecurityConfigurerAdap | @@ -154,11 +150,10 @@ public class YudaoWebSecurityConfigurerAdapter extends WebSecurityConfigurerAdap | ||
| 154 | // 设置每个请求的权限 ②:每个项目的自定义规则 | 150 | // 设置每个请求的权限 ②:每个项目的自定义规则 |
| 155 | .and().authorizeRequests(authorizeRequestsCustomizer) | 151 | .and().authorizeRequests(authorizeRequestsCustomizer) |
| 156 | // 设置每个请求的权限 ③:兜底规则,必须认证 | 152 | // 设置每个请求的权限 ③:兜底规则,必须认证 |
| 157 | -// .authorizeRequests().anyRequest().authenticated() | 153 | + .authorizeRequests().anyRequest().authenticated() |
| 158 | ; | 154 | ; |
| 159 | // 添加 JWT Filter | 155 | // 添加 JWT Filter |
| 160 | httpSecurity.addFilterBefore(authenticationTokenFilter, UsernamePasswordAuthenticationFilter.class); | 156 | httpSecurity.addFilterBefore(authenticationTokenFilter, UsernamePasswordAuthenticationFilter.class); |
| 161 | - | ||
| 162 | } | 157 | } |
| 163 | 158 | ||
| 164 | private String api(String url) { | 159 | private String api(String url) { |
yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/core/filter/JwtAuthenticationTokenFilter.java renamed to yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/core/filter/JWTAuthenticationTokenFilter.java
| @@ -23,10 +23,10 @@ import java.io.IOException; | @@ -23,10 +23,10 @@ import java.io.IOException; | ||
| 23 | * JWT 过滤器,验证 token 的有效性 | 23 | * JWT 过滤器,验证 token 的有效性 |
| 24 | * 验证通过后,获得 {@link LoginUser} 信息,并加入到 Spring Security 上下文 | 24 | * 验证通过后,获得 {@link LoginUser} 信息,并加入到 Spring Security 上下文 |
| 25 | * | 25 | * |
| 26 | - * @author ruoyi | 26 | + * @author 芋道源码 |
| 27 | */ | 27 | */ |
| 28 | @AllArgsConstructor | 28 | @AllArgsConstructor |
| 29 | -public class JwtAuthenticationTokenFilter extends OncePerRequestFilter { | 29 | +public class JWTAuthenticationTokenFilter extends OncePerRequestFilter { |
| 30 | 30 | ||
| 31 | private final SecurityProperties securityProperties; | 31 | private final SecurityProperties securityProperties; |
| 32 | 32 |
yudao-user-server/src/main/resources/application-dev.yaml
| @@ -44,13 +44,13 @@ spring: | @@ -44,13 +44,13 @@ spring: | ||
| 44 | datasource: | 44 | datasource: |
| 45 | master: | 45 | master: |
| 46 | name: ruoyi-vue-pro | 46 | name: ruoyi-vue-pro |
| 47 | - url: jdbc:mysql://400-infra.server.iocoder.cn:3306/${spring.datasource.dynamic.datasource.master.name}?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT | 47 | + url: jdbc:mysql://400-infra.server.iocoder.cn:3306/${spring.datasource.dynamic.datasource.master.name}?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT |
| 48 | driver-class-name: com.mysql.jdbc.Driver | 48 | driver-class-name: com.mysql.jdbc.Driver |
| 49 | username: root | 49 | username: root |
| 50 | password: 3WLiVUBEwTbvAfsh | 50 | password: 3WLiVUBEwTbvAfsh |
| 51 | slave: # 模拟从库,可根据自己需要修改 # 模拟从库,可根据自己需要修改 | 51 | slave: # 模拟从库,可根据自己需要修改 # 模拟从库,可根据自己需要修改 |
| 52 | name: ruoyi-vue-pro | 52 | name: ruoyi-vue-pro |
| 53 | - url: jdbc:mysql://400-infra.server.iocoder.cn:3306/${spring.datasource.dynamic.datasource.slave.name}?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT | 53 | + url: jdbc:mysql://400-infra.server.iocoder.cn:3306/${spring.datasource.dynamic.datasource.slave.name}?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT |
| 54 | driver-class-name: com.mysql.jdbc.Driver | 54 | driver-class-name: com.mysql.jdbc.Driver |
| 55 | username: root | 55 | username: root |
| 56 | password: 3WLiVUBEwTbvAfsh | 56 | password: 3WLiVUBEwTbvAfsh |
yudao-user-server/src/main/resources/application-local.yaml
| @@ -44,13 +44,13 @@ spring: | @@ -44,13 +44,13 @@ spring: | ||
| 44 | datasource: | 44 | datasource: |
| 45 | master: | 45 | master: |
| 46 | name: ruoyi-vue-pro | 46 | name: ruoyi-vue-pro |
| 47 | - url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.master.name}?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT | 47 | + url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.master.name}?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT |
| 48 | driver-class-name: com.mysql.jdbc.Driver | 48 | driver-class-name: com.mysql.jdbc.Driver |
| 49 | username: root | 49 | username: root |
| 50 | password: 123456 | 50 | password: 123456 |
| 51 | slave: # 模拟从库,可根据自己需要修改 | 51 | slave: # 模拟从库,可根据自己需要修改 |
| 52 | name: ruoyi-vue-pro | 52 | name: ruoyi-vue-pro |
| 53 | - url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.slave.name}?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT | 53 | + url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.slave.name}?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT |
| 54 | driver-class-name: com.mysql.jdbc.Driver | 54 | driver-class-name: com.mysql.jdbc.Driver |
| 55 | username: root | 55 | username: root |
| 56 | password: 123456 | 56 | password: 123456 |