修改代理服务
This commit is contained in:
parent
6eec973c2a
commit
1815b37547
|
|
@ -0,0 +1,31 @@
|
|||
package com.bonus.gateway.config;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 黑子
|
||||
*/
|
||||
public class AuthWriteUtils {
|
||||
|
||||
public static List<String> getBlackUrl(){
|
||||
List<String> whiteUrl=new ArrayList<>();
|
||||
whiteUrl.add("/bmw/**");
|
||||
return whiteUrl;
|
||||
}
|
||||
|
||||
public static List<String> getWriteUrl(){
|
||||
List<String> whiteUrl=new ArrayList<>();
|
||||
whiteUrl.add("js");
|
||||
whiteUrl.add("ttf");
|
||||
whiteUrl.add("woff2");
|
||||
whiteUrl.add("woff");
|
||||
whiteUrl.add("ico");
|
||||
whiteUrl.add("css");
|
||||
whiteUrl.add("png");
|
||||
whiteUrl.add("jpg");
|
||||
whiteUrl.add("html");
|
||||
return whiteUrl;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
package com.bonus.gateway.config;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.cors.CorsConfiguration;
|
||||
import org.springframework.web.cors.reactive.CorsWebFilter;
|
||||
import org.springframework.web.cors.reactive.UrlBasedCorsConfigurationSource;
|
||||
import org.springframework.web.util.pattern.PathPatternParser;
|
||||
|
||||
/**
|
||||
* description:
|
||||
* java项目fhadmin.cn
|
||||
*/
|
||||
@Configuration
|
||||
public class CorsConfig {
|
||||
@Bean
|
||||
public CorsWebFilter corsFilter() {
|
||||
CorsConfiguration config = new CorsConfiguration();
|
||||
config.addAllowedMethod("*"); // 是什么请求方法,比如GET POST PUT DELATE ...
|
||||
config.addAllowedOrigin("*"); // 来自哪个域名的请求,*号表示所有
|
||||
config.addAllowedOriginPattern("*"); // 来自哪个域名的请求,*号表示所有
|
||||
config.addAllowedHeader("*"); // 是什么请求头部
|
||||
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(new PathPatternParser());
|
||||
source.registerCorsConfiguration("/**", config);
|
||||
return new CorsWebFilter(source);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
package com.bonus.gateway.filter;
|
||||
|
||||
import com.bonus.gateway.config.AuthWriteUtils;
|
||||
import com.bonus.gateway.config.properties.IgnoreWhiteProperties;
|
||||
import com.bonus.common.core.constant.CacheConstants;
|
||||
import com.bonus.common.core.constant.HttpStatus;
|
||||
|
|
@ -44,8 +45,18 @@ public class AuthFilter implements GlobalFilter, Ordered
|
|||
{
|
||||
ServerHttpRequest request = exchange.getRequest();
|
||||
ServerHttpRequest.Builder mutate = request.mutate();
|
||||
|
||||
String url = request.getURI().getPath();
|
||||
if (StringUtils.matches(url, AuthWriteUtils.getBlackUrl()))
|
||||
{
|
||||
if(url.contains(".")){
|
||||
String type=url.substring(url.lastIndexOf(".")+1).toLowerCase().trim();
|
||||
if(AuthWriteUtils.getWriteUrl().contains(type)){
|
||||
return chain.filter(exchange);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 跳过不需要验证的路径
|
||||
if (StringUtils.matches(url, ignoreWhite.getWhites()))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -13,8 +13,8 @@ server:
|
|||
buffered: true
|
||||
requestAttributesEnabled: true
|
||||
port: 1911
|
||||
servlet:
|
||||
context-path: /bmw
|
||||
# servlet:
|
||||
# context-path: /bmw
|
||||
|
||||
environment: @profiles.active@
|
||||
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ function logout() {
|
|||
|
||||
$.ajax({
|
||||
type: 'delete',
|
||||
url: loginPath + '/logout',
|
||||
url: DATA_URL + '/auth/logout',
|
||||
headers: {
|
||||
"Authorization": token
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1,16 +1,19 @@
|
|||
var ctxPath = getContextPath();
|
||||
let DATA_URL="http://127.0.0.1:9100"
|
||||
|
||||
|
||||
var ctxPath = "http://127.0.0.1:9100/bmw"
|
||||
var currentHostname = window.location.hostname;
|
||||
|
||||
|
||||
// //测试
|
||||
// var loginPath = "http://" + currentHostname + ":9200";
|
||||
// var systemPath = "http://" + currentHostname + ":1910";
|
||||
var loginPath = "http://" + currentHostname + ":1616/auth";
|
||||
var systemPath = "http://" + currentHostname + ":1616/system";
|
||||
var filePath = "http://" + currentHostname + ":1909/file";
|
||||
var fileUrl = "http://" + currentHostname + ":1909/file";
|
||||
var planUrl = "http://" + currentHostname + ":1918/ynPlan";
|
||||
var oiPlanUrl = "http://" + currentHostname + ":1914/oiPlan";
|
||||
|
||||
var systemPath = "http://" + currentHostname + ":9100/system";
|
||||
var filePath = "http://" + currentHostname + ":9100/file";
|
||||
var fileUrl = "http://" + currentHostname + ":9100/file";
|
||||
var planUrl = "http://" + currentHostname + ":9100/ynPlan";
|
||||
var oiPlanUrl = "http://" + currentHostname + ":9100/oiPlan";
|
||||
|
||||
//112.29.103.165:1616
|
||||
//正式环境
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@
|
|||
if (token != null && token.trim().length != 0) {
|
||||
$.ajax({
|
||||
type : 'get',
|
||||
url : ctxPath + '/users/current?token=' + token,
|
||||
url : DATA_URL + '/users/current?token=' + token,
|
||||
success : function(data) {
|
||||
if(data != ''){
|
||||
location.href = ctxPath + '/index.html';
|
||||
|
|
@ -107,7 +107,7 @@
|
|||
$.ajax({
|
||||
type : 'post',
|
||||
contentType : "application/json; charset=utf-8",
|
||||
url : loginPath + '/login',
|
||||
url : DATA_URL + '/auth/login',
|
||||
data : JSON.stringify({
|
||||
// "username" : username,
|
||||
// "password" : password,
|
||||
|
|
@ -209,7 +209,7 @@
|
|||
time:5000
|
||||
});
|
||||
}
|
||||
var url = loginPath+"/getTokenKey?jwtToken="+jwtToken;
|
||||
var url = ctxPath+"/auth/getTokenKey?jwtToken="+jwtToken;
|
||||
$.ajax({
|
||||
type : "GET",
|
||||
contentType: "application/json;charset=UTF-8",
|
||||
|
|
|
|||
Loading…
Reference in New Issue