|
@@ -70,6 +70,24 @@ public class AuthGatewayFilterFactory extends AbstractGatewayFilterFactory<HostL
|
|
super(HostLocationInfo.class);
|
|
super(HostLocationInfo.class);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private boolean isRequest4StaticFiles(String requestUrl) {
|
|
|
|
+ String[] staticFilesSuffix = new String[]{
|
|
|
|
+ ".js",
|
|
|
|
+ ".css",
|
|
|
|
+ ".png",
|
|
|
|
+ ".jpg",
|
|
|
|
+ ".gif",
|
|
|
|
+ ".jpeg",
|
|
|
|
+ ".ico",
|
|
|
|
+ };
|
|
|
|
+ if (requestUrl != null && !requestUrl.isEmpty()) {
|
|
|
|
+ for (String suffix : staticFilesSuffix) {
|
|
|
|
+ if (requestUrl.toLowerCase().endsWith(suffix)) return true;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public GatewayFilter apply(HostLocationInfo config) {
|
|
public GatewayFilter apply(HostLocationInfo config) {
|
|
return (exchange, chain) -> {
|
|
return (exchange, chain) -> {
|
|
@@ -102,7 +120,7 @@ public class AuthGatewayFilterFactory extends AbstractGatewayFilterFactory<HostL
|
|
try {
|
|
try {
|
|
String auth = config.getAuth();
|
|
String auth = config.getAuth();
|
|
String protocol = config.getProtocol();
|
|
String protocol = config.getProtocol();
|
|
- if (auth == null || auth.isEmpty()) {
|
|
|
|
|
|
+ if (auth == null || auth.isEmpty() || isRequest4StaticFiles(requestUrl)) {
|
|
// 不需要授权
|
|
// 不需要授权
|
|
return chain.filter(exchange).then(Mono.fromRunnable(() -> {
|
|
return chain.filter(exchange).then(Mono.fromRunnable(() -> {
|
|
proxyPass(config, null, exchange.getResponse().getHeaders(), exchange.getResponse());
|
|
proxyPass(config, null, exchange.getResponse().getHeaders(), exchange.getResponse());
|