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 | 44 | datasource: |
| 45 | 45 | master: |
| 46 | 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 | 48 | driver-class-name: com.mysql.jdbc.Driver |
| 49 | 49 | username: root |
| 50 | 50 | password: 3WLiVUBEwTbvAfsh |
| 51 | 51 | slave: # 模拟从库,可根据自己需要修改 # 模拟从库,可根据自己需要修改 |
| 52 | 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 | 54 | driver-class-name: com.mysql.jdbc.Driver |
| 55 | 55 | username: root |
| 56 | 56 | password: 3WLiVUBEwTbvAfsh | ... | ... |
yudao-admin-server/src/main/resources/application-local.yaml
| ... | ... | @@ -44,13 +44,13 @@ spring: |
| 44 | 44 | datasource: |
| 45 | 45 | master: |
| 46 | 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 | 48 | driver-class-name: com.mysql.jdbc.Driver |
| 49 | 49 | username: root |
| 50 | 50 | password: 123456 |
| 51 | 51 | slave: # 模拟从库,可根据自己需要修改 |
| 52 | 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 | 54 | driver-class-name: com.mysql.jdbc.Driver |
| 55 | 55 | username: root |
| 56 | 56 | password: 123456 | ... | ... |
yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/config/YudaoSecurityAutoConfiguration.java
| 1 | 1 | package cn.iocoder.yudao.framework.security.config; |
| 2 | 2 | |
| 3 | 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 | 5 | import cn.iocoder.yudao.framework.security.core.handler.AccessDeniedHandlerImpl; |
| 6 | 6 | import cn.iocoder.yudao.framework.security.core.handler.AuthenticationEntryPointImpl; |
| 7 | 7 | import cn.iocoder.yudao.framework.security.core.handler.LogoutSuccessHandlerImpl; |
| ... | ... | @@ -80,9 +80,9 @@ public class YudaoSecurityAutoConfiguration { |
| 80 | 80 | * Token 认证过滤器 Bean |
| 81 | 81 | */ |
| 82 | 82 | @Bean |
| 83 | - public JwtAuthenticationTokenFilter authenticationTokenFilter(SecurityAuthFrameworkService securityFrameworkService, | |
| 83 | + public JWTAuthenticationTokenFilter authenticationTokenFilter(SecurityAuthFrameworkService securityFrameworkService, | |
| 84 | 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 | 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 | 4 | import cn.iocoder.yudao.framework.security.core.service.SecurityAuthFrameworkService; |
| 6 | 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 | 6 | import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; |
| 10 | 7 | import org.springframework.context.annotation.Bean; |
| 11 | 8 | import org.springframework.context.annotation.Configuration; |
| ... | ... | @@ -21,7 +18,6 @@ import org.springframework.security.config.http.SessionCreationPolicy; |
| 21 | 18 | import org.springframework.security.crypto.password.PasswordEncoder; |
| 22 | 19 | import org.springframework.security.web.AuthenticationEntryPoint; |
| 23 | 20 | import org.springframework.security.web.access.AccessDeniedHandler; |
| 24 | -import org.springframework.security.web.authentication.AuthenticationSuccessHandler; | |
| 25 | 21 | import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; |
| 26 | 22 | import org.springframework.security.web.authentication.logout.LogoutSuccessHandler; |
| 27 | 23 | |
| ... | ... | @@ -68,7 +64,7 @@ public class YudaoWebSecurityConfigurerAdapter extends WebSecurityConfigurerAdap |
| 68 | 64 | * Token 认证过滤器 Bean |
| 69 | 65 | */ |
| 70 | 66 | @Resource |
| 71 | - private JwtAuthenticationTokenFilter authenticationTokenFilter; | |
| 67 | + private JWTAuthenticationTokenFilter authenticationTokenFilter; | |
| 72 | 68 | /** |
| 73 | 69 | * 自定义的权限映射 Bean |
| 74 | 70 | * |
| ... | ... | @@ -154,11 +150,10 @@ public class YudaoWebSecurityConfigurerAdapter extends WebSecurityConfigurerAdap |
| 154 | 150 | // 设置每个请求的权限 ②:每个项目的自定义规则 |
| 155 | 151 | .and().authorizeRequests(authorizeRequestsCustomizer) |
| 156 | 152 | // 设置每个请求的权限 ③:兜底规则,必须认证 |
| 157 | -// .authorizeRequests().anyRequest().authenticated() | |
| 153 | + .authorizeRequests().anyRequest().authenticated() | |
| 158 | 154 | ; |
| 159 | 155 | // 添加 JWT Filter |
| 160 | 156 | httpSecurity.addFilterBefore(authenticationTokenFilter, UsernamePasswordAuthenticationFilter.class); |
| 161 | - | |
| 162 | 157 | } |
| 163 | 158 | |
| 164 | 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 | 23 | * JWT 过滤器,验证 token 的有效性 |
| 24 | 24 | * 验证通过后,获得 {@link LoginUser} 信息,并加入到 Spring Security 上下文 |
| 25 | 25 | * |
| 26 | - * @author ruoyi | |
| 26 | + * @author 芋道源码 | |
| 27 | 27 | */ |
| 28 | 28 | @AllArgsConstructor |
| 29 | -public class JwtAuthenticationTokenFilter extends OncePerRequestFilter { | |
| 29 | +public class JWTAuthenticationTokenFilter extends OncePerRequestFilter { | |
| 30 | 30 | |
| 31 | 31 | private final SecurityProperties securityProperties; |
| 32 | 32 | ... | ... |
yudao-user-server/src/main/resources/application-dev.yaml
| ... | ... | @@ -44,13 +44,13 @@ spring: |
| 44 | 44 | datasource: |
| 45 | 45 | master: |
| 46 | 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 | 48 | driver-class-name: com.mysql.jdbc.Driver |
| 49 | 49 | username: root |
| 50 | 50 | password: 3WLiVUBEwTbvAfsh |
| 51 | 51 | slave: # 模拟从库,可根据自己需要修改 # 模拟从库,可根据自己需要修改 |
| 52 | 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 | 54 | driver-class-name: com.mysql.jdbc.Driver |
| 55 | 55 | username: root |
| 56 | 56 | password: 3WLiVUBEwTbvAfsh | ... | ... |
yudao-user-server/src/main/resources/application-local.yaml
| ... | ... | @@ -44,13 +44,13 @@ spring: |
| 44 | 44 | datasource: |
| 45 | 45 | master: |
| 46 | 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 | 48 | driver-class-name: com.mysql.jdbc.Driver |
| 49 | 49 | username: root |
| 50 | 50 | password: 123456 |
| 51 | 51 | slave: # 模拟从库,可根据自己需要修改 |
| 52 | 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 | 54 | driver-class-name: com.mysql.jdbc.Driver |
| 55 | 55 | username: root |
| 56 | 56 | password: 123456 | ... | ... |