main
HuangHai 3 months ago
parent da70306ee0
commit 7efe9d1de0

@ -172,6 +172,7 @@
<artifactId>japidocs</artifactId> <artifactId>japidocs</artifactId>
<version>${japidocs.version}</version> <version>${japidocs.version}</version>
</dependency> </dependency>
<!--jjwt-->
<dependency> <dependency>
<groupId>io.jsonwebtoken</groupId> <groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-api</artifactId> <artifactId>jjwt-api</artifactId>

@ -8,6 +8,6 @@ import com.jfinal.kit.PropKit;
public class IndexController extends Controller { public class IndexController extends Controller {
@Before({GET.class}) @Before({GET.class})
public void index() { public void index() {
redirect(PropKit.get("first_page")); renderText("Welcome to dsBase World!");
} }
} }

@ -2,7 +2,7 @@
undertow.devMode=false undertow.devMode=false
undertow.port=8001 undertow.port=8001
undertow.host=0.0.0.0 undertow.host=0.0.0.0
undertow.resourcePath=D:/dsWork/dsProject/dsBase/WebRoot,classpath:static
# 目录名称 # 目录名称
undertow.contextPath=/dsBase undertow.contextPath=/dsBase

@ -129,11 +129,23 @@
<version>${snakeyaml.version}</version> <version>${snakeyaml.version}</version>
</dependency> </dependency>
<!-- JWT相关 --> <!--jjwt-->
<dependency> <dependency>
<groupId>io.jsonwebtoken</groupId> <groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-api</artifactId> <artifactId>jjwt-api</artifactId>
<version>${jjwt.version}</version> <version>${jsonwebtoken.version}</version>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-impl</artifactId>
<version>${jsonwebtoken.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-jackson</artifactId>
<version>0.11.5</version>
<scope>runtime</scope>
</dependency> </dependency>
<!-- JAXB相关 --> <!-- JAXB相关 -->

@ -110,7 +110,7 @@ public class RouterHandler extends Handler {
} }
// 方法2使用Set集合推荐性能更好 // 使用Set集合推荐性能更好
private static final Set<String> STATIC_EXTENSIONS = new HashSet<>(Arrays.asList( private static final Set<String> STATIC_EXTENSIONS = new HashSet<>(Arrays.asList(
"html", "js", "css", "png", "jpg", "jpeg", "gif", "ico", "svg", "html", "js", "css", "png", "jpg", "jpeg", "gif", "ico", "svg",
"woff", "woff2", "ttf", "eot", "map", "json", "xml", "txt" "woff", "woff2", "ttf", "eot", "map", "json", "xml", "txt"
@ -138,15 +138,15 @@ public class RouterHandler extends Handler {
return; return;
} }
//微服务间的调用视为内部调用
if (req.getServletPath().endsWith("_Internal")) {
renderJson(res, new RetBean(RetBean.ERROR, "微服务间内部接口调用,是不需要走网关的!").toString());
isHandled[0] = true; //停止filter
return;
}
//如果是白名单不检查jwt,否则需要检查jwt //如果是白名单不检查jwt,否则需要检查jwt
if (!GwApplication.whiteSet.contains(servletPath)) { if (!GwApplication.whiteSet.contains(servletPath)) {
//微服务间的调用视为内部调用
if (req.getServletPath().endsWith("_Internal")) {
renderJson(res, new RetBean(RetBean.ERROR, "微服务间内部接口调用,是不需要走网关的!").toString());
isHandled[0] = true; //停止filter
return;
}
//是不是通过了登录检查? //是不是通过了登录检查?
boolean canPass = true; boolean canPass = true;
//1、存在Session,检查是不是正确的Session //1、存在Session,检查是不是正确的Session

@ -57,6 +57,7 @@ public class JwtUtil {
.parseClaimsJws(token) .parseClaimsJws(token)
.getBody(); .getBody();
} catch (Exception e) { } catch (Exception e) {
System.out.println(e.toString());
claims = null; claims = null;
} }
return claims; return claims;

Loading…
Cancel
Save