mirror of
				https://github.com/dromara/RuoYi-Vue-Plus.git
				synced 2025-11-04 16:23:42 +08:00 
			
		
		
		
	@@ -200,7 +200,7 @@ justauth:
 | 
			
		||||
      redirect-uri: ${justauth.address}/social-callback?source=maxkey
 | 
			
		||||
    topiam:
 | 
			
		||||
      # topiam 服务器地址
 | 
			
		||||
      server-url: http://127.0.0.1:1989/api/v1/authorize/y0q************spq***********8ol
 | 
			
		||||
      server-url: http://127.0.0.1:1898/api/v1/authorize/y0q************spq***********8ol
 | 
			
		||||
      client-id: 449c4*********937************759
 | 
			
		||||
      client-secret: ac7***********1e0************28d
 | 
			
		||||
      redirect-uri: ${justauth.address}/social-callback?source=topiam
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,10 @@
 | 
			
		||||
package org.dromara.common.social.topiam;
 | 
			
		||||
 | 
			
		||||
import cn.hutool.core.codec.Base64;
 | 
			
		||||
import cn.hutool.core.lang.Dict;
 | 
			
		||||
import cn.hutool.core.util.StrUtil;
 | 
			
		||||
import cn.hutool.http.HttpRequest;
 | 
			
		||||
import cn.hutool.http.HttpResponse;
 | 
			
		||||
import com.xkcoding.http.support.HttpHeader;
 | 
			
		||||
import lombok.extern.slf4j.Slf4j;
 | 
			
		||||
import me.zhyd.oauth.cache.AuthStateCache;
 | 
			
		||||
@@ -70,6 +73,16 @@ public class AuthTopIamRequest extends AuthDefaultRequest {
 | 
			
		||||
            .build();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    protected String doPostAuthorizationCode(String code) {
 | 
			
		||||
        HttpRequest request = HttpRequest.post(source.accessToken())
 | 
			
		||||
            .header("Authorization", "Basic " + Base64.encode("%s:%s".formatted(config.getClientId(), config.getClientSecret())))
 | 
			
		||||
            .form("grant_type", "authorization_code")
 | 
			
		||||
            .form("code", code)
 | 
			
		||||
            .form("redirect_uri", config.getRedirectUri());
 | 
			
		||||
        HttpResponse response = request.execute();
 | 
			
		||||
        return response.body();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    protected String doGetUserInfo(AuthToken authToken) {
 | 
			
		||||
@@ -86,7 +99,7 @@ public class AuthTopIamRequest extends AuthDefaultRequest {
 | 
			
		||||
            .build();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static void checkResponse(Dict object) {
 | 
			
		||||
    private static void checkResponse(Dict object) {
 | 
			
		||||
        // oauth/token 验证异常
 | 
			
		||||
        if (object.containsKey("error")) {
 | 
			
		||||
            throw new AuthException(object.getStr("error_description"));
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user