Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
smileNicky
springbootexamples
提交
db68ff53
S
springbootexamples
项目概览
smileNicky
/
springbootexamples
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
4
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
springbootexamples
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
4
合并请求
4
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
db68ff53
编写于
7月 10, 2020
作者:
N
nicky
提交者:
马增群
7月 10, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
JWT代码提交
上级
6df054b7
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
8 addition
and
8 deletion
+8
-8
springboot-jwt/src/main/java/com/example/springboot/jwt/web/filter/JWTAuthenticationTokenFilter.java
...ringboot/jwt/web/filter/JWTAuthenticationTokenFilter.java
+2
-2
springboot-jwt/src/main/resources/application.yml
springboot-jwt/src/main/resources/application.yml
+1
-1
springboot-jwt/src/main/resources/templates/login.html
springboot-jwt/src/main/resources/templates/login.html
+5
-5
未找到文件。
springboot-jwt/src/main/java/com/example/springboot/jwt/web/filter/JWTAuthenticationTokenFilter.java
浏览文件 @
db68ff53
...
...
@@ -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
);
...
...
springboot-jwt/src/main/resources/application.yml
浏览文件 @
db68ff53
...
...
@@ -27,7 +27,7 @@ logging:
level
:
org
:
springframework
:
security
:
DEBUG
security
:
info
com
:
example
:
springboot
:
...
...
springboot-jwt/src/main/resources/templates/login.html
浏览文件 @
db68ff53
...
...
@@ -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:
tru
e,
cache
:
fals
e
,
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录