diff --git a/sa-token-starter/sa-token-spring-boot-autoconfig/pom.xml b/sa-token-starter/sa-token-spring-boot-autoconfig/pom.xml deleted file mode 100644 index aa0ece07..00000000 --- a/sa-token-starter/sa-token-spring-boot-autoconfig/pom.xml +++ /dev/null @@ -1,78 +0,0 @@ - - - 4.0.0 - - - cn.dev33 - sa-token-starter - ${revision} - ../pom.xml - - jar - - sa-token-spring-boot-autoconfig - sa-token-spring-boot-autoconfig - sa-token-spring-boot-autoconfig - - - - - - org.springframework.boot - spring-boot-starter - true - - - org.springframework - spring-webmvc - 5.3.7 - true - - - - - - - - - - org.springframework.boot - spring-boot-configuration-processor - true - - - - - cn.dev33 - sa-token-sso - true - - - - - cn.dev33 - sa-token-oauth2 - true - - - - - cn.dev33 - sa-token-apikey - true - - - - - cn.dev33 - sa-token-sign - true - - - - - - - diff --git a/sa-token-starter/sa-token-spring-boot-autoconfig/src/main/java/cn/dev33/satoken/package-info.java b/sa-token-starter/sa-token-spring-boot-autoconfig/src/main/java/cn/dev33/satoken/package-info.java deleted file mode 100644 index 3b171337..00000000 --- a/sa-token-starter/sa-token-spring-boot-autoconfig/src/main/java/cn/dev33/satoken/package-info.java +++ /dev/null @@ -1,19 +0,0 @@ -/* - * 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. - */ -/** - * Sa-Token 集成 SpringBoot 的各个组件 - */ -package cn.dev33.satoken; \ No newline at end of file diff --git a/sa-token-starter/sa-token-spring-boot-autoconfig/src/main/java/cn/dev33/satoken/spring/SaBeanInject.java b/sa-token-starter/sa-token-spring-boot-autoconfig/src/main/java/cn/dev33/satoken/spring/SaBeanInject.java deleted file mode 100644 index 326f8676..00000000 --- a/sa-token-starter/sa-token-spring-boot-autoconfig/src/main/java/cn/dev33/satoken/spring/SaBeanInject.java +++ /dev/null @@ -1,273 +0,0 @@ -/* - * 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.spring; - -import cn.dev33.satoken.SaManager; -import cn.dev33.satoken.annotation.handler.SaAnnotationHandlerInterface; -import cn.dev33.satoken.config.SaTokenConfig; -import cn.dev33.satoken.context.SaTokenContext; -import cn.dev33.satoken.dao.SaTokenDao; -import cn.dev33.satoken.fun.strategy.SaCorsHandleFunction; -import cn.dev33.satoken.http.SaHttpTemplate; -import cn.dev33.satoken.httpauth.basic.SaHttpBasicTemplate; -import cn.dev33.satoken.httpauth.basic.SaHttpBasicUtil; -import cn.dev33.satoken.httpauth.digest.SaHttpDigestTemplate; -import cn.dev33.satoken.httpauth.digest.SaHttpDigestUtil; -import cn.dev33.satoken.json.SaJsonTemplate; -import cn.dev33.satoken.listener.SaTokenEventCenter; -import cn.dev33.satoken.listener.SaTokenListener; -import cn.dev33.satoken.log.SaLog; -import cn.dev33.satoken.plugin.SaTokenPlugin; -import cn.dev33.satoken.plugin.SaTokenPluginHolder; -import cn.dev33.satoken.same.SaSameTemplate; -import cn.dev33.satoken.secure.totp.SaTotpTemplate; -import cn.dev33.satoken.serializer.SaSerializerTemplate; -import cn.dev33.satoken.spring.pathmatch.SaPathMatcherHolder; -import cn.dev33.satoken.stp.StpInterface; -import cn.dev33.satoken.stp.StpLogic; -import cn.dev33.satoken.stp.StpUtil; -import cn.dev33.satoken.strategy.SaAnnotationStrategy; -import cn.dev33.satoken.strategy.SaFirewallStrategy; -import cn.dev33.satoken.strategy.SaStrategy; -import cn.dev33.satoken.strategy.hooks.SaFirewallCheckHook; -import cn.dev33.satoken.temp.SaTempTemplate; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.util.PathMatcher; - -import java.util.List; - -/** - * 注入 Sa-Token 所需要的 Bean - * - * @author click33 - * @since 1.34.0 - */ -public class SaBeanInject { - - /** - * 组件注入 - *

为确保 Log 组件正常打印,必须将 SaLog 和 SaTokenConfig 率先初始化

- * - * @param log log 对象 - * @param saTokenConfig 配置对象 - */ - public SaBeanInject( - @Autowired(required = false) SaLog log, - @Autowired(required = false) SaTokenConfig saTokenConfig, - @Autowired(required = false) SaTokenPluginHolder pluginHolder - ){ - if(log != null) { - SaManager.setLog(log); - } - if(saTokenConfig != null) { - SaManager.setConfig(saTokenConfig); - } - // 初始化 Sa-Token SPI 插件 - if (pluginHolder == null) { - pluginHolder = SaTokenPluginHolder.instance; - } - pluginHolder.init(); - SaTokenPluginHolder.instance = pluginHolder; - } - - /** - * 注入持久化Bean - * - * @param saTokenDao SaTokenDao对象 - */ - @Autowired(required = false) - public void setSaTokenDao(SaTokenDao saTokenDao) { - SaManager.setSaTokenDao(saTokenDao); - } - - /** - * 注入权限认证Bean - * - * @param stpInterface StpInterface对象 - */ - @Autowired(required = false) - public void setStpInterface(StpInterface stpInterface) { - SaManager.setStpInterface(stpInterface); - } - - /** - * 注入上下文Bean - * - * @param saTokenContext SaTokenContext对象 - */ - @Autowired(required = false) - public void setSaTokenContext(SaTokenContext saTokenContext) { - SaManager.setSaTokenContext(saTokenContext); - } - - /** - * 注入侦听器Bean - * - * @param listenerList 侦听器集合 - */ - @Autowired(required = false) - public void setSaTokenListener(List listenerList) { - SaTokenEventCenter.registerListenerList(listenerList); - } - - /** - * 注入自定义注解处理器 - * - * @param handlerList 自定义注解处理器集合 - */ - @Autowired(required = false) - public void setSaAnnotationHandler(List> handlerList) { - for (SaAnnotationHandlerInterface handler : handlerList) { - SaAnnotationStrategy.instance.registerAnnotationHandler(handler); - } - } - - /** - * 注入临时令牌验证模块 Bean - * - * @param saTempTemplate / - */ - @Autowired(required = false) - public void setSaTempTemplate(SaTempTemplate saTempTemplate) { - SaManager.setSaTempTemplate(saTempTemplate); - } - - /** - * 注入 Same-Token 模块 Bean - * - * @param saSameTemplate saSameTemplate对象 - */ - @Autowired(required = false) - public void setSaIdTemplate(SaSameTemplate saSameTemplate) { - SaManager.setSaSameTemplate(saSameTemplate); - } - - /** - * 注入 Sa-Token Http Basic 认证模块 - * - * @param saBasicTemplate saBasicTemplate对象 - */ - @Autowired(required = false) - public void setSaHttpBasicTemplate(SaHttpBasicTemplate saBasicTemplate) { - SaHttpBasicUtil.saHttpBasicTemplate = saBasicTemplate; - } - - /** - * 注入 Sa-Token Http Digest 认证模块 - * - * @param saHttpDigestTemplate saHttpDigestTemplate 对象 - */ - @Autowired(required = false) - public void setSaHttpDigestTemplate(SaHttpDigestTemplate saHttpDigestTemplate) { - SaHttpDigestUtil.saHttpDigestTemplate = saHttpDigestTemplate; - } - - /** - * 注入自定义的 JSON 转换器 Bean - * - * @param saJsonTemplate JSON 转换器 - */ - @Autowired(required = false) - public void setSaJsonTemplate(SaJsonTemplate saJsonTemplate) { - SaManager.setSaJsonTemplate(saJsonTemplate); - } - - /** - * 注入自定义的 Http 转换器 Bean - * - * @param saHttpTemplate / - */ - @Autowired(required = false) - public void setSaHttpTemplate(SaHttpTemplate saHttpTemplate) { - SaManager.setSaHttpTemplate(saHttpTemplate); - } - - /** - * 注入自定义的序列化器 Bean - * - * @param saSerializerTemplate 序列化器 - */ - @Autowired(required = false) - public void setSaSerializerTemplate(SaSerializerTemplate saSerializerTemplate) { - SaManager.setSaSerializerTemplate(saSerializerTemplate); - } - - /** - * 注入自定义的 TOTP 算法 Bean - * - * @param totpTemplate TOTP 算法类 - */ - @Autowired(required = false) - public void setSaTotpTemplate(SaTotpTemplate totpTemplate) { - SaManager.setSaTotpTemplate(totpTemplate); - } - - /** - * 注入自定义的 StpLogic - * @param stpLogic / - */ - @Autowired(required = false) - public void setStpLogic(StpLogic stpLogic) { - StpUtil.setStpLogic(stpLogic); - } - - /** - * 利用自动注入特性,获取Spring框架内部使用的路由匹配器 - * - * @param pathMatcher 要设置的 pathMatcher - */ - @Autowired(required = false) - @Qualifier("mvcPathMatcher") - public void setPathMatcher(PathMatcher pathMatcher) { - SaPathMatcherHolder.setPathMatcher(pathMatcher); - } - - /** - * 注入自定义防火墙校验 hook 集合 - * - * @param hooks / - */ - @Autowired(required = false) - public void setSaFirewallCheckHooks(List hooks) { - for (SaFirewallCheckHook hook : hooks) { - SaFirewallStrategy.instance.registerHook(hook); - } - } - - /** - * 注入CORS 策略处理函数 - * - * @param corsHandle / - */ - @Autowired(required = false) - public void setCorsHandle(SaCorsHandleFunction corsHandle) { - SaStrategy.instance.corsHandle = corsHandle; - } - - /** - * 注入自定义插件集合 - * - * @param plugins / - */ - @Autowired(required = false) - public void setSaTokenPluginList(List plugins) { - for (SaTokenPlugin plugin : plugins) { - SaTokenPluginHolder.instance.installPlugin(plugin); - } - } - -} diff --git a/sa-token-starter/sa-token-spring-boot-autoconfig/src/main/java/cn/dev33/satoken/spring/SaBeanRegister.java b/sa-token-starter/sa-token-spring-boot-autoconfig/src/main/java/cn/dev33/satoken/spring/SaBeanRegister.java deleted file mode 100644 index ab8e1e91..00000000 --- a/sa-token-starter/sa-token-spring-boot-autoconfig/src/main/java/cn/dev33/satoken/spring/SaBeanRegister.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * 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.spring; - -import cn.dev33.satoken.config.SaTokenConfig; -import cn.dev33.satoken.spring.context.path.ApplicationContextPathLoading; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.context.annotation.Bean; - -/** - * 注册Sa-Token所需要的Bean - *

Bean 的注册与注入应该分开在两个文件中,否则在某些场景下会造成循环依赖 - * @author click33 - * - */ -public class SaBeanRegister { - - /** - * 获取配置Bean - * - * @return 配置对象 - */ - @Bean - @ConfigurationProperties(prefix = "sa-token") - public SaTokenConfig getSaTokenConfig() { - return new SaTokenConfig(); - } - - /** - * 应用上下文路径加载器 - * @return / - */ - @Bean - public ApplicationContextPathLoading getApplicationContextPathLoading() { - return new ApplicationContextPathLoading(); - } - -} diff --git a/sa-token-starter/sa-token-spring-boot-autoconfig/src/main/java/cn/dev33/satoken/spring/apikey/SaApiKeyBeanInject.java b/sa-token-starter/sa-token-spring-boot-autoconfig/src/main/java/cn/dev33/satoken/spring/apikey/SaApiKeyBeanInject.java deleted file mode 100644 index fda6a507..00000000 --- a/sa-token-starter/sa-token-spring-boot-autoconfig/src/main/java/cn/dev33/satoken/spring/apikey/SaApiKeyBeanInject.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * 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.spring.apikey; - -import cn.dev33.satoken.apikey.SaApiKeyManager; -import cn.dev33.satoken.apikey.config.SaApiKeyConfig; -import cn.dev33.satoken.apikey.loader.SaApiKeyDataLoader; -import cn.dev33.satoken.apikey.template.SaApiKeyTemplate; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; - -/** - * 注入 Sa-Token API Key 所需要的 Bean - * - * @author click33 - * @since 1.43.0 - */ -@ConditionalOnClass(SaApiKeyManager.class) -public class SaApiKeyBeanInject { - - /** - * 注入 API Key 配置对象 - * - * @param saApiKeyConfig 配置对象 - */ - @Autowired(required = false) - public void setSaApiKeyConfig(SaApiKeyConfig saApiKeyConfig) { - SaApiKeyManager.setConfig(saApiKeyConfig); - } - - /** - * 注入自定义的 API Key 模版方法 Bean - * - * @param apiKeyTemplate / - */ - @Autowired(required = false) - public void setSaApiKeyTemplate(SaApiKeyTemplate apiKeyTemplate) { - SaApiKeyManager.setSaApiKeyTemplate(apiKeyTemplate); - } - - /** - * 注入自定义的 API Key 数据加载器 Bean - * - * @param apiKeyDataLoader / - */ - @Autowired(required = false) - public void setSaApiKeyDataLoader(SaApiKeyDataLoader apiKeyDataLoader) { - SaApiKeyManager.setSaApiKeyDataLoader(apiKeyDataLoader); - } - -} diff --git a/sa-token-starter/sa-token-spring-boot-autoconfig/src/main/java/cn/dev33/satoken/spring/apikey/SaApiKeyBeanRegister.java b/sa-token-starter/sa-token-spring-boot-autoconfig/src/main/java/cn/dev33/satoken/spring/apikey/SaApiKeyBeanRegister.java deleted file mode 100644 index d6414514..00000000 --- a/sa-token-starter/sa-token-spring-boot-autoconfig/src/main/java/cn/dev33/satoken/spring/apikey/SaApiKeyBeanRegister.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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.spring.apikey; - -import cn.dev33.satoken.apikey.SaApiKeyManager; -import cn.dev33.satoken.apikey.config.SaApiKeyConfig; -import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.context.annotation.Bean; - -/** - * 注册 Sa-Token API Key 所需要的 Bean - * - * @author click33 - * @since 1.43.0 - */ -@ConditionalOnClass(SaApiKeyManager.class) -public class SaApiKeyBeanRegister { - - /** - * 获取 API Key 配置对象 - * @return 配置对象 - */ - @Bean - @ConfigurationProperties(prefix = "sa-token.api-key") - public SaApiKeyConfig getSaApiKeyConfig() { - return new SaApiKeyConfig(); - } - -} diff --git a/sa-token-starter/sa-token-spring-boot-autoconfig/src/main/java/cn/dev33/satoken/spring/apikey/package-info.java b/sa-token-starter/sa-token-spring-boot-autoconfig/src/main/java/cn/dev33/satoken/spring/apikey/package-info.java deleted file mode 100644 index f5874af8..00000000 --- a/sa-token-starter/sa-token-spring-boot-autoconfig/src/main/java/cn/dev33/satoken/spring/apikey/package-info.java +++ /dev/null @@ -1,19 +0,0 @@ -/* - * 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. - */ -/** - * sa-token-apikey 模块自动化配置(只有引入了 sa-token-apikey 模块后,此包下的代码才会开始工作) - */ -package cn.dev33.satoken.spring.apikey; \ No newline at end of file diff --git a/sa-token-starter/sa-token-spring-boot-autoconfig/src/main/java/cn/dev33/satoken/spring/context/path/ApplicationContextPathLoading.java b/sa-token-starter/sa-token-spring-boot-autoconfig/src/main/java/cn/dev33/satoken/spring/context/path/ApplicationContextPathLoading.java deleted file mode 100644 index 9ce85586..00000000 --- a/sa-token-starter/sa-token-spring-boot-autoconfig/src/main/java/cn/dev33/satoken/spring/context/path/ApplicationContextPathLoading.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * 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.spring.context.path; - -import cn.dev33.satoken.application.ApplicationInfo; -import cn.dev33.satoken.util.SaFoxUtil; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.ApplicationArguments; -import org.springframework.boot.ApplicationRunner; - -/** - * 应用上下文路径加载器 - * - * @author click33 - * @since 1.37.0 - */ -public class ApplicationContextPathLoading implements ApplicationRunner { - - @Value("${server.servlet.context-path:}") - String contextPath; - - @Value("${spring.mvc.servlet.path:}") - String servletPath; - - @Override - public void run(ApplicationArguments args) throws Exception { - - String routePrefix = ""; - - if(SaFoxUtil.isNotEmpty(contextPath)) { - if(! contextPath.startsWith("/")){ - contextPath = "/" + contextPath; - } - if (contextPath.endsWith("/")) { - contextPath = contextPath.substring(0, contextPath.length() - 1); - } - routePrefix += contextPath; - } - - if(SaFoxUtil.isNotEmpty(servletPath)) { - if(! servletPath.startsWith("/")){ - servletPath = "/" + servletPath; - } - if (servletPath.endsWith("/")) { - servletPath = servletPath.substring(0, servletPath.length() - 1); - } - routePrefix += servletPath; - } - - if(SaFoxUtil.isNotEmpty(routePrefix) && ! routePrefix.equals("/") ){ - ApplicationInfo.routePrefix = routePrefix; - } - } - -} \ 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/SaOAuth2BeanInject.java b/sa-token-starter/sa-token-spring-boot-autoconfig/src/main/java/cn/dev33/satoken/spring/oauth2/SaOAuth2BeanInject.java deleted file mode 100644 index 03748859..00000000 --- a/sa-token-starter/sa-token-spring-boot-autoconfig/src/main/java/cn/dev33/satoken/spring/oauth2/SaOAuth2BeanInject.java +++ /dev/null @@ -1,153 +0,0 @@ -/* - * 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.spring.oauth2; - -import cn.dev33.satoken.oauth2.SaOAuth2Manager; -import cn.dev33.satoken.oauth2.config.SaOAuth2ServerConfig; -import cn.dev33.satoken.oauth2.dao.SaOAuth2Dao; -import cn.dev33.satoken.oauth2.data.convert.SaOAuth2DataConverter; -import cn.dev33.satoken.oauth2.data.generate.SaOAuth2DataGenerate; -import cn.dev33.satoken.oauth2.data.loader.SaOAuth2DataLoader; -import cn.dev33.satoken.oauth2.data.resolver.SaOAuth2DataResolver; -import cn.dev33.satoken.oauth2.granttype.handler.SaOAuth2GrantTypeHandlerInterface; -import cn.dev33.satoken.oauth2.processor.SaOAuth2ServerProcessor; -import cn.dev33.satoken.oauth2.scope.handler.SaOAuth2ScopeHandlerInterface; -import cn.dev33.satoken.oauth2.strategy.SaOAuth2Strategy; -import cn.dev33.satoken.oauth2.template.SaOAuth2Template; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; - -import java.util.List; - - -// 小提示:如果你在 idea 中运行源码时出现异常:java: 程序包cn.dev33.satoken.oauth2不存在。 -// 在项目根目录进入 cmd,执行 mvn package 即可解决 - - -/** - * 注入 Sa-Token-OAuth2 所需要的组件 - * - * @author click33 - * @since 1.34.0 - */ -@ConditionalOnClass(SaOAuth2Manager.class) -public class SaOAuth2BeanInject { - - /** - * 注入 OAuth2 配置对象 - * - * @param saOAuth2Config 配置对象 - */ - @Autowired(required = false) - public void setSaOAuth2Config(SaOAuth2ServerConfig saOAuth2Config) { - SaOAuth2Manager.setServerConfig(saOAuth2Config); - } - - /** - * 注入 OAuth2 模板代码类 - * - * @param saOAuth2Template 模板代码类 - */ - @Autowired(required = false) - public void setSaOAuth2Template(SaOAuth2Template saOAuth2Template) { - SaOAuth2Manager.setTemplate(saOAuth2Template); - } - - /** - * 注入 OAuth2 请求处理器 - * - * @param serverProcessor 请求处理器 - */ - @Autowired(required = false) - public void setSaOAuth2Template(SaOAuth2ServerProcessor serverProcessor) { - SaOAuth2ServerProcessor.instance = serverProcessor; - } - - /** - * 注入 OAuth2 数据加载器 - * - * @param dataLoader / - */ - @Autowired(required = false) - public void setSaOAuth2DataLoader(SaOAuth2DataLoader dataLoader) { - SaOAuth2Manager.setDataLoader(dataLoader); - } - - /** - * 注入 OAuth2 数据解析器 Bean - * - * @param dataResolver / - */ - @Autowired(required = false) - public void setSaOAuth2DataResolver(SaOAuth2DataResolver dataResolver) { - SaOAuth2Manager.setDataResolver(dataResolver); - } - - /** - * 注入 OAuth2 数据格式转换器 Bean - * - * @param dataConverter / - */ - @Autowired(required = false) - public void setSaOAuth2DataConverter(SaOAuth2DataConverter dataConverter) { - SaOAuth2Manager.setDataConverter(dataConverter); - } - - /** - * 注入 OAuth2 数据构建器 Bean - * - * @param dataGenerate / - */ - @Autowired(required = false) - public void setSaOAuth2DataGenerate(SaOAuth2DataGenerate dataGenerate) { - SaOAuth2Manager.setDataGenerate(dataGenerate); - } - - /** - * 注入 OAuth2 数据持久 Bean - * - * @param dao / - */ - @Autowired(required = false) - public void setSaOAuth2Dao(SaOAuth2Dao dao) { - SaOAuth2Manager.setDao(dao); - } - - /** - * 注入自定义 scope 处理器 - * - * @param handlerList 自定义 scope 处理器集合 - */ - @Autowired(required = false) - public void setSaOAuth2ScopeHandler(List handlerList) { - for (SaOAuth2ScopeHandlerInterface handler : handlerList) { - SaOAuth2Strategy.instance.registerScopeHandler(handler); - } - } - - /** - * 注入自定义 grant_type 处理器 - * - * @param handlerList 自定义 grant_type 处理器集合 - */ - @Autowired(required = false) - public void setSaOAuth2GrantTypeHandlerInterface(List handlerList) { - for (SaOAuth2GrantTypeHandlerInterface handler : handlerList) { - SaOAuth2Strategy.instance.registerGrantTypeHandler(handler); - } - } - -} 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 deleted file mode 100644 index 788f97af..00000000 --- a/sa-token-starter/sa-token-spring-boot-autoconfig/src/main/java/cn/dev33/satoken/spring/oauth2/SaOAuth2BeanRegister.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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.spring.oauth2; - -import cn.dev33.satoken.oauth2.SaOAuth2Manager; -import cn.dev33.satoken.oauth2.config.SaOAuth2ServerConfig; -import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.context.annotation.Bean; - -/** - * 注册 Sa-Token-OAuth2 所需要的Bean - * - * @author click33 - * @since 1.34.0 - */ -@ConditionalOnClass(SaOAuth2Manager.class) -public class SaOAuth2BeanRegister { - - /** - * 获取 OAuth2 配置 Bean - * - * @return 配置对象 - */ - @Bean - @ConfigurationProperties(prefix = "sa-token.oauth2-server") - public SaOAuth2ServerConfig getSaOAuth2Config() { - return new SaOAuth2ServerConfig(); - } - -} diff --git a/sa-token-starter/sa-token-spring-boot-autoconfig/src/main/java/cn/dev33/satoken/spring/oauth2/package-info.java b/sa-token-starter/sa-token-spring-boot-autoconfig/src/main/java/cn/dev33/satoken/spring/oauth2/package-info.java deleted file mode 100644 index d4f2d942..00000000 --- a/sa-token-starter/sa-token-spring-boot-autoconfig/src/main/java/cn/dev33/satoken/spring/oauth2/package-info.java +++ /dev/null @@ -1,19 +0,0 @@ -/* - * 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. - */ -/** - * Sa-Token-OAuth2 模块自动化配置(只有引入了Sa-Token-OAuth2模块后,此包下的代码才会开始工作) - */ -package cn.dev33.satoken.spring.oauth2; \ No newline at end of file diff --git a/sa-token-starter/sa-token-spring-boot-autoconfig/src/main/java/cn/dev33/satoken/spring/pathmatch/SaPathMatcherHolder.java b/sa-token-starter/sa-token-spring-boot-autoconfig/src/main/java/cn/dev33/satoken/spring/pathmatch/SaPathMatcherHolder.java deleted file mode 100644 index f5a92491..00000000 --- a/sa-token-starter/sa-token-spring-boot-autoconfig/src/main/java/cn/dev33/satoken/spring/pathmatch/SaPathMatcherHolder.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * 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.spring.pathmatch; - -import org.springframework.util.AntPathMatcher; -import org.springframework.util.PathMatcher; - -/** - * 路由匹配工具类:持有 PathMatcher 全局引用,方便快捷的调用 PathMatcher 相关方法 - * - * @author click33 - * @since 1.34.0 - */ -public class SaPathMatcherHolder { - - private SaPathMatcherHolder() { - } - - /** - * 路由匹配器 - */ - public static PathMatcher pathMatcher; - - /** - * 获取路由匹配器 - * @return 路由匹配器 - */ - public static PathMatcher getPathMatcher() { - if(pathMatcher == null) { - pathMatcher = new AntPathMatcher(); - } - return pathMatcher; - } - - /** - * 写入路由匹配器 - * @param pathMatcher 路由匹配器 - */ - public static void setPathMatcher(PathMatcher pathMatcher) { - SaPathMatcherHolder.pathMatcher = pathMatcher; - } - -} diff --git a/sa-token-starter/sa-token-spring-boot-autoconfig/src/main/java/cn/dev33/satoken/spring/pathmatch/SaPathPatternParserUtil.java b/sa-token-starter/sa-token-spring-boot-autoconfig/src/main/java/cn/dev33/satoken/spring/pathmatch/SaPathPatternParserUtil.java deleted file mode 100644 index 176f9025..00000000 --- a/sa-token-starter/sa-token-spring-boot-autoconfig/src/main/java/cn/dev33/satoken/spring/pathmatch/SaPathPatternParserUtil.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * 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.spring.pathmatch; - -import org.springframework.http.server.PathContainer; -import org.springframework.web.util.pattern.PathPattern; -import org.springframework.web.util.pattern.PathPatternParser; - -/** - * 路由匹配工具类:使用 PathPatternParser 模式匹配 - * - * @author click33 - * @since 1.35.1 - */ -public class SaPathPatternParserUtil { - - private SaPathPatternParserUtil() { - } - - /** - * 判断:指定路由匹配符是否可以匹配成功指定路径 - * @param pattern 路由匹配符 - * @param path 要匹配的路径 - * @return 是否匹配成功 - */ - public static boolean match(String pattern, String path) { - PathPattern pathPattern = PathPatternParser.defaultInstance.parse(pattern); - PathContainer pathContainer = PathContainer.parsePath(path); - return pathPattern.matches(pathContainer); - } - - /* - 表现: - springboot 2.x SpringMVC match("/test/test", "/test/test/") // true - springboot 2.x WebFlux match("/test/test", "/test/test/") // true - springboot 3.x SpringMVC match("/test/test", "/test/test/") // false - springboot 3.x WebFlux match("/test/test", "/test/test/") // false - */ - -} diff --git a/sa-token-starter/sa-token-spring-boot-autoconfig/src/main/java/cn/dev33/satoken/spring/pathmatch/SaPatternsRequestConditionHolder.java b/sa-token-starter/sa-token-spring-boot-autoconfig/src/main/java/cn/dev33/satoken/spring/pathmatch/SaPatternsRequestConditionHolder.java deleted file mode 100644 index bb9e503e..00000000 --- a/sa-token-starter/sa-token-spring-boot-autoconfig/src/main/java/cn/dev33/satoken/spring/pathmatch/SaPatternsRequestConditionHolder.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * 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.spring.pathmatch; - -import cn.dev33.satoken.exception.SaTokenException; -import org.springframework.web.servlet.mvc.condition.PatternsRequestCondition; - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - -/** - * 路由匹配工具类 - * - * @author click33 - * @since 1.35.1 - */ -public class SaPatternsRequestConditionHolder { - - private SaPatternsRequestConditionHolder() { - } - - public static PatternsRequestCondition patternsRequestCondition; - - public static Method matcherMethod; - - static { - try { - patternsRequestCondition = new PatternsRequestCondition(); - matcherMethod = PatternsRequestCondition.class.getDeclaredMethod("getMatchingPattern", String.class, String.class); - matcherMethod.setAccessible(true); - } catch (NoSuchMethodException e) { - throw new SaTokenException("路由匹配器初始化失败", e); - } - } - - /** - * 判断:指定路由匹配符是否可以匹配成功指定路径 - * @param pattern 路由匹配符 - * @param lookupPath 要匹配的路径 - * @return 是否匹配成功 - */ - public static boolean match(String pattern, String lookupPath) { - try { - return matcherMethod.invoke(patternsRequestCondition, pattern, lookupPath) != null; - } catch (IllegalAccessException | InvocationTargetException e) { - throw new SaTokenException("路由匹配器调用失败", e); - } - } - - /* - 性能测试: - 100万次 - new 对象方式,耗时:3.685s 最慢 - 反射调方法方式,耗时:1.311s 中等 - 原始方式,耗时:0.445s 最快,但有bug - */ - -} diff --git a/sa-token-starter/sa-token-spring-boot-autoconfig/src/main/java/cn/dev33/satoken/spring/sign/SaSignBeanInject.java b/sa-token-starter/sa-token-spring-boot-autoconfig/src/main/java/cn/dev33/satoken/spring/sign/SaSignBeanInject.java deleted file mode 100644 index 8944e2a1..00000000 --- a/sa-token-starter/sa-token-spring-boot-autoconfig/src/main/java/cn/dev33/satoken/spring/sign/SaSignBeanInject.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * 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.spring.sign; - -import cn.dev33.satoken.sign.SaSignManager; -import cn.dev33.satoken.sign.config.SaSignConfig; -import cn.dev33.satoken.sign.config.SaSignManyConfigWrapper; -import cn.dev33.satoken.sign.template.SaSignTemplate; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; - -/** - * 注入 Sa-Token API 参数签名 所需要的 Bean - * - * @author click33 - * @since 1.43.0 - */ -@ConditionalOnClass(SaSignManager.class) -public class SaSignBeanInject { - - /** - * 注入 API 参数签名配置对象 - * - * @param saSignConfig 配置对象 - */ - @Autowired(required = false) - public void setSignConfig(SaSignConfig saSignConfig) { - SaSignManager.setConfig(saSignConfig); - } - - /** - * 注入 API 参数签名配置对象 - * - * @param signManyConfigWrapper 配置对象 - */ - @Autowired(required = false) - public void setSignManyConfig(SaSignManyConfigWrapper signManyConfigWrapper) { - SaSignManager.setSignMany(signManyConfigWrapper.getSignMany()); - } - - /** - * 注入自定义的 参数签名 模版方法 Bean - * - * @param saSignTemplate 参数签名 Bean - */ - @Autowired(required = false) - public void setSaSignTemplate(SaSignTemplate saSignTemplate) { - SaSignManager.setSaSignTemplate(saSignTemplate); - } - -} diff --git a/sa-token-starter/sa-token-spring-boot-autoconfig/src/main/java/cn/dev33/satoken/spring/sign/SaSignBeanRegister.java b/sa-token-starter/sa-token-spring-boot-autoconfig/src/main/java/cn/dev33/satoken/spring/sign/SaSignBeanRegister.java deleted file mode 100644 index a6e740d2..00000000 --- a/sa-token-starter/sa-token-spring-boot-autoconfig/src/main/java/cn/dev33/satoken/spring/sign/SaSignBeanRegister.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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.spring.sign; - -import cn.dev33.satoken.sign.SaSignManager; -import cn.dev33.satoken.sign.config.SaSignConfig; -import cn.dev33.satoken.sign.config.SaSignManyConfigWrapper; -import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.context.annotation.Bean; - -/** - * 注册 Sa-Token API 参数签名所需要的 Bean - * - * @author click33 - * @since 1.43.0 - */ -@ConditionalOnClass(SaSignManager.class) -public class SaSignBeanRegister { - - /** - * 获取 API 参数签名配置对象 - * @return 配置对象 - */ - @Bean - @ConfigurationProperties(prefix = "sa-token.sign") - public SaSignConfig getSaSignConfig() { - return new SaSignConfig(); - } - - /** - * 获取 API 参数签名 Many 配置对象 - * @return 配置对象 - */ - @Bean - @ConfigurationProperties(prefix = "sa-token") - public SaSignManyConfigWrapper getSaSignManyConfigWrapper() { - return new SaSignManyConfigWrapper(); - } - -} diff --git a/sa-token-starter/sa-token-spring-boot-autoconfig/src/main/java/cn/dev33/satoken/spring/sign/package-info.java b/sa-token-starter/sa-token-spring-boot-autoconfig/src/main/java/cn/dev33/satoken/spring/sign/package-info.java deleted file mode 100644 index be4e2f90..00000000 --- a/sa-token-starter/sa-token-spring-boot-autoconfig/src/main/java/cn/dev33/satoken/spring/sign/package-info.java +++ /dev/null @@ -1,19 +0,0 @@ -/* - * 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. - */ -/** - * sa-token-sign 模块自动化配置(只有引入了 sa-token-sign 模块后,此包下的代码才会开始工作) - */ -package cn.dev33.satoken.spring.sign; \ No newline at end of file diff --git a/sa-token-starter/sa-token-spring-boot-autoconfig/src/main/java/cn/dev33/satoken/spring/sso/SaSsoBeanInject.java b/sa-token-starter/sa-token-spring-boot-autoconfig/src/main/java/cn/dev33/satoken/spring/sso/SaSsoBeanInject.java deleted file mode 100644 index 9e8f07b9..00000000 --- a/sa-token-starter/sa-token-spring-boot-autoconfig/src/main/java/cn/dev33/satoken/spring/sso/SaSsoBeanInject.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * 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.spring.sso; - -import cn.dev33.satoken.sso.SaSsoManager; -import cn.dev33.satoken.sso.config.SaSsoClientConfig; -import cn.dev33.satoken.sso.config.SaSsoServerConfig; -import cn.dev33.satoken.sso.processor.SaSsoClientProcessor; -import cn.dev33.satoken.sso.processor.SaSsoServerProcessor; -import cn.dev33.satoken.sso.template.SaSsoClientTemplate; -import cn.dev33.satoken.sso.template.SaSsoServerTemplate; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; - -/** - * 注入 Sa-Token SSO 所需要的 Bean - * - * @author click33 - * @since 1.34.0 - */ -@ConditionalOnClass(SaSsoManager.class) -public class SaSsoBeanInject { - - /** - * 注入 Sa-Token SSO Server 端 配置类 - * - * @param serverConfig 配置对象 - */ - @Autowired(required = false) - public void setSaSsoServerConfig(SaSsoServerConfig serverConfig) { - SaSsoManager.setServerConfig(serverConfig); - } - - /** - * 注入 Sa-Token SSO Client 端 配置类 - * - * @param clientConfig 配置对象 - */ - @Autowired(required = false) - public void setSaSsoClientConfig(SaSsoClientConfig clientConfig) { - SaSsoManager.setClientConfig(clientConfig); - } - - /** - * 注入 SSO 模板代码类 (Server 端) - * - * @param ssoServerTemplate / - */ - @Autowired(required = false) - public void setSaSsoServerTemplate(SaSsoServerTemplate ssoServerTemplate) { - SaSsoServerProcessor.instance.ssoServerTemplate = ssoServerTemplate; - } - - /** - * 注入 SSO 模板代码类 (Client 端) - * - * @param ssoClientTemplate / - */ - @Autowired(required = false) - public void setSaSsoClientTemplate(SaSsoClientTemplate ssoClientTemplate) { - SaSsoClientProcessor.instance.ssoClientTemplate = ssoClientTemplate; - } - -} diff --git a/sa-token-starter/sa-token-spring-boot-autoconfig/src/main/java/cn/dev33/satoken/spring/sso/SaSsoBeanRegister.java b/sa-token-starter/sa-token-spring-boot-autoconfig/src/main/java/cn/dev33/satoken/spring/sso/SaSsoBeanRegister.java deleted file mode 100644 index 2c102df8..00000000 --- a/sa-token-starter/sa-token-spring-boot-autoconfig/src/main/java/cn/dev33/satoken/spring/sso/SaSsoBeanRegister.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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.spring.sso; - -import cn.dev33.satoken.sso.SaSsoManager; -import cn.dev33.satoken.sso.config.SaSsoClientConfig; -import cn.dev33.satoken.sso.config.SaSsoServerConfig; -import cn.dev33.satoken.sso.processor.SaSsoClientProcessor; -import cn.dev33.satoken.sso.processor.SaSsoServerProcessor; -import cn.dev33.satoken.sso.template.SaSsoClientTemplate; -import cn.dev33.satoken.sso.template.SaSsoServerTemplate; -import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.context.annotation.Bean; - -/** - * 注册 Sa-Token SSO 所需要的 Bean - * - * @author click33 - * @since 1.34.0 - */ -@ConditionalOnClass(SaSsoManager.class) -public class SaSsoBeanRegister { - - /** - * 获取 SSO Server 端 配置对象 - * @return 配置对象 - */ - @Bean - @ConfigurationProperties(prefix = "sa-token.sso-server") - public SaSsoServerConfig getSaSsoServerConfig() { - return new SaSsoServerConfig(); - } - - /** - * 获取 SSO Client 端 配置对象 - * @return 配置对象 - */ - @Bean - @ConfigurationProperties(prefix = "sa-token.sso-client") - public SaSsoClientConfig getSaSsoClientConfig() { - return new SaSsoClientConfig(); - } - - /** - * 获取 SSO Server 端 SaSsoServerTemplate - * - * @return / - */ - @Bean - @ConditionalOnMissingBean(SaSsoServerTemplate.class) - public SaSsoServerTemplate getSaSsoServerTemplate() { - return SaSsoServerProcessor.instance.ssoServerTemplate; - } - - /** - * 获取 SSO Client 端 SaSsoClientTemplate - * - * @return / - */ - @Bean - @ConditionalOnMissingBean(SaSsoClientTemplate.class) - public SaSsoClientTemplate getSaSsoClientTemplate() { - return SaSsoClientProcessor.instance.ssoClientTemplate; - } - -} diff --git a/sa-token-starter/sa-token-spring-boot-autoconfig/src/main/java/cn/dev33/satoken/spring/sso/package-info.java b/sa-token-starter/sa-token-spring-boot-autoconfig/src/main/java/cn/dev33/satoken/spring/sso/package-info.java deleted file mode 100644 index bc022e56..00000000 --- a/sa-token-starter/sa-token-spring-boot-autoconfig/src/main/java/cn/dev33/satoken/spring/sso/package-info.java +++ /dev/null @@ -1,19 +0,0 @@ -/* - * 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. - */ -/** - * Sa-Token-SSO 模块自动化配置(只有引入了 sa-token-sso 模块后,此包下的代码才会开始工作) - */ -package cn.dev33.satoken.spring.sso; \ No newline at end of file diff --git a/sa-token-starter/sa-token-spring-boot-autoconfig/src/main/resources/META-INF/spring.factories b/sa-token-starter/sa-token-spring-boot-autoconfig/src/main/resources/META-INF/spring.factories deleted file mode 100644 index d592afc2..00000000 --- a/sa-token-starter/sa-token-spring-boot-autoconfig/src/main/resources/META-INF/spring.factories +++ /dev/null @@ -1,11 +0,0 @@ -org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ -cn.dev33.satoken.spring.SaBeanRegister,\ -cn.dev33.satoken.spring.SaBeanInject,\ -cn.dev33.satoken.spring.sso.SaSsoBeanRegister,\ -cn.dev33.satoken.spring.sso.SaSsoBeanInject,\ -cn.dev33.satoken.spring.oauth2.SaOAuth2BeanRegister,\ -cn.dev33.satoken.spring.oauth2.SaOAuth2BeanInject,\ -cn.dev33.satoken.spring.apikey.SaApiKeyBeanRegister,\ -cn.dev33.satoken.spring.apikey.SaApiKeyBeanInject,\ -cn.dev33.satoken.spring.sign.SaSignBeanRegister,\ -cn.dev33.satoken.spring.sign.SaSignBeanInject \ No newline at end of file diff --git a/sa-token-starter/sa-token-spring-boot-autoconfig/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/sa-token-starter/sa-token-spring-boot-autoconfig/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports deleted file mode 100644 index b227d742..00000000 --- a/sa-token-starter/sa-token-spring-boot-autoconfig/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports +++ /dev/null @@ -1,10 +0,0 @@ -cn.dev33.satoken.spring.SaBeanRegister -cn.dev33.satoken.spring.SaBeanInject -cn.dev33.satoken.spring.sso.SaSsoBeanRegister -cn.dev33.satoken.spring.sso.SaSsoBeanInject -cn.dev33.satoken.spring.oauth2.SaOAuth2BeanRegister -cn.dev33.satoken.spring.oauth2.SaOAuth2BeanInject -cn.dev33.satoken.spring.apikey.SaApiKeyBeanRegister -cn.dev33.satoken.spring.apikey.SaApiKeyBeanInject -cn.dev33.satoken.spring.sign.SaSignBeanRegister -cn.dev33.satoken.spring.sign.SaSignBeanInject \ No newline at end of file