mirror of
https://gitee.com/dromara/sa-token.git
synced 2025-12-21 10:59:45 +08:00
优化单点登录步骤
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
<java.version>1.8</java.version>
|
||||
<maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
|
||||
<!-- 定义sa-token版本号 -->
|
||||
<sa-token-version>1.15.0.RELEASE</sa-token-version>
|
||||
<sa-token-version>1.21.0</sa-token-version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
@@ -39,7 +39,7 @@
|
||||
<dependency>
|
||||
<groupId>cn.dev33</groupId>
|
||||
<artifactId>sa-token-oauth2</artifactId>
|
||||
<version>1.15.0-alpha</version>
|
||||
<version>${sa-token-version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- sa-token整合redis (使用jackson序列化方式) -->
|
||||
|
||||
@@ -19,7 +19,7 @@ public class ServerAccController {
|
||||
public AjaxJson test(String username, String password) {
|
||||
System.out.println("------------------ 成功进入请求 ------------------");
|
||||
if("test".equals(username) && "test".equals(password)) {
|
||||
StpUtil.setLoginId(10001);
|
||||
StpUtil.login(10001);
|
||||
return AjaxJson.getSuccess();
|
||||
}
|
||||
return AjaxJson.getError();
|
||||
|
||||
@@ -7,7 +7,8 @@ import org.springframework.stereotype.Component;
|
||||
|
||||
import cn.dev33.satoken.oauth2.SaOAuth2Manager;
|
||||
import cn.dev33.satoken.oauth2.config.SaOAuth2Config;
|
||||
import cn.dev33.satoken.oauth2.logic.SaOAuth2Interface;
|
||||
import cn.dev33.satoken.oauth2.logic.SaOAuth2Template;
|
||||
import cn.dev33.satoken.oauth2.logic.SaOAuth2Util;
|
||||
|
||||
/**
|
||||
* 利用Spring完成自动装配
|
||||
@@ -24,7 +25,7 @@ public class SaOAuth2SpringAutowired {
|
||||
* @return 配置对象
|
||||
*/
|
||||
@Bean
|
||||
@ConfigurationProperties(prefix = "spring.sa-token.oauth2")
|
||||
@ConfigurationProperties(prefix = "sa-token.oauth2")
|
||||
public SaOAuth2Config getSaOAuth2Config() {
|
||||
return new SaOAuth2Config();
|
||||
}
|
||||
@@ -45,8 +46,8 @@ public class SaOAuth2SpringAutowired {
|
||||
* @param saOAuth2Interface OAuth2接口Bean
|
||||
*/
|
||||
@Autowired(required = false)
|
||||
public void setSaOAuth2Interface(SaOAuth2Interface saOAuth2Interface) {
|
||||
SaOAuth2Manager.setInterface(saOAuth2Interface);
|
||||
public void setSaOAuth2Interface(SaOAuth2Template saOAuth2Interface) {
|
||||
SaOAuth2Util.saOAuth2Template = saOAuth2Interface;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -5,14 +5,14 @@ import java.util.List;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import cn.dev33.satoken.oauth2.logic.SaOAuth2Interface;
|
||||
import cn.dev33.satoken.oauth2.logic.SaOAuth2Template;
|
||||
|
||||
/**
|
||||
* 使用oauth2.0 所必须的一些自定义实现
|
||||
* @author kong
|
||||
*/
|
||||
@Component
|
||||
public class SaOAuth2InterfaceImpl implements SaOAuth2Interface {
|
||||
public class SaOAuth2TemplateImpl extends SaOAuth2Template {
|
||||
|
||||
|
||||
/*
|
||||
@@ -1,18 +1,17 @@
|
||||
server:
|
||||
port: 8001
|
||||
|
||||
# sa-token配置
|
||||
sa-token:
|
||||
# token名称 (同时也是cookie名称)
|
||||
token-name: satoken-server
|
||||
|
||||
spring:
|
||||
# 静态文件路径映射
|
||||
resources:
|
||||
static-locations: classpath:/META-INF/resources/,classpath:/resources/, classpath:/static/, classpath:/public/
|
||||
# static-locations: file:E:\work\project-yun\sa-token\sa-token-demo-oauth2\sa-token-demo-oauth2-server\src\main\resources\static\
|
||||
|
||||
# sa-token配置
|
||||
sa-token:
|
||||
# token名称 (同时也是cookie名称)
|
||||
token-name: satoken-server
|
||||
|
||||
|
||||
# redis配置
|
||||
redis:
|
||||
# Redis数据库索引(默认为0)
|
||||
|
||||
Reference in New Issue
Block a user