支持单点登录

This commit is contained in:
lizhengwei 2026-04-07 16:02:01 +08:00
parent f0151d6521
commit 61b76803f9

View File

@ -1,13 +1,52 @@
package org.dromara.gateway.config;
import cn.dev33.satoken.jwt.StpLogicJwtForSimple;
import cn.dev33.satoken.sso.config.SaSsoClientConfig;
import cn.dev33.satoken.stp.StpLogic;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;
@Slf4j
@Configuration
public class SaTokenConfigure {
// Sa-Token 整合 jwt (Simple 简单模式)
private final RestTemplate restTemplate = new RestTemplate();
@Autowired
private void configSsoClient(SaSsoClientConfig ssoClientConfig) {
ssoClientConfig.sendHttp = url -> {
try {
log.info("SSO-Client端发起请求{}", url);
// String resStr = Forest.get(url).executeAsString();
String resStr = restTemplate.getForObject(url, String.class);
log.info("SSO-Client端请求结果{}", resStr);
return resStr;
} catch (Exception e) {
log.error("SSO-Client端发送Http请求异常", e);
return null;
}
};
}
//
// @Autowired
// private void configSsoServer(SaSsoServerConfig ssoServerConfig) {
// ssoServerConfig.sendHttp = url -> {
// try {
// log.info("SSO-Server端发起请求{}", url);
/// / String resStr = Forest.get(url).executeAsString();
// String resStr = restTemplate.getForObject(url,String.class);
// log.info("SSO-Server端请求结果{}", resStr);
// return resStr;
// } catch (Exception e) {
// log.error("SSO-Server端发送Http请求异常", e);
// return null;
// }
// };
// }
@Bean
public StpLogic getStpLogicJwt() {
return new StpLogicJwtForSimple();