Kaynağa Gözat

feat: springboot配置项修改 剔除不必要逻辑

yangliu 3 ay önce
ebeveyn
işleme
3d0130a3c8

+ 1 - 57
src/main/java/cn/hfln/framework/gateway/config/ResourceServerConfig.java

@@ -1,66 +1,10 @@
 package cn.hfln.framework.gateway.config;
 
-import cn.hutool.core.util.ArrayUtil;
-
-import cn.hfln.framework.gateway.authorization.AuthorizationManager;
-import cn.hfln.framework.gateway.componet.RestAuthenticationEntryPoint;
-import cn.hfln.framework.gateway.componet.RestfulAccessDeniedHandler;
-import cn.hfln.framework.gateway.constant.AuthConstant;
-import cn.hfln.framework.gateway.filter.IgnoreUrlsRemoveJwtFilter;
-import lombok.AllArgsConstructor;
-import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
-import org.springframework.core.convert.converter.Converter;
-import org.springframework.security.authentication.AbstractAuthenticationToken;
 import org.springframework.security.config.annotation.web.reactive.EnableWebFluxSecurity;
-import org.springframework.security.config.web.server.SecurityWebFiltersOrder;
-import org.springframework.security.config.web.server.ServerHttpSecurity;
-import org.springframework.security.oauth2.jwt.Jwt;
-import org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationConverter;
-import org.springframework.security.oauth2.server.resource.authentication.JwtGrantedAuthoritiesConverter;
-import org.springframework.security.oauth2.server.resource.authentication.ReactiveJwtAuthenticationConverterAdapter;
-import org.springframework.security.web.server.SecurityWebFilterChain;
-import reactor.core.publisher.Mono;
 
-/**
- * @USER: YangLiu
- */
-@AllArgsConstructor
 @Configuration
 @EnableWebFluxSecurity
 public class ResourceServerConfig {
-    private final AuthorizationManager authorizationManager;
-    private final IgnoreUrlsConfig ignoreUrlsConfig;
-    private final RestfulAccessDeniedHandler restfulAccessDeniedHandler;
-    private final RestAuthenticationEntryPoint restAuthenticationEntryPoint;
-    private final IgnoreUrlsRemoveJwtFilter ignoreUrlsRemoveJwtFilter;
-
-    @Bean
-    public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
-        http.oauth2ResourceServer().jwt()
-                .jwtAuthenticationConverter(jwtAuthenticationConverter());
-        //自定义处理JWT请求头过期或签名错误的结果
-        http.oauth2ResourceServer().authenticationEntryPoint(restAuthenticationEntryPoint);
-        //对白名单路径,直接移除JWT请求头
-        http.addFilterBefore(ignoreUrlsRemoveJwtFilter,SecurityWebFiltersOrder.AUTHENTICATION);
-        http.authorizeExchange()
-                .pathMatchers(ArrayUtil.toArray(ignoreUrlsConfig.getUrls(),String.class)).permitAll()//白名单配置
-                .anyExchange().access(authorizationManager)//鉴权管理器配置
-                .and().exceptionHandling()
-                .accessDeniedHandler(restfulAccessDeniedHandler)//处理未授权
-                .authenticationEntryPoint(restAuthenticationEntryPoint)//处理未认证
-                .and().csrf().disable();
-        return http.build();
-    }
-
-    @Bean
-    public Converter<Jwt, ? extends Mono<? extends AbstractAuthenticationToken>> jwtAuthenticationConverter() {
-        JwtGrantedAuthoritiesConverter jwtGrantedAuthoritiesConverter = new JwtGrantedAuthoritiesConverter();
-        jwtGrantedAuthoritiesConverter.setAuthorityPrefix(AuthConstant.AUTHORITY_PREFIX);
-        jwtGrantedAuthoritiesConverter.setAuthoritiesClaimName(AuthConstant.AUTHORITY_CLAIM_NAME);
-        JwtAuthenticationConverter jwtAuthenticationConverter = new JwtAuthenticationConverter();
-        jwtAuthenticationConverter.setJwtGrantedAuthoritiesConverter(jwtGrantedAuthoritiesConverter);
-        return new ReactiveJwtAuthenticationConverterAdapter(jwtAuthenticationConverter);
-    }
-
+    // 已移除所有安全相关配置
 }

+ 0 - 0
src/main/resources/bootstrap-dev.yml → src/main/resources/application-dev.yml


+ 1 - 4
src/main/resources/bootstrap-local.yml → src/main/resources/application-local.yml

@@ -32,7 +32,4 @@ spring:
         max-active: 8
         # #连接池最大阻塞等待时间(使用负值表示没有限制)
         max-wait: -1ms
-security:
-  captcha:
-    enabled: false
-    type: char
+

+ 0 - 0
src/main/resources/bootstrap-prod.yml → src/main/resources/application-prod.yml


+ 0 - 0
src/main/resources/bootstrap-test.yml → src/main/resources/application-test.yml


+ 1 - 8
src/main/resources/bootstrap.yml → src/main/resources/application.yml

@@ -2,7 +2,7 @@ server:
   port: 8090
 spring:
   profiles:
-    active: dev
+    active: local
   application:
     name: hfln-interior-gateway
   cloud:
@@ -26,13 +26,6 @@ spring:
           filters:
             - StripPrefix=1
 
-
-  # RSA密钥地址
-  security:
-    oauth2:
-      resourceserver:
-        jwt:
-          public-key-location: classpath:jwt_pub.key
 secure:
   ignore:
     urls: # 配置白名单路径