mirror of
https://gitee.com/dromara/sa-token.git
synced 2025-10-27 02:59:02 +08:00
将SSO模式三的接口调用改为签名式校验
This commit is contained in:
@@ -4,7 +4,6 @@ import java.util.Map;
|
||||
|
||||
import cn.dev33.satoken.dao.SaTokenDao;
|
||||
import cn.dev33.satoken.exception.NotLoginException;
|
||||
import cn.dev33.satoken.exception.SaTokenException;
|
||||
import cn.dev33.satoken.util.SaFoxUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.jwt.JWT;
|
||||
@@ -53,9 +52,6 @@ public class SaJwtUtil {
|
||||
*/
|
||||
public static String createToken(Object loginId, Map<String, Object> extraData, String keyt) {
|
||||
|
||||
// 秘钥不可以为空
|
||||
SaTokenException.throwByNull(keyt, "请配置jwt秘钥");
|
||||
|
||||
// 构建
|
||||
String token = JWT.create()
|
||||
.setPayload(LOGIN_ID, loginId)
|
||||
@@ -82,9 +78,6 @@ public class SaJwtUtil {
|
||||
public static String createToken(String loginType, Object loginId, String device,
|
||||
long timeout, Map<String, Object> extraData, String keyt) {
|
||||
|
||||
// 秘钥不可以为空
|
||||
SaTokenException.throwByNull(keyt, "请配置jwt秘钥");
|
||||
|
||||
// 计算有效期
|
||||
long effTime = timeout;
|
||||
if(timeout != NEVER_EXPIRE) {
|
||||
@@ -112,9 +105,7 @@ public class SaJwtUtil {
|
||||
* @return 解析后的jwt 对象
|
||||
*/
|
||||
public static JWT parseToken(String token, String keyt) {
|
||||
// 秘钥不可以为空
|
||||
SaTokenException.throwByNull(keyt, "请配置jwt秘钥");
|
||||
|
||||
|
||||
// 如果token为null
|
||||
if(token == null) {
|
||||
throw NotLoginException.newInstance(null, NotLoginException.NOT_TOKEN);
|
||||
|
||||
@@ -7,6 +7,7 @@ import cn.dev33.satoken.context.SaHolder;
|
||||
import cn.dev33.satoken.dao.SaTokenDao;
|
||||
import cn.dev33.satoken.exception.ApiDisabledException;
|
||||
import cn.dev33.satoken.exception.NotLoginException;
|
||||
import cn.dev33.satoken.exception.SaTokenException;
|
||||
import cn.dev33.satoken.stp.SaTokenInfo;
|
||||
import cn.dev33.satoken.stp.StpLogic;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
@@ -38,7 +39,9 @@ public class StpLogicJwtForMix extends StpLogic {
|
||||
* @return /
|
||||
*/
|
||||
public String jwtSecretKey() {
|
||||
return getConfig().getJwtSecretKey();
|
||||
String keyt = getConfig().getJwtSecretKey();
|
||||
SaTokenException.throwByNull(keyt, "请配置jwt秘钥");
|
||||
return keyt;
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
@@ -40,7 +40,9 @@ public class StpLogicJwtForStateless extends StpLogic {
|
||||
* @return /
|
||||
*/
|
||||
public String jwtSecretKey() {
|
||||
return getConfig().getJwtSecretKey();
|
||||
String keyt = getConfig().getJwtSecretKey();
|
||||
SaTokenException.throwByNull(keyt, "请配置jwt秘钥");
|
||||
return keyt;
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
@@ -2,6 +2,7 @@ package cn.dev33.satoken.jwt;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import cn.dev33.satoken.exception.SaTokenException;
|
||||
import cn.dev33.satoken.stp.StpLogic;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
|
||||
@@ -32,7 +33,9 @@ public class StpLogicJwtForStyle extends StpLogic {
|
||||
* @return /
|
||||
*/
|
||||
public String jwtSecretKey() {
|
||||
return getConfig().getJwtSecretKey();
|
||||
String keyt = getConfig().getJwtSecretKey();
|
||||
SaTokenException.throwByNull(keyt, "请配置jwt秘钥");
|
||||
return keyt;
|
||||
}
|
||||
|
||||
// ------ 重写方法
|
||||
|
||||
Reference in New Issue
Block a user