基于@EnableOAuth2Sso实现单点登录

This commit is contained in:
2023-08-21 10:12:56 +08:00
parent c5f9146bac
commit c4256d46f9
11 changed files with 81 additions and 2 deletions

View File

@@ -18,6 +18,16 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-oauth2</artifactId>
<version>2.2.5.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>

View File

@@ -2,6 +2,7 @@ package com.test;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.security.oauth2.client.EnableOAuth2Sso;
/**
* ClassName: BorrowApplication
@@ -10,6 +11,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
* @author yovinchen
* @Create 2023/8/14 16:25
*/
@EnableOAuth2Sso
@SpringBootApplication
public class BorrowApplication {
public static void main(String[] args) {

View File

@@ -6,3 +6,16 @@ spring:
url: jdbc:mysql://43.143.164.194:3306/mac
username: mac
password: mactest
security:
oauth2:
client:
#不多说了
client-id: web
client-secret: 654321
#Token获取地址
access-token-uri: http://localhost:8500/sso/oauth/token
#验证页面地址
user-authorization-uri: http://localhost:8500/sso/oauth/authorize
resource:
#Token信息获取和校验地址
token-info-uri: http://localhost:8500/sso/oauth/check_token