mirror of
https://gitee.com/dromara/sa-token.git
synced 2026-05-14 04:42:09 +08:00
refactor: 移除 sa-token-spring-boot-autoconfig 模块
This commit is contained in:
@@ -1,78 +0,0 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>cn.dev33</groupId>
|
||||
<artifactId>sa-token-starter</artifactId>
|
||||
<version>${revision}</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>sa-token-spring-boot-autoconfig</name>
|
||||
<artifactId>sa-token-spring-boot-autoconfig</artifactId>
|
||||
<description>sa-token-spring-boot-autoconfig</description>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!-- spring-boot-starter (optional) -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-webmvc</artifactId>
|
||||
<version>5.3.7</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.fasterxml.jackson.core</groupId>-->
|
||||
<!-- <artifactId>jackson-databind</artifactId>-->
|
||||
<!-- <optional>true</optional>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<!-- config (optional) -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-configuration-processor</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<!-- SSO (optional) -->
|
||||
<dependency>
|
||||
<groupId>cn.dev33</groupId>
|
||||
<artifactId>sa-token-sso</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<!-- OAuth2.0 (optional) -->
|
||||
<dependency>
|
||||
<groupId>cn.dev33</groupId>
|
||||
<artifactId>sa-token-oauth2</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<!-- API Key (optional) -->
|
||||
<dependency>
|
||||
<groupId>cn.dev33</groupId>
|
||||
<artifactId>sa-token-apikey</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<!-- API Sign (optional) -->
|
||||
<dependency>
|
||||
<groupId>cn.dev33</groupId>
|
||||
<artifactId>sa-token-sign</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
|
||||
</project>
|
||||
@@ -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;
|
||||
@@ -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 {
|
||||
|
||||
/**
|
||||
* 组件注入
|
||||
* <p> 为确保 Log 组件正常打印,必须将 SaLog 和 SaTokenConfig 率先初始化 </p>
|
||||
*
|
||||
* @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<SaTokenListener> listenerList) {
|
||||
SaTokenEventCenter.registerListenerList(listenerList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 注入自定义注解处理器
|
||||
*
|
||||
* @param handlerList 自定义注解处理器集合
|
||||
*/
|
||||
@Autowired(required = false)
|
||||
public void setSaAnnotationHandler(List<SaAnnotationHandlerInterface<?>> 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<SaFirewallCheckHook> 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<SaTokenPlugin> plugins) {
|
||||
for (SaTokenPlugin plugin : plugins) {
|
||||
SaTokenPluginHolder.instance.installPlugin(plugin);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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
|
||||
* <p> 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();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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<SaOAuth2ScopeHandlerInterface> handlerList) {
|
||||
for (SaOAuth2ScopeHandlerInterface handler : handlerList) {
|
||||
SaOAuth2Strategy.instance.registerScopeHandler(handler);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 注入自定义 grant_type 处理器
|
||||
*
|
||||
* @param handlerList 自定义 grant_type 处理器集合
|
||||
*/
|
||||
@Autowired(required = false)
|
||||
public void setSaOAuth2GrantTypeHandlerInterface(List<SaOAuth2GrantTypeHandlerInterface> handlerList) {
|
||||
for (SaOAuth2GrantTypeHandlerInterface handler : handlerList) {
|
||||
SaOAuth2Strategy.instance.registerGrantTypeHandler(handler);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
}
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
@@ -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
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user