mirror of
https://gitee.com/dromara/sa-token.git
synced 2025-04-30 04:45:51 +08:00
refactor: 重构 sa-token-oauth2 插件,将注解鉴权处理器的注册过程放进了SPI插件里
This commit is contained in:
parent
b83927abdf
commit
062572e2ee
@ -139,6 +139,7 @@
|
|||||||
- [issue 提问模板](/fun/issue-template)
|
- [issue 提问模板](/fun/issue-template)
|
||||||
- [为Sa-Token贡献代码](/fun/git-pr)
|
- [为Sa-Token贡献代码](/fun/git-pr)
|
||||||
- [Sa-Token开源大事记](/fun/timeline)
|
- [Sa-Token开源大事记](/fun/timeline)
|
||||||
|
<!-- - [参考资料](/fun/refer-info) -->
|
||||||
- [团队成员](/fun/team)
|
- [团队成员](/fun/team)
|
||||||
- [Sa-Token框架掌握度--在线考试](/fun/sa-token-test)
|
- [Sa-Token框架掌握度--在线考试](/fun/sa-token-test)
|
||||||
|
|
||||||
|
12
sa-token-doc/fun/refer-info.md
Normal file
12
sa-token-doc/fun/refer-info.md
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
# 参考资料
|
||||||
|
记录 Sa-Token 框架开发中参考过的一些资料。(由 2025-3-1 开始整理)
|
||||||
|
|
||||||
|
|
||||||
|
- Sa-Token对url过滤不全存在的风险点 - https://mp.weixin.qq.com/s/77CIDZbgBwRunJeluofPTA
|
||||||
|
- SpringBoot 热拔插 AOP 组件:
|
||||||
|
- https://www.jb51.net/program/297714rev.htm
|
||||||
|
- https://www.bilibili.com/video/BV1WZ421W7Qx
|
||||||
|
- https://blog.csdn.net/Tomwildboar/article/details/139199801
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2020-2099 sa-token.cc
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package cn.dev33.satoken.plugin;
|
||||||
|
|
||||||
|
import cn.dev33.satoken.oauth2.annotation.handler.SaCheckAccessTokenHandler;
|
||||||
|
import cn.dev33.satoken.oauth2.annotation.handler.SaCheckClientIdSecretHandler;
|
||||||
|
import cn.dev33.satoken.oauth2.annotation.handler.SaCheckClientTokenHandler;
|
||||||
|
import cn.dev33.satoken.strategy.SaAnnotationStrategy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SaToken 插件安装:OAuth2 相关功能
|
||||||
|
*
|
||||||
|
* @author click33
|
||||||
|
* @since 1.41.0
|
||||||
|
*/
|
||||||
|
public class SaTokenPluginForOAuth2 implements SaTokenPlugin {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void install() {
|
||||||
|
// 安装 OAuth2 鉴权注解
|
||||||
|
SaAnnotationStrategy.instance.registerAnnotationHandler(new SaCheckAccessTokenHandler());
|
||||||
|
SaAnnotationStrategy.instance.registerAnnotationHandler(new SaCheckClientTokenHandler());
|
||||||
|
SaAnnotationStrategy.instance.registerAnnotationHandler(new SaCheckClientIdSecretHandler());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1 @@
|
|||||||
|
cn.dev33.satoken.plugin.SaTokenPluginForOAuth2
|
@ -15,14 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package cn.dev33.satoken.spring.oauth2;
|
package cn.dev33.satoken.spring.oauth2;
|
||||||
|
|
||||||
import cn.dev33.satoken.annotation.handler.SaAnnotationHandlerInterface;
|
|
||||||
import cn.dev33.satoken.oauth2.SaOAuth2Manager;
|
import cn.dev33.satoken.oauth2.SaOAuth2Manager;
|
||||||
import cn.dev33.satoken.oauth2.annotation.SaCheckAccessToken;
|
|
||||||
import cn.dev33.satoken.oauth2.annotation.SaCheckClientIdSecret;
|
|
||||||
import cn.dev33.satoken.oauth2.annotation.SaCheckClientToken;
|
|
||||||
import cn.dev33.satoken.oauth2.annotation.handler.SaCheckAccessTokenHandler;
|
|
||||||
import cn.dev33.satoken.oauth2.annotation.handler.SaCheckClientIdSecretHandler;
|
|
||||||
import cn.dev33.satoken.oauth2.annotation.handler.SaCheckClientTokenHandler;
|
|
||||||
import cn.dev33.satoken.oauth2.config.SaOAuth2ServerConfig;
|
import cn.dev33.satoken.oauth2.config.SaOAuth2ServerConfig;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
@ -48,31 +41,4 @@ public class SaOAuth2BeanRegister {
|
|||||||
return new SaOAuth2ServerConfig();
|
return new SaOAuth2ServerConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 自定义注解处理器
|
|
||||||
@Bean
|
|
||||||
public SaAnnotationHandlerInterface<SaCheckAccessToken> getSaCheckAccessTokenHandler() {
|
|
||||||
return new SaCheckAccessTokenHandler();
|
|
||||||
}
|
|
||||||
@Bean
|
|
||||||
public SaAnnotationHandlerInterface<SaCheckClientToken> getSaCheckClientTokenHandler() {
|
|
||||||
return new SaCheckClientTokenHandler();
|
|
||||||
}
|
|
||||||
@Bean
|
|
||||||
public SaAnnotationHandlerInterface<SaCheckClientIdSecret> getSaCheckClientIdSecretHandler() {
|
|
||||||
return new SaCheckClientIdSecretHandler();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
// 这种写法有问题,当项目还有自定义的注解处理器时,项目中的自定义注解处理器将会覆盖掉此处 List 中的注解处理器
|
|
||||||
// @Bean
|
|
||||||
// public List<SaAnnotationHandlerInterface<?>> getXxx() {
|
|
||||||
// return Arrays.asList(
|
|
||||||
// new SaCheckAccessTokenHandler(),
|
|
||||||
// new SaCheckClientTokenHandler(),
|
|
||||||
// new SaCheckClientSecretHandler()
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user