mirror of
https://gitee.com/dromara/sa-token.git
synced 2024-11-29 18:37:49 +08:00
新增 revokeClientToken、revokeClientTokenByIndex: Client-Token 回收函数
This commit is contained in:
parent
a1560ce0a7
commit
d3b337a6a6
@ -236,6 +236,15 @@ public interface SaOAuth2Dao {
|
||||
getSaTokenDao().delete(splicingClientTokenIndexKey(clientId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除:Past-Token
|
||||
* @param pastToken 值
|
||||
*/
|
||||
default void deletePastToken(String pastToken) {
|
||||
// 其实就是删除 ClientToken
|
||||
deleteClientToken(pastToken);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除:Past-Token索引
|
||||
* @param clientId 应用id
|
||||
|
@ -374,6 +374,47 @@ public class SaOAuth2Template {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 回收指定的 ClientToken
|
||||
*
|
||||
* @param clientToken /
|
||||
*/
|
||||
public void revokeClientToken(String clientToken) {
|
||||
SaOAuth2Dao dao = SaOAuth2Manager.getDao();
|
||||
ClientTokenModel ctModel = dao.getClientToken(clientToken);
|
||||
if(ctModel == null) {
|
||||
return;
|
||||
}
|
||||
// 删 ct、索引
|
||||
dao.deleteClientToken(clientToken);
|
||||
dao.deleteClientTokenIndex(ctModel.clientId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 回收指定的 ClientToken,根据索引: clientId
|
||||
*
|
||||
* @param clientId /
|
||||
*/
|
||||
public void revokeClientTokenByIndex(String clientId) {
|
||||
SaOAuth2Dao dao = SaOAuth2Manager.getDao();
|
||||
|
||||
// 删 clientToken
|
||||
String clientToken = dao.getClientTokenValue(clientId);
|
||||
if(clientToken != null) {
|
||||
dao.deleteClientToken(clientToken);
|
||||
dao.deleteClientTokenIndex(clientId);
|
||||
}
|
||||
|
||||
// 删 pastToken
|
||||
String pastToken = dao.getPastTokenValue(clientId);
|
||||
if(pastToken != null) {
|
||||
dao.deletePastToken(pastToken);
|
||||
dao.deletePastTokenIndex(clientId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ------------------- 包装其它 bean 的方法
|
||||
|
||||
|
@ -21,7 +21,6 @@ import cn.dev33.satoken.oauth2.data.model.ClientTokenModel;
|
||||
import cn.dev33.satoken.oauth2.data.model.CodeModel;
|
||||
import cn.dev33.satoken.oauth2.data.model.RefreshTokenModel;
|
||||
import cn.dev33.satoken.oauth2.data.model.loader.SaClientModel;
|
||||
import cn.dev33.satoken.oauth2.processor.SaOAuth2ServerProcessor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -175,7 +174,25 @@ public class SaOAuth2Util {
|
||||
public static AccessTokenModel checkAccessTokenParam(String clientId, String clientSecret, String accessToken) {
|
||||
return SaOAuth2Manager.getTemplate().checkAccessTokenParam(clientId, clientSecret, accessToken);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 回收指定的 ClientToken
|
||||
*
|
||||
* @param clientToken /
|
||||
*/
|
||||
public static void revokeClientToken(String clientToken) {
|
||||
SaOAuth2Manager.getTemplate().revokeClientToken(clientToken);
|
||||
}
|
||||
|
||||
/**
|
||||
* 回收指定的 ClientToken,根据索引:clientId
|
||||
*
|
||||
* @param clientId /
|
||||
*/
|
||||
public static void revokeClientTokenByIndex(String clientId) {
|
||||
SaOAuth2Manager.getTemplate().revokeClientTokenByIndex(clientId);
|
||||
}
|
||||
|
||||
// ------------------- save 数据
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user