diff --git a/sa-token-doc/_sidebar.md b/sa-token-doc/_sidebar.md index 3422352a..7666cad2 100644 --- a/sa-token-doc/_sidebar.md +++ b/sa-token-doc/_sidebar.md @@ -139,6 +139,7 @@ - [issue 提问模板](/fun/issue-template) - [为Sa-Token贡献代码](/fun/git-pr) - [Sa-Token开源大事记](/fun/timeline) + - [团队成员](/fun/team) - [Sa-Token框架掌握度--在线考试](/fun/sa-token-test) diff --git a/sa-token-doc/fun/refer-info.md b/sa-token-doc/fun/refer-info.md new file mode 100644 index 00000000..9b9a4cda --- /dev/null +++ b/sa-token-doc/fun/refer-info.md @@ -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 + + + diff --git a/sa-token-plugin/sa-token-oauth2/src/main/java/cn/dev33/satoken/plugin/SaTokenPluginForOAuth2.java b/sa-token-plugin/sa-token-oauth2/src/main/java/cn/dev33/satoken/plugin/SaTokenPluginForOAuth2.java new file mode 100644 index 00000000..ff9314d0 --- /dev/null +++ b/sa-token-plugin/sa-token-oauth2/src/main/java/cn/dev33/satoken/plugin/SaTokenPluginForOAuth2.java @@ -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()); + } + +} \ No newline at end of file diff --git a/sa-token-plugin/sa-token-oauth2/src/main/resources/META-INF/satoken/cn.dev33.satoken.plugin.SaTokenPlugin b/sa-token-plugin/sa-token-oauth2/src/main/resources/META-INF/satoken/cn.dev33.satoken.plugin.SaTokenPlugin new file mode 100644 index 00000000..33727cef --- /dev/null +++ b/sa-token-plugin/sa-token-oauth2/src/main/resources/META-INF/satoken/cn.dev33.satoken.plugin.SaTokenPlugin @@ -0,0 +1 @@ +cn.dev33.satoken.plugin.SaTokenPluginForOAuth2 \ No newline at end of file diff --git a/sa-token-starter/sa-token-spring-boot-autoconfig/src/main/java/cn/dev33/satoken/spring/oauth2/SaOAuth2BeanRegister.java b/sa-token-starter/sa-token-spring-boot-autoconfig/src/main/java/cn/dev33/satoken/spring/oauth2/SaOAuth2BeanRegister.java index b9b99a3c..788f97af 100644 --- a/sa-token-starter/sa-token-spring-boot-autoconfig/src/main/java/cn/dev33/satoken/spring/oauth2/SaOAuth2BeanRegister.java +++ b/sa-token-starter/sa-token-spring-boot-autoconfig/src/main/java/cn/dev33/satoken/spring/oauth2/SaOAuth2BeanRegister.java @@ -15,14 +15,7 @@ */ package cn.dev33.satoken.spring.oauth2; -import cn.dev33.satoken.annotation.handler.SaAnnotationHandlerInterface; 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 org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.context.properties.ConfigurationProperties; @@ -48,31 +41,4 @@ public class SaOAuth2BeanRegister { return new SaOAuth2ServerConfig(); } - // 自定义注解处理器 - @Bean - public SaAnnotationHandlerInterface getSaCheckAccessTokenHandler() { - return new SaCheckAccessTokenHandler(); - } - @Bean - public SaAnnotationHandlerInterface getSaCheckClientTokenHandler() { - return new SaCheckClientTokenHandler(); - } - @Bean - public SaAnnotationHandlerInterface getSaCheckClientIdSecretHandler() { - return new SaCheckClientIdSecretHandler(); - } - - /* - // 这种写法有问题,当项目还有自定义的注解处理器时,项目中的自定义注解处理器将会覆盖掉此处 List 中的注解处理器 -// @Bean -// public List> getXxx() { -// return Arrays.asList( -// new SaCheckAccessTokenHandler(), -// new SaCheckClientTokenHandler(), -// new SaCheckClientSecretHandler() -// ); -// } - - */ - }