feat: 添加网关白名单
This commit is contained in:
@@ -1,8 +1,11 @@
|
|||||||
package cn.meowrain.aioj.backend.gateway;
|
package cn.meowrain.aioj.backend.gateway;
|
||||||
|
|
||||||
|
import cn.meowrain.aioj.backend.gateway.config.GatewayPropertiesConfiguration;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||||
|
|
||||||
|
@EnableConfigurationProperties(value = {GatewayPropertiesConfiguration.class})
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
public class AIOJGatewayApplication {
|
public class AIOJGatewayApplication {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package cn.meowrain.aioj.backend.gateway.config;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
|
||||||
|
@ConfigurationProperties(prefix = GatewayPropertiesConfiguration.PREFIX)
|
||||||
|
@Data
|
||||||
|
public class GatewayPropertiesConfiguration {
|
||||||
|
public static final String PREFIX = "aioj-backend-gateway";
|
||||||
|
/*
|
||||||
|
* 白名单放行
|
||||||
|
* */
|
||||||
|
private String[] whiteList;
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package cn.meowrain.aioj.backend.gateway.filter;
|
||||||
|
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
|
||||||
|
import org.springframework.cloud.gateway.filter.GlobalFilter;
|
||||||
|
import org.springframework.core.Ordered;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.web.reactive.function.client.WebClient;
|
||||||
|
import org.springframework.web.server.ServerWebExchange;
|
||||||
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class AuthGlobalFilter implements GlobalFilter, Ordered {
|
||||||
|
|
||||||
|
private final WebClient.Builder webClientBuilder;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getOrder() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user