mirror of
https://github.com/dromara/RuoYi-Vue-Plus.git
synced 2025-09-24 07:19:46 +08:00
优化第三方授权登录
This commit is contained in:
@ -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