mirror of
https://gitee.com/dromara/sa-token.git
synced 2025-05-05 05:07:54 +08:00
新增 SaOAuth2Util.checkClientTokenScope(clientToken, scopes)
方法,校验 Client-Token 是否含有指定 Scope
This commit is contained in:
parent
cd909f4137
commit
386295dc6b
@ -98,6 +98,21 @@ public class SaOAuth2Template {
|
||||
SaOAuth2Exception.throwBy(scopeList.contains(scope) == false, "该 Access-Token 不具备 Scope:" + scope);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 校验:指定 Client-Token 是否具有指定 Scope
|
||||
* @param clientToken Client-Token
|
||||
* @param scopes 需要校验的权限列表
|
||||
*/
|
||||
public void checkClientTokenScope(String clientToken, String... scopes) {
|
||||
if(scopes == null || scopes.length == 0) {
|
||||
return;
|
||||
}
|
||||
ClientTokenModel ct = checkClientToken(clientToken);
|
||||
List<String> scopeList = SaFoxUtil.convertStringToList(ct.scope);
|
||||
for (String scope : scopes) {
|
||||
SaOAuth2Exception.throwBy(scopeList.contains(scope) == false, "该 Client-Token 不具备 Scope:" + scope);
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------- generate 构建数据
|
||||
/**
|
||||
|
@ -49,7 +49,7 @@ public class SaOAuth2Util {
|
||||
public static ClientTokenModel checkClientToken(String clientToken) {
|
||||
return saOAuth2Template.checkClientToken(clientToken);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取 Access-Token 所代表的LoginId
|
||||
* @param accessToken Access-Token
|
||||
@ -68,6 +68,15 @@ public class SaOAuth2Util {
|
||||
saOAuth2Template.checkScope(accessToken, scopes);
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验:指定 Client-Token 是否具有指定 Scope
|
||||
* @param clientToken Client-Token
|
||||
* @param scopes 需要校验的权限列表
|
||||
*/
|
||||
public static void checkClientTokenScope(String clientToken, String... scopes) {
|
||||
saOAuth2Template.checkClientTokenScope(clientToken, scopes);
|
||||
}
|
||||
|
||||
// ------------------- generate 构建数据
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user