mirror of
https://gitee.com/dromara/sa-token.git
synced 2026-02-27 16:50:24 +08:00
完善 OAuth2-自定义权限处理器 章节文档
This commit is contained in:
@@ -25,7 +25,7 @@ import cn.dev33.satoken.oauth2.scope.CommonScope;
|
||||
* @author click33
|
||||
* @since 1.39.0
|
||||
*/
|
||||
public class OidcScopeHandler implements SaOAuth2ScopeAbstractHandler {
|
||||
public class OidcScopeHandler implements SaOAuth2ScopeHandlerInterface {
|
||||
|
||||
public String getHandlerScope() {
|
||||
return CommonScope.OIDC;
|
||||
|
||||
@@ -27,7 +27,7 @@ import cn.dev33.satoken.oauth2.scope.CommonScope;
|
||||
* @author click33
|
||||
* @since 1.39.0
|
||||
*/
|
||||
public class OpenIdScopeHandler implements SaOAuth2ScopeAbstractHandler {
|
||||
public class OpenIdScopeHandler implements SaOAuth2ScopeHandlerInterface {
|
||||
|
||||
public String getHandlerScope() {
|
||||
return CommonScope.OPENID;
|
||||
|
||||
@@ -24,7 +24,7 @@ import cn.dev33.satoken.oauth2.data.model.ClientTokenModel;
|
||||
* @author click33
|
||||
* @since 1.39.0
|
||||
*/
|
||||
public interface SaOAuth2ScopeAbstractHandler {
|
||||
public interface SaOAuth2ScopeHandlerInterface {
|
||||
|
||||
/**
|
||||
* 获取所要处理的权限
|
||||
@@ -26,7 +26,7 @@ import cn.dev33.satoken.oauth2.scope.CommonScope;
|
||||
* @author click33
|
||||
* @since 1.39.0
|
||||
*/
|
||||
public class UserIdScopeHandler implements SaOAuth2ScopeAbstractHandler {
|
||||
public class UserIdScopeHandler implements SaOAuth2ScopeHandlerInterface {
|
||||
|
||||
public String getHandlerScope() {
|
||||
return CommonScope.USERID;
|
||||
|
||||
@@ -20,7 +20,7 @@ import cn.dev33.satoken.oauth2.function.strategy.*;
|
||||
import cn.dev33.satoken.oauth2.scope.CommonScope;
|
||||
import cn.dev33.satoken.oauth2.scope.handler.OidcScopeHandler;
|
||||
import cn.dev33.satoken.oauth2.scope.handler.OpenIdScopeHandler;
|
||||
import cn.dev33.satoken.oauth2.scope.handler.SaOAuth2ScopeAbstractHandler;
|
||||
import cn.dev33.satoken.oauth2.scope.handler.SaOAuth2ScopeHandlerInterface;
|
||||
import cn.dev33.satoken.oauth2.scope.handler.UserIdScopeHandler;
|
||||
import cn.dev33.satoken.util.SaFoxUtil;
|
||||
|
||||
@@ -49,7 +49,7 @@ public final class SaOAuth2Strategy {
|
||||
/**
|
||||
* 权限处理器集合
|
||||
*/
|
||||
public Map<String, SaOAuth2ScopeAbstractHandler> scopeHandlerMap = new LinkedHashMap<>();
|
||||
public Map<String, SaOAuth2ScopeHandlerInterface> scopeHandlerMap = new LinkedHashMap<>();
|
||||
|
||||
/**
|
||||
* 注册所有默认的权限处理器
|
||||
@@ -63,7 +63,7 @@ public final class SaOAuth2Strategy {
|
||||
/**
|
||||
* 注册一个权限处理器
|
||||
*/
|
||||
public void registerScopeHandler(SaOAuth2ScopeAbstractHandler handler) {
|
||||
public void registerScopeHandler(SaOAuth2ScopeHandlerInterface handler) {
|
||||
scopeHandlerMap.put(handler.getHandlerScope(), handler);
|
||||
// TODO 优化日志输出
|
||||
SaManager.getLog().info("新增权限处理器:" + handler.getHandlerScope());
|
||||
@@ -86,7 +86,7 @@ public final class SaOAuth2Strategy {
|
||||
public SaOAuth2ScopeWorkAccessTokenFunction workAccessTokenByScope = (at) -> {
|
||||
if(at.scopes != null && !at.scopes.isEmpty()) {
|
||||
for (String scope : at.scopes) {
|
||||
SaOAuth2ScopeAbstractHandler handler = scopeHandlerMap.get(scope);
|
||||
SaOAuth2ScopeHandlerInterface handler = scopeHandlerMap.get(scope);
|
||||
if(handler != null) {
|
||||
handler.workAccessToken(at);
|
||||
}
|
||||
@@ -100,7 +100,7 @@ public final class SaOAuth2Strategy {
|
||||
public SaOAuth2ScopeWorkClientTokenFunction workClientTokenByScope = (ct) -> {
|
||||
if(ct.scopes != null && !ct.scopes.isEmpty()) {
|
||||
for (String scope : ct.scopes) {
|
||||
SaOAuth2ScopeAbstractHandler handler = scopeHandlerMap.get(scope);
|
||||
SaOAuth2ScopeHandlerInterface handler = scopeHandlerMap.get(scope);
|
||||
if(handler != null) {
|
||||
handler.workClientToken(ct);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user