mirror of
https://gitee.com/dromara/sa-token.git
synced 2024-11-29 18:37:49 +08:00
feat(oauth2): 增加回收 Refresh-Token 方法: revokeRefreshToken
、revokeRefreshTokenByIndex
This commit is contained in:
parent
d1a0402c52
commit
a8851cf54d
@ -521,6 +521,38 @@ public class SaOAuth2Template {
|
||||
return SaOAuth2Manager.getDao().getRefreshTokenValue(clientId, loginId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 回收 Refresh-Token
|
||||
* @param refreshToken Refresh-Token 值
|
||||
*/
|
||||
public void revokeRefreshToken(String refreshToken) {
|
||||
RefreshTokenModel rt = getRefreshToken(refreshToken);
|
||||
if(rt == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 删 rt、索引
|
||||
SaOAuth2Dao dao = SaOAuth2Manager.getDao();
|
||||
dao.deleteRefreshToken(refreshToken);
|
||||
dao.deleteRefreshTokenIndex(rt.clientId, rt.loginId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 回收 Refresh-Token,根据索引: clientId、loginId
|
||||
* @param clientId /
|
||||
* @param loginId /
|
||||
*/
|
||||
public void revokeRefreshTokenByIndex(String clientId, Object loginId) {
|
||||
SaOAuth2Dao dao = SaOAuth2Manager.getDao();
|
||||
|
||||
// 删 rt、删索引
|
||||
String refreshToken = getRefreshTokenValue(clientId, loginId);
|
||||
if(refreshToken != null) {
|
||||
dao.deleteRefreshToken(refreshToken);
|
||||
dao.deleteRefreshTokenIndex(clientId, loginId);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据 RefreshToken 刷新出一个 AccessToken
|
||||
* @param refreshToken /
|
||||
|
@ -16,6 +16,7 @@
|
||||
package cn.dev33.satoken.oauth2.template;
|
||||
|
||||
import cn.dev33.satoken.oauth2.SaOAuth2Manager;
|
||||
import cn.dev33.satoken.oauth2.dao.SaOAuth2Dao;
|
||||
import cn.dev33.satoken.oauth2.data.model.AccessTokenModel;
|
||||
import cn.dev33.satoken.oauth2.data.model.ClientTokenModel;
|
||||
import cn.dev33.satoken.oauth2.data.model.RefreshTokenModel;
|
||||
@ -242,6 +243,23 @@ public class SaOAuth2Util {
|
||||
return SaOAuth2Manager.getTemplate().getRefreshTokenValue(clientId, loginId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 回收 Refresh-Token
|
||||
* @param refreshToken Refresh-Token 值
|
||||
*/
|
||||
public static void revokeRefreshToken(String refreshToken) {
|
||||
SaOAuth2Manager.getTemplate().revokeRefreshToken(refreshToken);
|
||||
}
|
||||
|
||||
/**
|
||||
* 回收 Refresh-Token,根据索引: clientId、loginId
|
||||
* @param clientId /
|
||||
* @param loginId /
|
||||
*/
|
||||
public static void revokeRefreshTokenByIndex(String clientId, Object loginId) {
|
||||
SaOAuth2Manager.getTemplate().revokeRefreshTokenByIndex(clientId, loginId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据 RefreshToken 刷新出一个 AccessToken
|
||||
* @param refreshToken /
|
||||
|
Loading…
Reference in New Issue
Block a user