OAuth2.0文档

This commit is contained in:
click33
2021-07-19 01:12:55 +08:00
parent 6d44299902
commit de7ccf05aa
22 changed files with 535 additions and 44 deletions

View File

@@ -110,7 +110,10 @@ public class SaTokenJwtUtil {
warn += "-------------------------------------";
System.err.println(warn);
}
// 提前调用一下方法,促使其属性初始化
StpUtil.getLoginType();
// 修改默认实现
StpUtil.stpLogic = new StpLogic("login") {

View File

@@ -3,9 +3,8 @@ package com.pj;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
* 启动OAuth2-Client端
* 启动:Sa-OAuth2 ClientServer
* @author kong
*/
@SpringBootApplication
@@ -16,7 +15,8 @@ public class SaOAuth2ClientApplication {
System.out.println("\nSa-Token-OAuth Client端启动成功\n\n" + str);
}
static String str = "首先在host文件 (C:\\WINDOWS\\system32\\drivers\\etc\\hosts) 添加以下内容: \r\n" +
static String str = "-------------------- Sa-Token-OAuth2 示例 --------------------\n\n" +
"首先在host文件 (C:\\windows\\system32\\drivers\\etc\\hosts) 添加以下内容: \r\n" +
" 127.0.0.1 sa-oauth-server.com \r\n" +
" 127.0.0.1 sa-oauth-client.com \r\n" +
"再从浏览器访问:\r\n" +

View File

@@ -4,7 +4,7 @@ import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
* 启动OAuth2-Server端
* 启动:Sa-OAuth2 Server端
* @author kong
*/
@SpringBootApplication

View File

@@ -28,7 +28,7 @@ public class SaOAuth2ServerController {
// 处理所有OAuth相关请求
@RequestMapping("/oauth2/*")
public Object request() {
System.out.println("--------------进入请求 ");
System.out.println("------- 进入请求: " + SaHolder.getRequest().getUrl());
return SaOAuth2Handle.serverRequest();
}

View File

@@ -21,7 +21,7 @@
<dependencies>
<!-- springboot依赖 -->
<!-- SpringBoot依赖 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
@@ -38,27 +38,27 @@
<version>${sa-token-version}</version>
</dependency>
<!-- sa-token整合redis (使用jdk默认序列化方式) -->
<!-- Sa-Token 整合 Redis (使用jdk默认序列化方式) -->
<!-- <dependency>
<groupId>cn.dev33</groupId>
<artifactId>sa-token-dao-redis</artifactId>
<version>${sa-token-version}</version>
</dependency> -->
<!-- sa-token整合redis (使用jackson序列化方式) -->
<!-- Sa-Token整合 Redis (使用jackson序列化方式) -->
<!-- <dependency>
<groupId>cn.dev33</groupId>
<artifactId>sa-token-dao-redis-jackson</artifactId>
<version>${sa-token-version}</version>
</dependency> -->
<!-- 提供redis连接池 -->
<!-- 提供Redis连接池 -->
<!-- <dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-pool2</artifactId>
</dependency> -->
<!-- sa-token整合SpringAOP实现注解鉴权 -->
<!-- Sa-Token整合SpringAOP实现注解鉴权 -->
<dependency>
<groupId>cn.dev33</groupId>
<artifactId>sa-token-spring-aop</artifactId>

View File

@@ -9,7 +9,6 @@ import org.springframework.web.bind.annotation.RestController;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.pj.satoken.at.StpUserUtil;
import com.pj.util.AjaxJson;
import com.pj.util.Ttime;
@@ -242,7 +241,6 @@ public class TestController {
@RequestMapping("test")
public AjaxJson test() {
System.out.println("进来了");
StpUserUtil.login(10001);
return AjaxJson.getSuccess();
}

View File

@@ -11,7 +11,7 @@ sa-token:
# token临时有效期 (指定时间内无操作就视为token过期) 单位: 秒
activity-timeout: -1
# 是否允许同一账号并发登录 (为true时允许一起登录, 为false时新登录挤掉旧登录)
is-concurrent: false
is-concurrent: true
# 在多人登录同一账号时是否共用一个token (为true时所有登录共用一个token, 为false时每次登录新建一个token)
is-share: true
# token风格