mirror of
https://gitee.com/yadong.zhang/JustAuth.git
synced 2025-12-06 16:58:24 +08:00
!31 修复企业微信的 redirect_uri 没有 urlEncode 问题
Merge pull request !31 from AlexChan/dev
This commit is contained in:
commit
afddf269e1
@ -5,6 +5,7 @@ import me.zhyd.oauth.config.AuthConfig;
|
|||||||
import me.zhyd.oauth.config.AuthDefaultSource;
|
import me.zhyd.oauth.config.AuthDefaultSource;
|
||||||
import me.zhyd.oauth.enums.scope.AuthWeChatEnterpriseWebScope;
|
import me.zhyd.oauth.enums.scope.AuthWeChatEnterpriseWebScope;
|
||||||
import me.zhyd.oauth.utils.AuthScopeUtils;
|
import me.zhyd.oauth.utils.AuthScopeUtils;
|
||||||
|
import me.zhyd.oauth.utils.GlobalAuthUtils;
|
||||||
import me.zhyd.oauth.utils.UrlBuilder;
|
import me.zhyd.oauth.utils.UrlBuilder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -28,7 +29,7 @@ public class AuthWeChatEnterpriseWebRequest extends AbstractAuthWeChatEnterprise
|
|||||||
public String authorize(String state) {
|
public String authorize(String state) {
|
||||||
return UrlBuilder.fromBaseUrl(source.authorize())
|
return UrlBuilder.fromBaseUrl(source.authorize())
|
||||||
.queryParam("appid", config.getClientId())
|
.queryParam("appid", config.getClientId())
|
||||||
.queryParam("redirect_uri", config.getRedirectUri())
|
.queryParam("redirect_uri", GlobalAuthUtils.urlEncode(config.getRedirectUri()))
|
||||||
.queryParam("response_type", "code")
|
.queryParam("response_type", "code")
|
||||||
.queryParam("scope", this.getScopes(",", false, AuthScopeUtils.getDefaultScopes(AuthWeChatEnterpriseWebScope.values())))
|
.queryParam("scope", this.getScopes(",", false, AuthScopeUtils.getDefaultScopes(AuthWeChatEnterpriseWebScope.values())))
|
||||||
.queryParam("state", getRealState(state).concat("#wechat_redirect"))
|
.queryParam("state", getRealState(state).concat("#wechat_redirect"))
|
||||||
|
|||||||
@ -0,0 +1,20 @@
|
|||||||
|
package me.zhyd.oauth.request;
|
||||||
|
|
||||||
|
import me.zhyd.oauth.config.AuthConfig;
|
||||||
|
import me.zhyd.oauth.utils.AuthStateUtils;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
public class AuthWeChatEnterpriseWebRequestTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void authorize() {
|
||||||
|
AuthRequest request = new AuthWeChatEnterpriseWebRequest(AuthConfig.builder()
|
||||||
|
.clientId("a")
|
||||||
|
.clientSecret("a")
|
||||||
|
.redirectUri("https://www.justauth.cn")
|
||||||
|
.build());
|
||||||
|
System.out.println(request.authorize(AuthStateUtils.createState()));
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user