提交 db68ff53 编写于 作者: N nicky 提交者: 马增群

JWT代码提交

上级 6df054b7
......@@ -63,12 +63,12 @@ public class JWTAuthenticationTokenFilter extends OncePerRequestFilter {
final String _authHeader = httpServletRequest.getHeader(jwtProperties.getTokenKey());
log.info("Authorization:[{}]",_authHeader);
if (StringUtils.isEmpty(_authHeader) || ! _authHeader.startsWith(jwtProperties.getTokenPrefix())) {
throw new RuntimeException("无token,请重新登录");
throw new RuntimeException("Unable to get JWT Token");
}
final String token = _authHeader.substring(7);
log.info("acceptToken:[{}]",token);
if (!jwtTokenUtil.validateToken(token)) {
throw new RuntimeException("401 Exception,token校验失败");
throw new RuntimeException("Invalid token");
}
if (jwtTokenUtil.validateToken(token)) {
String username = jwtTokenUtil.getUsernameFromClaims(token);
......
......@@ -27,7 +27,7 @@ logging:
level:
org:
springframework:
security: DEBUG
security: info
com:
example:
springboot:
......
......@@ -33,15 +33,15 @@
<script src="https://cdn.bootcss.com/jquery/1.11.3/jquery.js"></script>
<script>
$(function() {
/* $("#btnSave").click(function () {
$("#btnSave").click(function () {
var username=$("#username").val();
var password=$("#password").val();
$.ajax({
cache: true,
cache: false,
type: "POST",
url: "/authenticate",
contentType: "application/json;charset=UTF-8",
data:JSON.stringify({"username":username ,"password" : password}),
contentType:"application/x-www-form-urlencoded; charset=UTF-8",
data:{"username":username ,"password" : password},
dataType: "json",
async: false,
error: function (request) {
......@@ -52,7 +52,7 @@
localStorage.setItem("token",data);
}
});
});*/
});
});
</script>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册