Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wecloud_im_server
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hewei
wecloud_im_server
Commits
8d3b684c
Commit
8d3b684c
authored
Sep 25, 2020
by
giaogiao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化shiro
parent
104c3297
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
38 additions
and
59 deletions
+38
-59
config/src/main/java/io/geekidea/springbootplus/config/constant/AppLoginRedisKey.java
+0
-12
config/src/main/java/io/geekidea/springbootplus/config/constant/CommonRedisKey.java
+12
-0
config/src/main/java/io/geekidea/springbootplus/config/constant/MerchantLoginRedisKey.java
+0
-12
config/src/main/java/io/geekidea/springbootplus/config/constant/SysLoginRedisKey.java
+0
-12
framework/src/main/java/io/geekidea/springbootplus/framework/shiro/cache/impl/AppLoginRedisServiceImpl.java
+8
-7
framework/src/main/java/io/geekidea/springbootplus/framework/shiro/cache/impl/MerchantLoginRedisServiceImpl.java
+8
-7
framework/src/main/java/io/geekidea/springbootplus/framework/shiro/cache/impl/SysLoginRedisServiceImpl.java
+8
-7
framework/src/main/java/io/geekidea/springbootplus/framework/shiro/jwt/JwtFilter.java
+2
-2
No files found.
config/src/main/java/io/geekidea/springbootplus/config/constant/AppLoginRedisKey.java
View file @
8d3b684c
...
@@ -27,23 +27,11 @@ package io.geekidea.springbootplus.config.constant;
...
@@ -27,23 +27,11 @@ package io.geekidea.springbootplus.config.constant;
public
interface
AppLoginRedisKey
{
public
interface
AppLoginRedisKey
{
/**
/**
* 登录用户token信息key
* login:token:tokenMd5
*/
String
LOGIN_TOKEN
=
"sys:login:token:%s"
;
/**
* 登录用户信息key
* 登录用户信息key
* login:user:username
* login:user:username
*/
*/
String
LOGIN_USER
=
"app:login:user:%s"
;
String
LOGIN_USER
=
"app:login:user:%s"
;
/**
* 登录用户盐值信息key
* login:salt:username
*/
// String LOGIN_SALT = "app:login:salt:%s";
String
LOGIN_SALT
=
"sys:login:salt:%s"
;
/**
/**
...
...
config/src/main/java/io/geekidea/springbootplus/config/constant/CommonRedisKey.java
View file @
8d3b684c
...
@@ -27,6 +27,18 @@ package io.geekidea.springbootplus.config.constant;
...
@@ -27,6 +27,18 @@ package io.geekidea.springbootplus.config.constant;
public
interface
CommonRedisKey
{
public
interface
CommonRedisKey
{
/**
/**
* 登录用户token信息key
* login:token:tokenMd5
*/
String
LOGIN_TOKEN
=
"login:token:%s"
;
/**
* 登录用户盐值信息key
* login:salt:username
*/
String
LOGIN_SALT
=
"login:salt:%s"
;
/**
* 验证码
* 验证码
* verify.code:666666
* verify.code:666666
*/
*/
...
...
config/src/main/java/io/geekidea/springbootplus/config/constant/MerchantLoginRedisKey.java
View file @
8d3b684c
...
@@ -27,24 +27,12 @@ package io.geekidea.springbootplus.config.constant;
...
@@ -27,24 +27,12 @@ package io.geekidea.springbootplus.config.constant;
public
interface
MerchantLoginRedisKey
{
public
interface
MerchantLoginRedisKey
{
/**
/**
* 登录用户token信息key
* login:token:tokenMd5
*/
String
LOGIN_TOKEN
=
"sys:login:token:%s"
;
/**
* 登录用户信息key
* 登录用户信息key
* login:user:username
* login:user:username
*/
*/
String
LOGIN_USER
=
"mer:login:user:%s"
;
String
LOGIN_USER
=
"mer:login:user:%s"
;
/**
/**
* 登录用户盐值信息key
* login:salt:username
*/
String
LOGIN_SALT
=
"sys:login:salt:%s"
;
/**
* 登录用户username token
* 登录用户username token
* login:user:token:username:token
* login:user:token:username:token
*/
*/
...
...
config/src/main/java/io/geekidea/springbootplus/config/constant/SysLoginRedisKey.java
View file @
8d3b684c
...
@@ -27,24 +27,12 @@ package io.geekidea.springbootplus.config.constant;
...
@@ -27,24 +27,12 @@ package io.geekidea.springbootplus.config.constant;
public
interface
SysLoginRedisKey
{
public
interface
SysLoginRedisKey
{
/**
/**
* 登录用户token信息key
* login:token:tokenMd5
*/
String
LOGIN_TOKEN
=
"sys:login:token:%s"
;
/**
* 登录用户信息key
* 登录用户信息key
* login:user:username
* login:user:username
*/
*/
String
LOGIN_USER
=
"sys:login:user:%s"
;
String
LOGIN_USER
=
"sys:login:user:%s"
;
/**
/**
* 登录用户盐值信息key
* login:salt:username
*/
String
LOGIN_SALT
=
"sys:login:salt:%s"
;
/**
* 登录用户username token
* 登录用户username token
* login:user:token:username:token
* login:user:token:username:token
*/
*/
...
...
framework/src/main/java/io/geekidea/springbootplus/framework/shiro/cache/impl/AppLoginRedisServiceImpl.java
View file @
8d3b684c
package
io
.
geekidea
.
springbootplus
.
framework
.
shiro
.
cache
.
impl
;
package
io
.
geekidea
.
springbootplus
.
framework
.
shiro
.
cache
.
impl
;
import
io.geekidea.springbootplus.config.constant.AppLoginRedisKey
;
import
io.geekidea.springbootplus.config.constant.AppLoginRedisKey
;
import
io.geekidea.springbootplus.config.constant.CommonRedisKey
;
import
io.geekidea.springbootplus.config.properties.JwtProperties
;
import
io.geekidea.springbootplus.config.properties.JwtProperties
;
import
io.geekidea.springbootplus.framework.common.bean.ClientInfo
;
import
io.geekidea.springbootplus.framework.common.bean.ClientInfo
;
import
io.geekidea.springbootplus.framework.shiro.cache.AppLoginRedisService
;
import
io.geekidea.springbootplus.framework.shiro.cache.AppLoginRedisService
;
...
@@ -80,12 +81,12 @@ public class AppLoginRedisServiceImpl implements AppLoginRedisService {
...
@@ -80,12 +81,12 @@ public class AppLoginRedisServiceImpl implements AppLoginRedisService {
}
}
// 1. tokenMd5:jwtTokenRedisVo
// 1. tokenMd5:jwtTokenRedisVo
String
loginTokenRedisKey
=
String
.
format
(
AppLogi
nRedisKey
.
LOGIN_TOKEN
,
tokenMd5
);
String
loginTokenRedisKey
=
String
.
format
(
Commo
nRedisKey
.
LOGIN_TOKEN
,
tokenMd5
);
redisTemplate
.
opsForValue
().
set
(
loginTokenRedisKey
,
jwtTokenRedisVo
,
expireDuration
);
redisTemplate
.
opsForValue
().
set
(
loginTokenRedisKey
,
jwtTokenRedisVo
,
expireDuration
);
// 2. username:loginSysUserRedisVo
// 2. username:loginSysUserRedisVo
redisTemplate
.
opsForValue
().
set
(
String
.
format
(
AppLoginRedisKey
.
LOGIN_USER
,
username
),
loginSysUserRedisVo
,
expireDuration
);
redisTemplate
.
opsForValue
().
set
(
String
.
format
(
AppLoginRedisKey
.
LOGIN_USER
,
username
),
loginSysUserRedisVo
,
expireDuration
);
// 3. salt hash,方便获取盐值鉴权
// 3. salt hash,方便获取盐值鉴权
redisTemplate
.
opsForValue
().
set
(
String
.
format
(
AppLogi
nRedisKey
.
LOGIN_SALT
,
username
),
salt
,
expireDuration
);
redisTemplate
.
opsForValue
().
set
(
String
.
format
(
Commo
nRedisKey
.
LOGIN_SALT
,
username
),
salt
,
expireDuration
);
// 4. login user token
// 4. login user token
redisTemplate
.
opsForValue
().
set
(
String
.
format
(
AppLoginRedisKey
.
LOGIN_USER_TOKEN
,
username
,
tokenMd5
),
loginTokenRedisKey
,
expireDuration
);
redisTemplate
.
opsForValue
().
set
(
String
.
format
(
AppLoginRedisKey
.
LOGIN_USER_TOKEN
,
username
,
tokenMd5
),
loginTokenRedisKey
,
expireDuration
);
}
}
...
@@ -122,7 +123,7 @@ public class AppLoginRedisServiceImpl implements AppLoginRedisService {
...
@@ -122,7 +123,7 @@ public class AppLoginRedisServiceImpl implements AppLoginRedisService {
if
(
StringUtils
.
isBlank
(
username
))
{
if
(
StringUtils
.
isBlank
(
username
))
{
throw
new
IllegalArgumentException
(
"username不能为空"
);
throw
new
IllegalArgumentException
(
"username不能为空"
);
}
}
String
salt
=
(
String
)
redisTemplate
.
opsForValue
().
get
(
String
.
format
(
AppLogi
nRedisKey
.
LOGIN_SALT
,
username
));
String
salt
=
(
String
)
redisTemplate
.
opsForValue
().
get
(
String
.
format
(
Commo
nRedisKey
.
LOGIN_SALT
,
username
));
return
salt
;
return
salt
;
}
}
...
@@ -136,11 +137,11 @@ public class AppLoginRedisServiceImpl implements AppLoginRedisService {
...
@@ -136,11 +137,11 @@ public class AppLoginRedisServiceImpl implements AppLoginRedisService {
}
}
String
tokenMd5
=
DigestUtils
.
md5Hex
(
token
);
String
tokenMd5
=
DigestUtils
.
md5Hex
(
token
);
// 1. delete tokenMd5
// 1. delete tokenMd5
redisTemplate
.
delete
(
String
.
format
(
AppLogi
nRedisKey
.
LOGIN_TOKEN
,
tokenMd5
));
redisTemplate
.
delete
(
String
.
format
(
Commo
nRedisKey
.
LOGIN_TOKEN
,
tokenMd5
));
// 2. delete username
// 2. delete username
redisTemplate
.
delete
(
String
.
format
(
AppLoginRedisKey
.
LOGIN_USER
,
username
));
redisTemplate
.
delete
(
String
.
format
(
AppLoginRedisKey
.
LOGIN_USER
,
username
));
// 3. delete salt
// 3. delete salt
redisTemplate
.
delete
(
String
.
format
(
AppLogi
nRedisKey
.
LOGIN_SALT
,
username
));
redisTemplate
.
delete
(
String
.
format
(
Commo
nRedisKey
.
LOGIN_SALT
,
username
));
// 4. delete user token
// 4. delete user token
redisTemplate
.
delete
(
String
.
format
(
AppLoginRedisKey
.
LOGIN_USER_TOKEN
,
username
,
tokenMd5
));
redisTemplate
.
delete
(
String
.
format
(
AppLoginRedisKey
.
LOGIN_USER_TOKEN
,
username
,
tokenMd5
));
}
}
...
@@ -151,7 +152,7 @@ public class AppLoginRedisServiceImpl implements AppLoginRedisService {
...
@@ -151,7 +152,7 @@ public class AppLoginRedisServiceImpl implements AppLoginRedisService {
throw
new
IllegalArgumentException
(
"token不能为空"
);
throw
new
IllegalArgumentException
(
"token不能为空"
);
}
}
String
tokenMd5
=
DigestUtils
.
md5Hex
(
token
);
String
tokenMd5
=
DigestUtils
.
md5Hex
(
token
);
Object
object
=
redisTemplate
.
opsForValue
().
get
(
String
.
format
(
AppLogi
nRedisKey
.
LOGIN_TOKEN
,
tokenMd5
));
Object
object
=
redisTemplate
.
opsForValue
().
get
(
String
.
format
(
Commo
nRedisKey
.
LOGIN_TOKEN
,
tokenMd5
));
return
object
!=
null
;
return
object
!=
null
;
}
}
...
@@ -170,7 +171,7 @@ public class AppLoginRedisServiceImpl implements AppLoginRedisService {
...
@@ -170,7 +171,7 @@ public class AppLoginRedisServiceImpl implements AppLoginRedisService {
// 3. 删除登录用户信息
// 3. 删除登录用户信息
redisTemplate
.
delete
(
String
.
format
(
AppLoginRedisKey
.
LOGIN_USER
,
username
));
redisTemplate
.
delete
(
String
.
format
(
AppLoginRedisKey
.
LOGIN_USER
,
username
));
// 4. 删除登录用户盐值信息
// 4. 删除登录用户盐值信息
redisTemplate
.
delete
(
String
.
format
(
AppLogi
nRedisKey
.
LOGIN_SALT
,
username
));
redisTemplate
.
delete
(
String
.
format
(
Commo
nRedisKey
.
LOGIN_SALT
,
username
));
}
}
...
...
framework/src/main/java/io/geekidea/springbootplus/framework/shiro/cache/impl/MerchantLoginRedisServiceImpl.java
View file @
8d3b684c
package
io
.
geekidea
.
springbootplus
.
framework
.
shiro
.
cache
.
impl
;
package
io
.
geekidea
.
springbootplus
.
framework
.
shiro
.
cache
.
impl
;
import
io.geekidea.springbootplus.config.constant.CommonRedisKey
;
import
io.geekidea.springbootplus.config.constant.MerchantLoginRedisKey
;
import
io.geekidea.springbootplus.config.constant.MerchantLoginRedisKey
;
import
io.geekidea.springbootplus.config.properties.JwtProperties
;
import
io.geekidea.springbootplus.config.properties.JwtProperties
;
import
io.geekidea.springbootplus.framework.common.bean.ClientInfo
;
import
io.geekidea.springbootplus.framework.common.bean.ClientInfo
;
...
@@ -79,12 +80,12 @@ public class MerchantLoginRedisServiceImpl implements MerchantLoginRedisService
...
@@ -79,12 +80,12 @@ public class MerchantLoginRedisServiceImpl implements MerchantLoginRedisService
}
}
// 1. tokenMd5:jwtTokenRedisVo
// 1. tokenMd5:jwtTokenRedisVo
String
loginTokenRedisKey
=
String
.
format
(
MerchantLogi
nRedisKey
.
LOGIN_TOKEN
,
tokenMd5
);
String
loginTokenRedisKey
=
String
.
format
(
Commo
nRedisKey
.
LOGIN_TOKEN
,
tokenMd5
);
redisTemplate
.
opsForValue
().
set
(
loginTokenRedisKey
,
jwtTokenRedisVo
,
expireDuration
);
redisTemplate
.
opsForValue
().
set
(
loginTokenRedisKey
,
jwtTokenRedisVo
,
expireDuration
);
// 2. username:loginSysUserRedisVo
// 2. username:loginSysUserRedisVo
redisTemplate
.
opsForValue
().
set
(
String
.
format
(
MerchantLoginRedisKey
.
LOGIN_USER
,
username
),
loginSysUserRedisVo
,
expireDuration
);
redisTemplate
.
opsForValue
().
set
(
String
.
format
(
MerchantLoginRedisKey
.
LOGIN_USER
,
username
),
loginSysUserRedisVo
,
expireDuration
);
// 3. salt hash,方便获取盐值鉴权
// 3. salt hash,方便获取盐值鉴权
redisTemplate
.
opsForValue
().
set
(
String
.
format
(
MerchantLogi
nRedisKey
.
LOGIN_SALT
,
username
),
salt
,
expireDuration
);
redisTemplate
.
opsForValue
().
set
(
String
.
format
(
Commo
nRedisKey
.
LOGIN_SALT
,
username
),
salt
,
expireDuration
);
// 4. login user token
// 4. login user token
redisTemplate
.
opsForValue
().
set
(
String
.
format
(
MerchantLoginRedisKey
.
LOGIN_USER_TOKEN
,
username
,
tokenMd5
),
loginTokenRedisKey
,
expireDuration
);
redisTemplate
.
opsForValue
().
set
(
String
.
format
(
MerchantLoginRedisKey
.
LOGIN_USER_TOKEN
,
username
,
tokenMd5
),
loginTokenRedisKey
,
expireDuration
);
}
}
...
@@ -121,7 +122,7 @@ public class MerchantLoginRedisServiceImpl implements MerchantLoginRedisService
...
@@ -121,7 +122,7 @@ public class MerchantLoginRedisServiceImpl implements MerchantLoginRedisService
if
(
StringUtils
.
isBlank
(
username
))
{
if
(
StringUtils
.
isBlank
(
username
))
{
throw
new
IllegalArgumentException
(
"username不能为空"
);
throw
new
IllegalArgumentException
(
"username不能为空"
);
}
}
String
salt
=
(
String
)
redisTemplate
.
opsForValue
().
get
(
String
.
format
(
MerchantLogi
nRedisKey
.
LOGIN_SALT
,
username
));
String
salt
=
(
String
)
redisTemplate
.
opsForValue
().
get
(
String
.
format
(
Commo
nRedisKey
.
LOGIN_SALT
,
username
));
return
salt
;
return
salt
;
}
}
...
@@ -135,11 +136,11 @@ public class MerchantLoginRedisServiceImpl implements MerchantLoginRedisService
...
@@ -135,11 +136,11 @@ public class MerchantLoginRedisServiceImpl implements MerchantLoginRedisService
}
}
String
tokenMd5
=
DigestUtils
.
md5Hex
(
token
);
String
tokenMd5
=
DigestUtils
.
md5Hex
(
token
);
// 1. delete tokenMd5
// 1. delete tokenMd5
redisTemplate
.
delete
(
String
.
format
(
MerchantLogi
nRedisKey
.
LOGIN_TOKEN
,
tokenMd5
));
redisTemplate
.
delete
(
String
.
format
(
Commo
nRedisKey
.
LOGIN_TOKEN
,
tokenMd5
));
// 2. delete username
// 2. delete username
redisTemplate
.
delete
(
String
.
format
(
MerchantLoginRedisKey
.
LOGIN_USER
,
username
));
redisTemplate
.
delete
(
String
.
format
(
MerchantLoginRedisKey
.
LOGIN_USER
,
username
));
// 3. delete salt
// 3. delete salt
redisTemplate
.
delete
(
String
.
format
(
MerchantLogi
nRedisKey
.
LOGIN_SALT
,
username
));
redisTemplate
.
delete
(
String
.
format
(
Commo
nRedisKey
.
LOGIN_SALT
,
username
));
// 4. delete user token
// 4. delete user token
redisTemplate
.
delete
(
String
.
format
(
MerchantLoginRedisKey
.
LOGIN_USER_TOKEN
,
username
,
tokenMd5
));
redisTemplate
.
delete
(
String
.
format
(
MerchantLoginRedisKey
.
LOGIN_USER_TOKEN
,
username
,
tokenMd5
));
}
}
...
@@ -150,7 +151,7 @@ public class MerchantLoginRedisServiceImpl implements MerchantLoginRedisService
...
@@ -150,7 +151,7 @@ public class MerchantLoginRedisServiceImpl implements MerchantLoginRedisService
throw
new
IllegalArgumentException
(
"token不能为空"
);
throw
new
IllegalArgumentException
(
"token不能为空"
);
}
}
String
tokenMd5
=
DigestUtils
.
md5Hex
(
token
);
String
tokenMd5
=
DigestUtils
.
md5Hex
(
token
);
Object
object
=
redisTemplate
.
opsForValue
().
get
(
String
.
format
(
MerchantLogi
nRedisKey
.
LOGIN_TOKEN
,
tokenMd5
));
Object
object
=
redisTemplate
.
opsForValue
().
get
(
String
.
format
(
Commo
nRedisKey
.
LOGIN_TOKEN
,
tokenMd5
));
return
object
!=
null
;
return
object
!=
null
;
}
}
...
@@ -169,7 +170,7 @@ public class MerchantLoginRedisServiceImpl implements MerchantLoginRedisService
...
@@ -169,7 +170,7 @@ public class MerchantLoginRedisServiceImpl implements MerchantLoginRedisService
// 3. 删除登录用户信息
// 3. 删除登录用户信息
redisTemplate
.
delete
(
String
.
format
(
MerchantLoginRedisKey
.
LOGIN_USER
,
username
));
redisTemplate
.
delete
(
String
.
format
(
MerchantLoginRedisKey
.
LOGIN_USER
,
username
));
// 4. 删除登录用户盐值信息
// 4. 删除登录用户盐值信息
redisTemplate
.
delete
(
String
.
format
(
MerchantLogi
nRedisKey
.
LOGIN_SALT
,
username
));
redisTemplate
.
delete
(
String
.
format
(
Commo
nRedisKey
.
LOGIN_SALT
,
username
));
}
}
...
...
framework/src/main/java/io/geekidea/springbootplus/framework/shiro/cache/impl/SysLoginRedisServiceImpl.java
View file @
8d3b684c
...
@@ -16,6 +16,7 @@
...
@@ -16,6 +16,7 @@
package
io
.
geekidea
.
springbootplus
.
framework
.
shiro
.
cache
.
impl
;
package
io
.
geekidea
.
springbootplus
.
framework
.
shiro
.
cache
.
impl
;
import
io.geekidea.springbootplus.config.constant.CommonRedisKey
;
import
io.geekidea.springbootplus.config.constant.SysLoginRedisKey
;
import
io.geekidea.springbootplus.config.constant.SysLoginRedisKey
;
import
io.geekidea.springbootplus.config.properties.JwtProperties
;
import
io.geekidea.springbootplus.config.properties.JwtProperties
;
import
io.geekidea.springbootplus.framework.common.bean.ClientInfo
;
import
io.geekidea.springbootplus.framework.common.bean.ClientInfo
;
...
@@ -102,12 +103,12 @@ public class SysLoginRedisServiceImpl implements SysLoginRedisService {
...
@@ -102,12 +103,12 @@ public class SysLoginRedisServiceImpl implements SysLoginRedisService {
}
}
// 1. tokenMd5:jwtTokenRedisVo
// 1. tokenMd5:jwtTokenRedisVo
String
loginTokenRedisKey
=
String
.
format
(
SysLogi
nRedisKey
.
LOGIN_TOKEN
,
tokenMd5
);
String
loginTokenRedisKey
=
String
.
format
(
Commo
nRedisKey
.
LOGIN_TOKEN
,
tokenMd5
);
redisTemplate
.
opsForValue
().
set
(
loginTokenRedisKey
,
jwtTokenRedisVo
,
expireDuration
);
redisTemplate
.
opsForValue
().
set
(
loginTokenRedisKey
,
jwtTokenRedisVo
,
expireDuration
);
// 2. username:loginSysUserRedisVo
// 2. username:loginSysUserRedisVo
redisTemplate
.
opsForValue
().
set
(
String
.
format
(
SysLoginRedisKey
.
LOGIN_USER
,
username
),
loginSysUserRedisVo
,
expireDuration
);
redisTemplate
.
opsForValue
().
set
(
String
.
format
(
SysLoginRedisKey
.
LOGIN_USER
,
username
),
loginSysUserRedisVo
,
expireDuration
);
// 3. salt hash,方便获取盐值鉴权
// 3. salt hash,方便获取盐值鉴权
redisTemplate
.
opsForValue
().
set
(
String
.
format
(
SysLogi
nRedisKey
.
LOGIN_SALT
,
username
),
salt
,
expireDuration
);
redisTemplate
.
opsForValue
().
set
(
String
.
format
(
Commo
nRedisKey
.
LOGIN_SALT
,
username
),
salt
,
expireDuration
);
// 4. login user token
// 4. login user token
redisTemplate
.
opsForValue
().
set
(
String
.
format
(
SysLoginRedisKey
.
LOGIN_USER_TOKEN
,
username
,
tokenMd5
),
loginTokenRedisKey
,
expireDuration
);
redisTemplate
.
opsForValue
().
set
(
String
.
format
(
SysLoginRedisKey
.
LOGIN_USER_TOKEN
,
username
,
tokenMd5
),
loginTokenRedisKey
,
expireDuration
);
}
}
...
@@ -144,7 +145,7 @@ public class SysLoginRedisServiceImpl implements SysLoginRedisService {
...
@@ -144,7 +145,7 @@ public class SysLoginRedisServiceImpl implements SysLoginRedisService {
if
(
StringUtils
.
isBlank
(
username
))
{
if
(
StringUtils
.
isBlank
(
username
))
{
throw
new
IllegalArgumentException
(
"username不能为空"
);
throw
new
IllegalArgumentException
(
"username不能为空"
);
}
}
String
salt
=
(
String
)
redisTemplate
.
opsForValue
().
get
(
String
.
format
(
SysLogi
nRedisKey
.
LOGIN_SALT
,
username
));
String
salt
=
(
String
)
redisTemplate
.
opsForValue
().
get
(
String
.
format
(
Commo
nRedisKey
.
LOGIN_SALT
,
username
));
return
salt
;
return
salt
;
}
}
...
@@ -158,11 +159,11 @@ public class SysLoginRedisServiceImpl implements SysLoginRedisService {
...
@@ -158,11 +159,11 @@ public class SysLoginRedisServiceImpl implements SysLoginRedisService {
}
}
String
tokenMd5
=
DigestUtils
.
md5Hex
(
token
);
String
tokenMd5
=
DigestUtils
.
md5Hex
(
token
);
// 1. delete tokenMd5
// 1. delete tokenMd5
redisTemplate
.
delete
(
String
.
format
(
SysLogi
nRedisKey
.
LOGIN_TOKEN
,
tokenMd5
));
redisTemplate
.
delete
(
String
.
format
(
Commo
nRedisKey
.
LOGIN_TOKEN
,
tokenMd5
));
// 2. delete username
// 2. delete username
redisTemplate
.
delete
(
String
.
format
(
SysLoginRedisKey
.
LOGIN_USER
,
username
));
redisTemplate
.
delete
(
String
.
format
(
SysLoginRedisKey
.
LOGIN_USER
,
username
));
// 3. delete salt
// 3. delete salt
redisTemplate
.
delete
(
String
.
format
(
SysLogi
nRedisKey
.
LOGIN_SALT
,
username
));
redisTemplate
.
delete
(
String
.
format
(
Commo
nRedisKey
.
LOGIN_SALT
,
username
));
// 4. delete user token
// 4. delete user token
redisTemplate
.
delete
(
String
.
format
(
SysLoginRedisKey
.
LOGIN_USER_TOKEN
,
username
,
tokenMd5
));
redisTemplate
.
delete
(
String
.
format
(
SysLoginRedisKey
.
LOGIN_USER_TOKEN
,
username
,
tokenMd5
));
}
}
...
@@ -173,7 +174,7 @@ public class SysLoginRedisServiceImpl implements SysLoginRedisService {
...
@@ -173,7 +174,7 @@ public class SysLoginRedisServiceImpl implements SysLoginRedisService {
throw
new
IllegalArgumentException
(
"token不能为空"
);
throw
new
IllegalArgumentException
(
"token不能为空"
);
}
}
String
tokenMd5
=
DigestUtils
.
md5Hex
(
token
);
String
tokenMd5
=
DigestUtils
.
md5Hex
(
token
);
Object
object
=
redisTemplate
.
opsForValue
().
get
(
String
.
format
(
SysLogi
nRedisKey
.
LOGIN_TOKEN
,
tokenMd5
));
Object
object
=
redisTemplate
.
opsForValue
().
get
(
String
.
format
(
Commo
nRedisKey
.
LOGIN_TOKEN
,
tokenMd5
));
return
object
!=
null
;
return
object
!=
null
;
}
}
...
@@ -192,7 +193,7 @@ public class SysLoginRedisServiceImpl implements SysLoginRedisService {
...
@@ -192,7 +193,7 @@ public class SysLoginRedisServiceImpl implements SysLoginRedisService {
// 3. 删除登录用户信息
// 3. 删除登录用户信息
redisTemplate
.
delete
(
String
.
format
(
SysLoginRedisKey
.
LOGIN_USER
,
username
));
redisTemplate
.
delete
(
String
.
format
(
SysLoginRedisKey
.
LOGIN_USER
,
username
));
// 4. 删除登录用户盐值信息
// 4. 删除登录用户盐值信息
redisTemplate
.
delete
(
String
.
format
(
SysLogi
nRedisKey
.
LOGIN_SALT
,
username
));
redisTemplate
.
delete
(
String
.
format
(
Commo
nRedisKey
.
LOGIN_SALT
,
username
));
}
}
...
...
framework/src/main/java/io/geekidea/springbootplus/framework/shiro/jwt/JwtFilter.java
View file @
8d3b684c
...
@@ -16,7 +16,7 @@
...
@@ -16,7 +16,7 @@
package
io
.
geekidea
.
springbootplus
.
framework
.
shiro
.
jwt
;
package
io
.
geekidea
.
springbootplus
.
framework
.
shiro
.
jwt
;
import
io.geekidea.springbootplus.config.constant.
SysLogi
nRedisKey
;
import
io.geekidea.springbootplus.config.constant.
Commo
nRedisKey
;
import
io.geekidea.springbootplus.config.properties.JwtProperties
;
import
io.geekidea.springbootplus.config.properties.JwtProperties
;
import
io.geekidea.springbootplus.framework.common.api.ApiCode
;
import
io.geekidea.springbootplus.framework.common.api.ApiCode
;
import
io.geekidea.springbootplus.framework.common.api.ApiResult
;
import
io.geekidea.springbootplus.framework.common.api.ApiResult
;
...
@@ -85,7 +85,7 @@ public class JwtFilter extends AuthenticatingFilter {
...
@@ -85,7 +85,7 @@ public class JwtFilter extends AuthenticatingFilter {
// 如果开启redis二次校验,或者设置为单个用户token登录,则先在redis中判断token是否存在
// 如果开启redis二次校验,或者设置为单个用户token登录,则先在redis中判断token是否存在
if
(
jwtProperties
.
isRedisCheck
()
||
jwtProperties
.
isSingleLogin
())
{
if
(
jwtProperties
.
isRedisCheck
()
||
jwtProperties
.
isSingleLogin
())
{
String
tokenMd5
=
DigestUtils
.
md5Hex
(
token
);
String
tokenMd5
=
DigestUtils
.
md5Hex
(
token
);
jwtTokenRedisVo
=
redisTemplate
.
opsForValue
().
get
(
String
.
format
(
SysLogi
nRedisKey
.
LOGIN_TOKEN
,
tokenMd5
));
jwtTokenRedisVo
=
redisTemplate
.
opsForValue
().
get
(
String
.
format
(
Commo
nRedisKey
.
LOGIN_TOKEN
,
tokenMd5
));
// boolean redisExpired = sysLoginRedisService.exists(token);
// boolean redisExpired = sysLoginRedisService.exists(token);
if
(
jwtTokenRedisVo
==
null
)
{
if
(
jwtTokenRedisVo
==
null
)
{
throw
new
AuthenticationException
(
"Redis Token不存在,token:"
+
token
);
throw
new
AuthenticationException
(
"Redis Token不存在,token:"
+
token
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment