mirror of
https://github.com/dromara/RuoYi-Vue-Plus.git
synced 2025-10-11 20:43:44 +08:00
优化第三方授权登录
This commit is contained in:
@@ -117,6 +117,12 @@
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.dromara</groupId>
|
||||
<artifactId>ruoyi-common-social</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- web服务 -->
|
||||
<dependency>
|
||||
<groupId>org.dromara</groupId>
|
||||
|
@@ -1,35 +1,26 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<groupId>org.dromara</groupId>
|
||||
<artifactId>ruoyi-common</artifactId>
|
||||
<version>${revision}</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>ruoyi-common-social</artifactId>
|
||||
|
||||
<description>
|
||||
ruoyi-common-auth 认证模块
|
||||
ruoyi-common-social 授权认证
|
||||
</description>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>me.zhyd.oauth</groupId>
|
||||
<artifactId>JustAuth</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-autoconfigure</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.dromara</groupId>
|
||||
<artifactId>ruoyi-common-redis</artifactId>
|
||||
|
@@ -17,7 +17,7 @@ import org.springframework.context.annotation.Bean;
|
||||
public class SocialConfig {
|
||||
|
||||
@Bean
|
||||
public AuthStateCache redis() {
|
||||
public AuthStateCache authStateCache() {
|
||||
return new AuthRedisStateCache();
|
||||
}
|
||||
|
||||
|
@@ -3,7 +3,7 @@ package org.dromara.common.social.config.properties;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class ConfigProperties {
|
||||
public class SocialLoginConfigProperties {
|
||||
|
||||
/**
|
||||
* 应用 ID
|
@@ -24,7 +24,7 @@ public class SocialProperties {
|
||||
/**
|
||||
* 授权类型
|
||||
*/
|
||||
private Map<String, ConfigProperties> type;
|
||||
private Map<String, SocialLoginConfigProperties> type;
|
||||
|
||||
/**
|
||||
* 授权过期时间
|
||||
|
@@ -12,21 +12,7 @@ import java.time.Duration;
|
||||
|
||||
public class AuthRedisStateCache implements AuthStateCache {
|
||||
|
||||
private final SocialProperties socialProperties;
|
||||
private final RedisTemplate<String, String> redisTemplate;
|
||||
|
||||
private ValueOperations<String, String> valueOperations;
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
valueOperations = redisTemplate.opsForValue();
|
||||
}
|
||||
|
||||
|
||||
public AuthRedisStateCache() {
|
||||
this.socialProperties = new SocialProperties();
|
||||
redisTemplate = new RedisTemplate<>();
|
||||
}
|
||||
private SocialProperties socialProperties;
|
||||
|
||||
/**
|
||||
* 存入缓存
|
||||
|
@@ -19,17 +19,17 @@ public class SocialUtils {
|
||||
AuthRequest authRequest = null;
|
||||
switch (source.toLowerCase()) {
|
||||
case "dingtalk" ->
|
||||
authRequest = new AuthDingTalkRequest(AuthConfig.builder().
|
||||
clientId(clientId).
|
||||
clientSecret(clientSecret)
|
||||
.redirectUri(redirectUri).
|
||||
build());
|
||||
authRequest = new AuthDingTalkRequest(AuthConfig.builder()
|
||||
.clientId(clientId)
|
||||
.clientSecret(clientSecret)
|
||||
.redirectUri(redirectUri)
|
||||
.build());
|
||||
case "baidu" ->
|
||||
authRequest = new AuthBaiduRequest(AuthConfig.builder().
|
||||
clientId(clientId).
|
||||
clientSecret(clientSecret)
|
||||
.redirectUri(redirectUri).
|
||||
build());
|
||||
authRequest = new AuthBaiduRequest(AuthConfig.builder()
|
||||
.clientId(clientId)
|
||||
.clientSecret(clientSecret)
|
||||
.redirectUri(redirectUri)
|
||||
.build());
|
||||
case "github" ->
|
||||
authRequest = new AuthGithubRequest(AuthConfig.builder().clientId(clientId).clientSecret(clientSecret)
|
||||
.redirectUri(redirectUri).build());
|
||||
|
Reference in New Issue
Block a user