!298 优化 solon 相关的 demo 代码

Merge pull request !298 from 西东/dev
This commit is contained in:
刘潇 2024-05-11 05:59:23 +00:00 committed by Gitee
commit 26bf2bd478
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
16 changed files with 38 additions and 47 deletions

View File

@ -10,7 +10,7 @@
<parent>
<groupId>org.noear</groupId>
<artifactId>solon-parent</artifactId>
<version>2.4.0</version>
<version>2.7.0</version>
<relativePath/>
</parent>

View File

@ -10,7 +10,7 @@
<parent>
<groupId>org.noear</groupId>
<artifactId>solon-parent</artifactId>
<version>2.4.0</version>
<version>2.7.0</version>
<relativePath/>
</parent>

View File

@ -10,14 +10,13 @@
<parent>
<groupId>org.noear</groupId>
<artifactId>solon-parent</artifactId>
<version>2.4.0</version>
<version>2.7.0</version>
<relativePath/>
</parent>
<!-- 定义 Sa-Token 版本号 -->
<properties>
<sa-token.version>1.38.0</sa-token.version>
<solon.version>2.2.3</solon.version>
</properties>
<dependencies>

View File

@ -21,7 +21,7 @@ public class SsoConfig {
* 构建建 SaToken redis dao如果不需要 redis可以注释掉
* */
@Bean
public SaTokenDao saTokenDaoInit(@Inject("${sa-token.redis}") SaTokenDaoOfRedis saTokenDao) {
public SaTokenDao saTokenDaoInit(@Inject("${sa-token.dao.redis}") SaTokenDaoOfRedis saTokenDao) {
return saTokenDao;
}

View File

@ -26,7 +26,7 @@ sa-token:
secret-key: kQwIOrYvnXmSDkwEiFngrKidMcdrgKor
# ---- 除了以上配置项,你还需要为 Sa-Token 配置http请求处理器文档有步骤说明
sa-token: #名字可以随意取
sa-token.dao: #名字可以随意取
redis:
server: "localhost:6379"
password: 123456

View File

@ -10,7 +10,7 @@
<parent>
<groupId>org.noear</groupId>
<artifactId>solon-parent</artifactId>
<version>2.4.0</version>
<version>2.7.0</version>
<relativePath/>
</parent>

View File

@ -16,7 +16,7 @@ public class SaConfig {
* 配置 Sa-Token 单独使用的Redis连接 此处需要和SSO-Server端连接同一个Redis
* */
@Bean
public SaTokenDao saTokenDaoInit(@Inject("${sa-token.redis}") SaTokenDaoOfRedis saTokenDao) {
public SaTokenDao saTokenDaoInit(@Inject("${sa-token.dao.redis}") SaTokenDaoOfRedis saTokenDao) {
return saTokenDao;
}
}

View File

@ -12,7 +12,7 @@ sa-token:
slo-url: http://sso.stp.com:9000/sso/signout
# 配置 Sa-Token 单独使用的Redis连接 此处需要和SSO-Server端连接同一个Redis
sa-token: #名字可以随意取
sa-token.dao: #名字可以随意取
redis:
server: "localhost:6379"
password: 123456

View File

@ -10,7 +10,7 @@
<parent>
<groupId>org.noear</groupId>
<artifactId>solon-parent</artifactId>
<version>2.4.0</version>
<version>2.7.0</version>
<relativePath/>
</parent>

View File

@ -16,7 +16,7 @@ public class SaConfig {
* 配置 Sa-Token 单独使用的Redis连接 此处需要和SSO-Server端连接同一个Redis
* */
@Bean
public SaTokenDao saTokenDaoInit(@Inject("${sa-token.redis}") SaTokenDaoOfRedis saTokenDao) {
public SaTokenDao saTokenDaoInit(@Inject("${sa-token.dao.redis}") SaTokenDaoOfRedis saTokenDao) {
return saTokenDao;
}
}

View File

@ -1,6 +1,6 @@
# 端口
server:
port: 9001
port: 9002
# sa-token配置
sa-token:
@ -13,7 +13,7 @@ sa-token:
is-slo: true
# 配置 Sa-Token 单独使用的Redis连接 此处需要和SSO-Server端连接同一个Redis
sa-token: #名字可以随意取
sa-token.dao: #名字可以随意取
redis:
server: "localhost:6379"
password: 123456

View File

@ -10,7 +10,7 @@
<parent>
<groupId>org.noear</groupId>
<artifactId>solon-parent</artifactId>
<version>2.4.0</version>
<version>2.7.0</version>
<relativePath/>
</parent>
@ -26,6 +26,12 @@
<groupId>org.noear</groupId>
<artifactId>solon-api</artifactId>
</dependency>
<!-- Http 请求工具 -->
<dependency>
<groupId>org.noear</groupId>
<artifactId>forest-solon-plugin</artifactId>
</dependency>
<!-- Sa-Token 权限认证, 在线文档https://sa-token.cc/ -->
<dependency>
@ -47,15 +53,7 @@
<artifactId>sa-token-redisx</artifactId>
<version>${sa-token.version}</version>
</dependency>
<!-- Http 请求工具 -->
<dependency>
<groupId>com.dtflys.forest</groupId>
<artifactId>forest-solon-plugin</artifactId>
<version>1.5.29</version>
</dependency>
</dependencies>

View File

@ -16,7 +16,7 @@ public class SaConfig {
* 构建建 SaToken redis dao如果不需要 redis可以注释掉
* */
@Bean
public SaTokenDao saTokenDaoInit(@Inject("${sa-token.redis}") SaTokenDaoOfRedis saTokenDao) {
public SaTokenDao saTokenDaoInit(@Inject("${sa-token.dao.redis}") SaTokenDaoOfRedis saTokenDao) {
return saTokenDao;
}
}

View File

@ -1,6 +1,6 @@
# 端口
server:
port: 9001
port: 9003
# sa-token配置
sa-token:
@ -23,7 +23,7 @@ sa-token:
# 配置 Sa-Token Dao此处与SSO-Server端连接不同的Redis
sa-token: #名字可以随意取
sa-token.dao: #名字可以随意取
redis:
server: "localhost:6379"
password: 123456

View File

@ -24,7 +24,6 @@ import org.noear.solon.annotation.Condition;
import org.noear.solon.annotation.Configuration;
import org.noear.solon.annotation.Inject;
import org.noear.solon.core.AppContext;
import org.noear.solon.core.bean.InitializingBean;
/**
* @author noear
@ -33,12 +32,9 @@ import org.noear.solon.core.bean.InitializingBean;
@Condition(onClass = SaOAuth2Manager.class)
@Configuration
public class SaOAuth2AutoConfigure implements InitializingBean {
@Inject
private AppContext appContext;
@Override
public void afterInjection() throws Throwable {
public class SaOAuth2AutoConfigure {
@Bean
public void init(AppContext appContext) throws Throwable {
appContext.subBeansOfType(SaOAuth2Template.class, bean -> {
SaOAuth2Util.saOAuth2Template = bean;
});

View File

@ -36,39 +36,37 @@ import org.noear.solon.core.bean.InitializingBean;
@Condition(onClass = SaSsoManager.class)
@Configuration
public class SaSsoAutoConfigure implements InitializingBean {
@Inject
private AppContext appContext;
@Override
public void afterInjection() throws Throwable {
appContext.subBeansOfType(SaSsoServerTemplate.class, bean->{
public class SaSsoAutoConfigure {
@Bean
public void init(AppContext appContext) throws Throwable {
appContext.subBeansOfType(SaSsoServerTemplate.class, bean -> {
SaSsoServerProcessor.instance.ssoServerTemplate = bean;
});
appContext.subBeansOfType(SaSsoClientTemplate.class, bean->{
appContext.subBeansOfType(SaSsoClientTemplate.class, bean -> {
SaSsoClientProcessor.instance.ssoClientTemplate = bean;
});
appContext.subBeansOfType(SaSsoServerConfig.class, bean->{
appContext.subBeansOfType(SaSsoServerConfig.class, bean -> {
SaSsoManager.setServerConfig(bean);
});
appContext.subBeansOfType(SaSsoClientConfig.class, bean->{
appContext.subBeansOfType(SaSsoClientConfig.class, bean -> {
SaSsoManager.setClientConfig(bean);
});
}
/**
* 获取 SSO Server 配置Bean
* */
*/
@Bean
public SaSsoServerConfig getConfig(@Inject(value = "${sa-token.sso-server}",required = false) SaSsoServerConfig ssoConfig) {
public SaSsoServerConfig getConfig(@Inject(value = "${sa-token.sso-server}", required = false) SaSsoServerConfig ssoConfig) {
return ssoConfig;
}
/**
* 获取 SSO Client 配置Bean
* */
*/
@Bean
public SaSsoClientConfig getClientConfig(@Inject(value = "${sa-token.sso-client}",required = false) SaSsoClientConfig ssoConfig) {
public SaSsoClientConfig getClientConfig(@Inject(value = "${sa-token.sso-client}", required = false) SaSsoClientConfig ssoConfig) {
return ssoConfig;
}
}