From 0a2db34ad01a307bc9052a8d16f380430488b4ed Mon Sep 17 00:00:00 2001 From: luojielin <384184718@qq.com> Date: Mon, 29 Nov 2021 22:04:40 +0800 Subject: [PATCH] fix bugs --- lib/authentication/authentication_client.go | 37 +++++--- .../authentication_client_test.go | 90 +++++++++---------- lib/authentication/mfa_client_test.go | 22 ++--- lib/management/audit_log_management_client.go | 3 - lib/management/namespace_management_client.go | 5 -- lib/management/policies_management_client.go | 2 - ...ncipal_authentication_management_client.go | 3 - lib/management/user_management_client.go | 7 -- 8 files changed, 81 insertions(+), 88 deletions(-) diff --git a/lib/authentication/authentication_client.go b/lib/authentication/authentication_client.go index c289858..5f7c21e 100644 --- a/lib/authentication/authentication_client.go +++ b/lib/authentication/authentication_client.go @@ -29,7 +29,7 @@ type Client struct { Secret string Host string RedirectUri string - userPoolId string + UserPoolId string TokenEndPointAuthMethod constant.AuthMethodEnum ClientToken *string @@ -418,7 +418,7 @@ func (c *Client) SendHttpRequestManage(url string, method string, query string, token := c.ClientToken req.Header.Add("Authorization", "Bearer "+*token) } - req.Header.Add("x-authing-userpool-id", ""+c.userPoolId) + req.Header.Add("x-authing-userpool-id", ""+c.UserPoolId) req.Header.Add("x-authing-request-from", constant.SdkType) req.Header.Add("x-authing-sdk-version", constant.SdkVersion) req.Header.Add("x-authing-app-id", ""+constant.AppId) @@ -442,7 +442,7 @@ func QueryAccessToken(client *Client) (*model.AccessTokenRes, error) { } variables := map[string]interface{}{ - "userPoolId": client.userPoolId, + "userPoolId": client.UserPoolId, "secret": client.Secret, } @@ -461,7 +461,7 @@ func QueryAccessToken(client *Client) (*model.AccessTokenRes, error) { // 获取访问Token func GetAccessToken(client *Client) (string, error) { // 从缓存获取token - cacheToken, b := cacheutil.GetCache(constant.TokenCacheKeyPrefix + client.userPoolId) + cacheToken, b := cacheutil.GetCache(constant.TokenCacheKeyPrefix + client.UserPoolId) if b && cacheToken != nil { return cacheToken.(string), nil } @@ -469,7 +469,7 @@ func GetAccessToken(client *Client) (string, error) { var mutex sync.Mutex mutex.Lock() defer mutex.Unlock() - cacheToken, b = cacheutil.GetCache(constant.TokenCacheKeyPrefix + client.userPoolId) + cacheToken, b = cacheutil.GetCache(constant.TokenCacheKeyPrefix + client.UserPoolId) if b && cacheToken != nil { return cacheToken.(string), nil } @@ -478,7 +478,7 @@ func GetAccessToken(client *Client) (string, error) { return "", err } var expire = *(token.Exp) - time.Now().Unix() - 43200 - cacheutil.SetCache(constant.TokenCacheKeyPrefix+client.userPoolId, *token.AccessToken, time.Duration(expire*int64(time.Second))) + cacheutil.SetCache(constant.TokenCacheKeyPrefix+client.UserPoolId, *token.AccessToken, time.Duration(expire*int64(time.Second))) return *token.AccessToken, nil } @@ -512,7 +512,7 @@ func (c *Client) SendHttpRestRequest(url string, method string, token *string, v } req.Header.Add("Authorization", "Bearer "+*token) - req.Header.Add("x-authing-userpool-id", ""+c.userPoolId) + req.Header.Add("x-authing-userpool-id", ""+c.UserPoolId) req.Header.Add("x-authing-request-from", constant.SdkType) req.Header.Add("x-authing-sdk-version", constant.SdkVersion) req.Header.Add("x-authing-app-id", ""+constant.AppId) @@ -549,7 +549,7 @@ func (c *Client) SendHttpRestRequestNotToken(url string, method string, variable req.Header.Add("Content-Type", "application/json") } - req.Header.Add("x-authing-userpool-id", ""+c.userPoolId) + req.Header.Add("x-authing-userpool-id", ""+c.UserPoolId) req.Header.Add("x-authing-request-from", constant.SdkType) req.Header.Add("x-authing-sdk-version", constant.SdkVersion) req.Header.Add("x-authing-app-id", ""+constant.AppId) @@ -585,7 +585,7 @@ func (c *Client) GetCurrentUser(token *string) (*model.User, error) { } func (c *Client) getCurrentUser() (*model.User, error) { - k, e := cacheutil.GetCache(constant.UserCacheKeyPrefix + c.userPoolId) + k, e := cacheutil.GetCache(constant.UserCacheKeyPrefix + c.UserPoolId) if !e { return nil, errors.New("未登录") } @@ -1063,7 +1063,7 @@ func (c *Client) SendHttpRequestCustomTokenManage(url string, method string, tok req.Header.Add("Authorization", "Bearer "+*token) } - req.Header.Add("x-authing-userpool-id", ""+c.userPoolId) + req.Header.Add("x-authing-userpool-id", ""+c.UserPoolId) req.Header.Add("x-authing-request-from", constant.SdkType) req.Header.Add("x-authing-sdk-version", constant.SdkVersion) req.Header.Add("x-authing-app-id", ""+constant.AppId) @@ -1223,7 +1223,7 @@ func (c *Client) UnBindEmail() (*model.User, error) { // Logout // 退出登录 func (c *Client) Logout() (*model.CommonMessageAndCode, error) { - cacheToken, _ := cacheutil.GetCache(constant.TokenCacheKeyPrefix + c.userPoolId) + cacheToken, _ := cacheutil.GetCache(constant.TokenCacheKeyPrefix + c.UserPoolId) if cacheToken == nil { return nil, errors.New("Please login first") } @@ -1234,7 +1234,6 @@ func (c *Client) Logout() (*model.CommonMessageAndCode, error) { if err != nil { return nil, err } - log.Println(string(b)) resp := model.CommonMessageAndCode{} jsoniter.Unmarshal(b, &resp) if resp.Code != 200 { @@ -1244,6 +1243,20 @@ func (c *Client) Logout() (*model.CommonMessageAndCode, error) { return &resp, nil } +func (c *Client) LogoutByToken(token string) (*model.CommonMessageAndCode, error) { + url := fmt.Sprintf("%s/api/v2/logout?app_id=%s", c.Host, c.AppId) + b, err := c.SendHttpRestRequest(url, http.MethodGet, &token, nil) + if err != nil { + return nil, err + } + resp := model.CommonMessageAndCode{} + jsoniter.Unmarshal(b, &resp) + if resp.Code != 200 { + return nil, errors.New(resp.Message) + } + return &resp, nil +} + func (c *Client) ClearUser() { c.ClientUser = nil c.ClientToken = nil diff --git a/lib/authentication/authentication_client_test.go b/lib/authentication/authentication_client_test.go index 6b4d5e4..4f4fd42 100644 --- a/lib/authentication/authentication_client_test.go +++ b/lib/authentication/authentication_client_test.go @@ -135,7 +135,7 @@ func TestClient_RevokeToken(t *testing.T) { func TestClient_LoginByUserName(t *testing.T) { authenticationClient := NewClient("60a6f980dd9a9a7642da768a", "5cd4ea7b3603b792aea9a00da9e18f44") - authenticationClient.userPoolId = "60e043f8cd91b87d712b6365" + authenticationClient.UserPoolId = "60e043f8cd91b87d712b6365" authenticationClient.Secret = "158c7679333bc196b524d78d745813e5" req := model.LoginByUsernameInput{ Username: "luojielin", @@ -152,7 +152,7 @@ func TestClient_LoginByUserName(t *testing.T) { func TestClient_LoginByEmail(t *testing.T) { authenticationClient := NewClient("60a6f980dd9a9a7642da768a", "5cd4ea7b3603b792aea9a00da9e18f44") - authenticationClient.userPoolId = "60e043f8cd91b87d712b6365" + authenticationClient.UserPoolId = "60e043f8cd91b87d712b6365" authenticationClient.Secret = "158c7679333bc196b524d78d745813e5" req := model.LoginByEmailInput{ Email: "luojielin@authing.cn", @@ -169,7 +169,7 @@ func TestClient_LoginByEmail(t *testing.T) { func TestClient_LoginByPhonePassword(b *testing.T) { authenticationClient := NewClient("60a6f980dd9a9a7642da768a", "5cd4ea7b3603b792aea9a00da9e18f44") - authenticationClient.userPoolId = "60e043f8cd91b87d712b6365" + authenticationClient.UserPoolId = "60e043f8cd91b87d712b6365" authenticationClient.Secret = "158c7679333bc196b524d78d745813e5" req := model.LoginByPhonePasswordInput{ Phone: "18310641137", @@ -186,7 +186,7 @@ func TestClient_LoginByPhonePassword(b *testing.T) { /*func TestClient_LoginByPhoneCode(b *testing.T) { authenticationClient := NewClient("60a6f980dd9a9a7642da768a","5cd4ea7b3603b792aea9a00da9e18f44") - authenticationClient.userPoolId = "60e043f8cd91b87d712b6365" + authenticationClient.UserPoolId = "60e043f8cd91b87d712b6365" authenticationClient.Secret = "158c7679333bc196b524d78d745813e5" req := model.LoginByPhoneCodeInput{ Phone: "18310641137", @@ -202,7 +202,7 @@ func TestClient_LoginByPhonePassword(b *testing.T) { func TestClient_SendSmsCode(t *testing.T) { authenticationClient := NewClient("60a6f980dd9a9a7642da768a","5cd4ea7b3603b792aea9a00da9e18f44") - authenticationClient.userPoolId = "60e043f8cd91b87d712b6365" + authenticationClient.UserPoolId = "60e043f8cd91b87d712b6365" authenticationClient.Secret = "158c7679333bc196b524d78d745813e5" resp,err := authenticationClient.SendSmsCode("15566416161") log.Println(resp,err) @@ -210,7 +210,7 @@ func TestClient_SendSmsCode(t *testing.T) { func TestClient_GetCurrentUser(t *testing.T) { authenticationClient := NewClient(AppId, Secret) - authenticationClient.userPoolId = UserPool + authenticationClient.UserPoolId = UserPool req := &model.LoginByPhoneCodeInput{ Code: "3289", @@ -223,7 +223,7 @@ func TestClient_GetCurrentUser(t *testing.T) { func TestClient_RegisterByEmail(t *testing.T) { authenticationClient := NewClient(AppId, Secret) - authenticationClient.userPoolId = UserPool + authenticationClient.UserPoolId = UserPool data, e := jsoniter.Marshal([]model.KeyValuePair{{Key: "custom", Value: "qq"}}) log.Println(data, e) p := string(data) @@ -242,7 +242,7 @@ func TestClient_RegisterByEmail(t *testing.T) { func TestClient_RegisterByUsername(t *testing.T) { authenticationClient := NewClient(AppId, Secret) - authenticationClient.userPoolId = UserPool + authenticationClient.UserPoolId = UserPool data, e := jsoniter.Marshal([]model.KeyValuePair{{Key: "custom", Value: "qq"}}) log.Println(data, e) p := string(data) @@ -257,7 +257,7 @@ func TestClient_RegisterByUsername(t *testing.T) { func TestClient_RegisterByPhoneCode(t *testing.T) { authenticationClient := NewClient(AppId, Secret) - authenticationClient.userPoolId = UserPool + authenticationClient.UserPoolId = UserPool data, e := jsoniter.Marshal([]model.KeyValuePair{{Key: "custom", Value: "qq"}}) log.Println(data, e) p := string(data) @@ -278,7 +278,7 @@ func TestClient_RegisterByPhoneCode(t *testing.T) { func TestClient_CheckPasswordStrength(t *testing.T) { authenticationClient := NewClient(AppId, Secret) - authenticationClient.userPoolId = UserPool + authenticationClient.UserPoolId = UserPool data, e := jsoniter.Marshal([]model.KeyValuePair{{Key: "custom", Value: "qq"}}) log.Println(data, e) @@ -288,7 +288,7 @@ func TestClient_CheckPasswordStrength(t *testing.T) { func TestClient_SendSmsCode(t *testing.T) { authenticationClient := NewClient(AppId, Secret) - authenticationClient.userPoolId = UserPool + authenticationClient.UserPoolId = UserPool resp, err := authenticationClient.SendSmsCode("18515006338") log.Println(resp, err) @@ -296,7 +296,7 @@ func TestClient_SendSmsCode(t *testing.T) { func TestClient_LoginByPhoneCode(t *testing.T) { authenticationClient := NewClient(AppId, Secret) - authenticationClient.userPoolId = UserPool + authenticationClient.UserPoolId = UserPool req := &model.LoginByPhoneCodeInput{ Code: "3289", Phone: "18910471835", @@ -307,7 +307,7 @@ func TestClient_LoginByPhoneCode(t *testing.T) { func TestClient_CheckLoginStatus(t *testing.T) { authenticationClient := NewClient(AppId, Secret) - authenticationClient.userPoolId = UserPool + authenticationClient.UserPoolId = UserPool reginter := &model.RegisterByUsernameInput{ Username: "testGoSDK", Password: "123456789", @@ -326,7 +326,7 @@ func TestClient_CheckLoginStatus(t *testing.T) { func TestClient_SendEmail(t *testing.T) { authenticationClient := NewClient(AppId, Secret) - authenticationClient.userPoolId = UserPool + authenticationClient.UserPoolId = UserPool resp, err := authenticationClient.SendEmail(" mail@qq.com", model.EnumEmailSceneChangeEmail) log.Println(resp, err) @@ -334,7 +334,7 @@ func TestClient_SendEmail(t *testing.T) { func TestClient_UpdateProfile(t *testing.T) { authenticationClient := NewClient("6139c4d24e78a4d706b7545b", Secret) - authenticationClient.userPoolId = UserPool + authenticationClient.UserPoolId = UserPool req := &model.LoginByUsernameInput{ Username: "updateProfile", @@ -352,7 +352,7 @@ func TestClient_UpdateProfile(t *testing.T) { func TestClient_UpdatePassword(t *testing.T) { authenticationClient := NewClient(AppId, Secret) - authenticationClient.userPoolId = UserPool + authenticationClient.UserPoolId = UserPool req := &model.LoginByUsernameInput{ Username: "goSdkTestUpdateProfile", Password: "654321", @@ -370,7 +370,7 @@ func TestClient_UpdatePassword(t *testing.T) { func TestClient_UpdatePhone(t *testing.T) { authenticationClient := NewClient(AppId, Secret) - authenticationClient.userPoolId = UserPool + authenticationClient.UserPoolId = UserPool req := &model.LoginByUsernameInput{ Username: "goSdkTestUpdateProfile", Password: "654321", @@ -385,7 +385,7 @@ func TestClient_UpdatePhone(t *testing.T) { func TestClient_UpdateEmail(t *testing.T) { authenticationClient := NewClient(AppId, Secret) - authenticationClient.userPoolId = UserPool + authenticationClient.UserPoolId = UserPool req := &model.LoginByUsernameInput{ Username: "goSdkTestUpdateProfile", Password: "654321", @@ -400,7 +400,7 @@ func TestClient_UpdateEmail(t *testing.T) { func TestClient_RefreshToken(t *testing.T) { authenticationClient := NewClient(AppId, Secret) - authenticationClient.userPoolId = UserPool + authenticationClient.UserPoolId = UserPool req := &model.LoginByUsernameInput{ Username: "goSdkTestUpdateProfile", Password: "654321", @@ -418,7 +418,7 @@ func TestClient_RefreshToken(t *testing.T) { func TestClient_LinkAccount(t *testing.T) { authenticationClient := NewClient(AppId, Secret) - authenticationClient.userPoolId = UserPool + authenticationClient.UserPoolId = UserPool req := &model.LoginByUsernameInput{ Username: "goSdkTestUpdateProfile", Password: "654321", @@ -434,7 +434,7 @@ func TestClient_LinkAccount(t *testing.T) { func TestClient_UnLinkAccount(t *testing.T) { authenticationClient := NewClient(AppId, Secret) - authenticationClient.userPoolId = UserPool + authenticationClient.UserPoolId = UserPool req := &model.LoginByUsernameInput{ Username: "goSdkTestUpdateProfile", Password: "654321", @@ -450,7 +450,7 @@ func TestClient_UnLinkAccount(t *testing.T) { func TestClient_BindPhone(t *testing.T) { authenticationClient := NewClient(AppId, Secret) - authenticationClient.userPoolId = UserPool + authenticationClient.UserPoolId = UserPool req := &model.LoginByUsernameInput{ Username: "18515006338", Password: "123456", @@ -462,14 +462,14 @@ func TestClient_BindPhone(t *testing.T) { } func TestClient_SendSmsCode2(t *testing.T) { authenticationClient := NewClient(AppId, Secret) - authenticationClient.userPoolId = UserPool + authenticationClient.UserPoolId = UserPool d, e := authenticationClient.SendSmsCode("18515006338") log.Println(d, e) } func TestClient_UnBindPhone(t *testing.T) { authenticationClient := NewClient(AppId, Secret) - authenticationClient.userPoolId = UserPool + authenticationClient.UserPoolId = UserPool req := &model.LoginByUsernameInput{ Username: "18515006338", Password: "123456", @@ -482,7 +482,7 @@ func TestClient_UnBindPhone(t *testing.T) { func TestClient_BindEmail(t *testing.T) { authenticationClient := NewClient(AppId, Secret) - authenticationClient.userPoolId = UserPool + authenticationClient.UserPoolId = UserPool req := &model.LoginByUsernameInput{ Username: "18515006338", Password: "123456", @@ -495,7 +495,7 @@ func TestClient_BindEmail(t *testing.T) { func TestClient_UnBindEmail(t *testing.T) { authenticationClient := NewClient(AppId, Secret) - authenticationClient.userPoolId = UserPool + authenticationClient.UserPoolId = UserPool req := &model.LoginByUsernameInput{ Username: "18515006338", Password: "123456", @@ -508,7 +508,7 @@ func TestClient_UnBindEmail(t *testing.T) { func TestClient_Logout(t *testing.T) { authenticationClient := NewClient(AppId, Secret) - authenticationClient.userPoolId = UserPool + authenticationClient.UserPoolId = UserPool req := &model.LoginByUsernameInput{ Username: "18515006338", Password: "123456", @@ -521,7 +521,7 @@ func TestClient_Logout(t *testing.T) { func TestClient_ListUdv(t *testing.T) { authenticationClient := NewClient(AppId, Secret) - authenticationClient.userPoolId = UserPool + authenticationClient.UserPoolId = UserPool req := &model.LoginByUsernameInput{ Username: "18515006338", Password: "123456", @@ -534,7 +534,7 @@ func TestClient_ListUdv(t *testing.T) { func TestClient_SetUdv(t *testing.T) { authenticationClient := NewClient(AppId, Secret) - authenticationClient.userPoolId = UserPool + authenticationClient.UserPoolId = UserPool req := &model.LoginByUsernameInput{ Username: "18515006338", Password: "123456", @@ -549,7 +549,7 @@ func TestClient_SetUdv(t *testing.T) { func TestClient_RemoveUdv(t *testing.T) { authenticationClient := NewClient(AppId, Secret) - authenticationClient.userPoolId = UserPool + authenticationClient.UserPoolId = UserPool req := &model.LoginByUsernameInput{ Username: "18515006338", Password: "123456", @@ -562,7 +562,7 @@ func TestClient_RemoveUdv(t *testing.T) { func TestClient_ListOrg(t *testing.T) { authenticationClient := NewClient(AppId, Secret) - authenticationClient.userPoolId = UserPool + authenticationClient.UserPoolId = UserPool req := &model.LoginByUsernameInput{ Username: "18515006338", Password: "123456", @@ -575,21 +575,21 @@ func TestClient_ListOrg(t *testing.T) { func TestClient_LoginByLdap(t *testing.T) { authenticationClient := NewClient(AppId, Secret) - authenticationClient.userPoolId = UserPool + authenticationClient.UserPoolId = UserPool resp, err := authenticationClient.LoginByLdap("18515006338", "123456") log.Println(resp, err) } func TestClient_LoginByAd(t *testing.T) { authenticationClient := NewClient(AppId, Secret) - authenticationClient.userPoolId = UserPool + authenticationClient.UserPoolId = UserPool resp, err := authenticationClient.LoginByAd("18515006338", "123456") log.Println(resp, err) } func TestClient_GetSecurityLevel(t *testing.T) { authenticationClient := NewClient(AppId, Secret) - authenticationClient.userPoolId = UserPool + authenticationClient.UserPoolId = UserPool req := &model.LoginByUsernameInput{ Username: "18515006338", Password: "123456", @@ -601,7 +601,7 @@ func TestClient_GetSecurityLevel(t *testing.T) { func TestClient_ListAuthorizedResources(t *testing.T) { authenticationClient := NewClient(AppId, Secret) - authenticationClient.userPoolId = UserPool + authenticationClient.UserPoolId = UserPool req := &model.LoginByUsernameInput{ Username: "18515006338", Password: "123456", @@ -613,7 +613,7 @@ func TestClient_ListAuthorizedResources(t *testing.T) { func TestClient_BuildAuthorizeUrlByOauth(t *testing.T) { authenticationClient := NewClient(AppId, Secret) - authenticationClient.userPoolId = UserPool + authenticationClient.UserPoolId = UserPool authenticationClient.Protocol = constant.OAUTH resp, ee := authenticationClient.BuildAuthorizeUrlByOauth("email", "qq", "ww", "cc") log.Println(resp, ee) @@ -621,7 +621,7 @@ func TestClient_BuildAuthorizeUrlByOauth(t *testing.T) { func TestClient_ValidateTicketV1(t *testing.T) { authenticationClient := NewClient(AppId, Secret) - authenticationClient.userPoolId = UserPool + authenticationClient.UserPoolId = UserPool authenticationClient.Protocol = constant.OAUTH resp, ee := authenticationClient.ValidateTicketV1("email", "qq") log.Println(resp, ee) @@ -629,7 +629,7 @@ func TestClient_ValidateTicketV1(t *testing.T) { func TestClient_ListRole(t *testing.T) { authenticationClient := NewClient(AppId, Secret) - authenticationClient.userPoolId = UserPool + authenticationClient.UserPoolId = UserPool req := &model.LoginByUsernameInput{ Username: "18515006338", Password: "123456", @@ -640,7 +640,7 @@ func TestClient_ListRole(t *testing.T) { } func TestClient_HasRole(t *testing.T) { authenticationClient := NewClient(AppId, Secret) - authenticationClient.userPoolId = UserPool + authenticationClient.UserPoolId = UserPool req := &model.LoginByUsernameInput{ Username: "18515006338", Password: "123456", @@ -651,7 +651,7 @@ func TestClient_HasRole(t *testing.T) { } func TestClient_ListApplications(t *testing.T) { authenticationClient := NewClient(AppId, Secret) - authenticationClient.userPoolId = UserPool + authenticationClient.UserPoolId = UserPool req := &model.LoginByUsernameInput{ Username: "18515006338", Password: "123456", @@ -663,7 +663,7 @@ func TestClient_ListApplications(t *testing.T) { func TestClient_GetCodeChallengeDigest(t *testing.T) { authenticationClient := NewClient(AppId, Secret) - authenticationClient.userPoolId = UserPool + authenticationClient.UserPoolId = UserPool resp, err := authenticationClient.GetCodeChallengeDigest("wpaiscposrovkquicztfmftripjocybgmphyqtucmoz", constant.S256) @@ -672,7 +672,7 @@ func TestClient_GetCodeChallengeDigest(t *testing.T) { func TestClient_LoginBySubAccount(t *testing.T) { authenticationClient := NewClient(AppId, Secret) - authenticationClient.userPoolId = UserPool + authenticationClient.UserPoolId = UserPool req := &model.LoginBySubAccountRequest{ Account: "123456789", Password: "8558781", @@ -684,7 +684,7 @@ func TestClient_LoginBySubAccount(t *testing.T) { func TestClient_ListDepartments(t *testing.T) { authenticationClient := NewClient(AppId, Secret) - authenticationClient.userPoolId = UserPool + authenticationClient.UserPoolId = UserPool req := &model.LoginByUsernameInput{ Username: "18515006338", Password: "123456", @@ -696,7 +696,7 @@ func TestClient_ListDepartments(t *testing.T) { func TestClient_IsUserExists(t *testing.T) { authenticationClient := NewClient(AppId, Secret) - authenticationClient.userPoolId = UserPool + authenticationClient.UserPoolId = UserPool req := &model.LoginByUsernameInput{ Username: "18515006338", Password: "123456", @@ -711,7 +711,7 @@ func TestClient_IsUserExists(t *testing.T) { func TestClient_ValidateTicketV2(t *testing.T) { authenticationClient := NewClient(AppId, Secret) - authenticationClient.userPoolId = UserPool + authenticationClient.UserPoolId = UserPool resp, err := authenticationClient.ValidateTicketV2("ss", "ss", constant.XML) log.Println(resp, err) diff --git a/lib/authentication/mfa_client_test.go b/lib/authentication/mfa_client_test.go index 7f80cc3..d79f124 100644 --- a/lib/authentication/mfa_client_test.go +++ b/lib/authentication/mfa_client_test.go @@ -9,7 +9,7 @@ import ( func TestClient_GetMfaAuthenticators(t *testing.T) { authenticationClient := NewClient(AppId, Secret) - authenticationClient.userPoolId = UserPool + authenticationClient.UserPoolId = UserPool loginReq := model.LoginByEmailInput{ Email: "fptvmzqyxn@authing.cn", Password: "12345678", @@ -29,7 +29,7 @@ func TestClient_GetMfaAuthenticators(t *testing.T) { func TestClient_AssociateMfaAuthenticator(t *testing.T) { authenticationClient := NewClient(AppId, Secret) - authenticationClient.userPoolId = UserPool + authenticationClient.UserPoolId = UserPool loginReq := model.LoginByEmailInput{ Email: "fptvmzqyxn@authing.cn", Password: "12345678", @@ -48,7 +48,7 @@ func TestClient_AssociateMfaAuthenticator(t *testing.T) { func TestClient_DeleteMfaAuthenticator(t *testing.T) { authenticationClient := NewClient(AppId, Secret) - authenticationClient.userPoolId = UserPool + authenticationClient.UserPoolId = UserPool resp, err := authenticationClient.DeleteMfaAuthenticator() if err != nil { fmt.Println(err) @@ -59,7 +59,7 @@ func TestClient_DeleteMfaAuthenticator(t *testing.T) { func TestClient_ConfirmAssociateMfaAuthenticator(t *testing.T) { authenticationClient := NewClient(AppId, Secret) - authenticationClient.userPoolId = UserPool + authenticationClient.UserPoolId = UserPool //loginReq:= model.LoginByEmailInput{ // Email: "fptvmzqyxn@authing.cn", // Password: "12345678", @@ -80,7 +80,7 @@ func TestClient_ConfirmAssociateMfaAuthenticator(t *testing.T) { func TestClient_VerifyTotpMfa(t *testing.T) { authenticationClient := NewClient(AppId, Secret) - authenticationClient.userPoolId = UserPool + authenticationClient.UserPoolId = UserPool mfaToken := "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkYXRhIjp7InVzZXJQb29sSWQiOiI2MGMxN2IzZDcyYjkyNTA5N2E3MzhkODYiLCJ1c2VySWQiOiI2MTc2NWYxMDI5MThhOGZjNjUyNDU2NDAiLCJhcm4iOiJhcm46Y246YXV0aGluZzo2MGMxN2IzZDcyYjkyNTA5N2E3MzhkODY6dXNlcjo2MTc2NWYxMDI5MThhOGZjNjUyNDU2NDAiLCJzdGFnZSI6MX0sImlhdCI6MTYzNTE0OTQ2MiwiZXhwIjoxNjM1MTQ5ODIyfQ.2DbmVf1-JQeiRMpZBk-3y-uPIN15FL-ranE4UlMKMoM" resp, err := authenticationClient.VerifyTotpMfa("q", mfaToken) @@ -93,7 +93,7 @@ func TestClient_VerifyTotpMfa(t *testing.T) { func TestClient_VerifyAppSmsMfa(t *testing.T) { authenticationClient := NewClient(AppId, Secret) - authenticationClient.userPoolId = UserPool + authenticationClient.UserPoolId = UserPool loginReq := model.LoginByEmailInput{ Email: "gosdk@mail.com", Password: "123456789", @@ -110,7 +110,7 @@ func TestClient_VerifyAppSmsMfa(t *testing.T) { func TestClient_VerifyAppEmailMfa(t *testing.T) { authenticationClient := NewClient(AppId, Secret) - authenticationClient.userPoolId = UserPool + authenticationClient.UserPoolId = UserPool loginReq := model.LoginByEmailInput{ Email: "gosdk@mail.com", Password: "123456789", @@ -129,7 +129,7 @@ func TestClient_VerifyAppEmailMfa(t *testing.T) { func TestClient_PhoneOrEmailBindable(t *testing.T) { authenticationClient := NewClient(AppId, Secret) - authenticationClient.userPoolId = UserPool + authenticationClient.UserPoolId = UserPool mfaToken := "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkYXRhIjp7InVzZXJQb29sSWQiOiI2MGMxN2IzZDcyYjkyNTA5N2E3MzhkODYiLCJ1c2VySWQiOiI2MTc2NWYxMDI5MThhOGZjNjUyNDU2NDAiLCJhcm4iOiJhcm46Y246YXV0aGluZzo2MGMxN2IzZDcyYjkyNTA5N2E3MzhkODY6dXNlcjo2MTc2NWYxMDI5MThhOGZjNjUyNDU2NDAiLCJzdGFnZSI6MX0sImlhdCI6MTYzNTE0OTQ2MiwiZXhwIjoxNjM1MTQ5ODIyfQ.2DbmVf1-JQeiRMpZBk-3y-uPIN15FL-ranE4UlMKMoM" email := "gosdk@mail.com" resp, err := authenticationClient.PhoneOrEmailBindable(&email, nil, mfaToken) @@ -142,7 +142,7 @@ func TestClient_PhoneOrEmailBindable(t *testing.T) { func TestClient_VerifyFaceMfa(t *testing.T) { authenticationClient := NewClient(AppId, Secret) - authenticationClient.userPoolId = UserPool + authenticationClient.UserPoolId = UserPool mfaToken := "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkYXRhIjp7InVzZXJQb29sSWQiOiI2MGMxN2IzZDcyYjkyNTA5N2E3MzhkODYiLCJ1c2VySWQiOiI2MTc2NWYxMDI5MThhOGZjNjUyNDU2NDAiLCJhcm4iOiJhcm46Y246YXV0aGluZzo2MGMxN2IzZDcyYjkyNTA5N2E3MzhkODY6dXNlcjo2MTc2NWYxMDI5MThhOGZjNjUyNDU2NDAiLCJzdGFnZSI6MX0sImlhdCI6MTYzNTE0OTQ2MiwiZXhwIjoxNjM1MTQ5ODIyfQ.2DbmVf1-JQeiRMpZBk-3y-uPIN15FL-ranE4UlMKMoM" @@ -156,7 +156,7 @@ func TestClient_VerifyFaceMfa(t *testing.T) { func TestClient_AssociateFaceByUrl(t *testing.T) { authenticationClient := NewClient(AppId, Secret) - authenticationClient.userPoolId = UserPool + authenticationClient.UserPoolId = UserPool mfaToken := "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkYXRhIjp7InVzZXJQb29sSWQiOiI2MGMxN2IzZDcyYjkyNTA5N2E3MzhkODYiLCJ1c2VySWQiOiI2MTc2NWYxMDI5MThhOGZjNjUyNDU2NDAiLCJhcm4iOiJhcm46Y246YXV0aGluZzo2MGMxN2IzZDcyYjkyNTA5N2E3MzhkODY6dXNlcjo2MTc2NWYxMDI5MThhOGZjNjUyNDU2NDAiLCJzdGFnZSI6MX0sImlhdCI6MTYzNTE0OTQ2MiwiZXhwIjoxNjM1MTQ5ODIyfQ.2DbmVf1-JQeiRMpZBk-3y-uPIN15FL-ranE4UlMKMoM" @@ -170,7 +170,7 @@ func TestClient_AssociateFaceByUrl(t *testing.T) { func TestClient_VerifyTotpRecoveryCode(t *testing.T) { authenticationClient := NewClient(AppId, Secret) - authenticationClient.userPoolId = UserPool + authenticationClient.UserPoolId = UserPool mfaToken := "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkYXRhIjp7InVzZXJQb29sSWQiOiI2MGMxN2IzZDcyYjkyNTA5N2E3MzhkODYiLCJ1c2VySWQiOiI2MTc2NWYxMDI5MThhOGZjNjUyNDU2NDAiLCJhcm4iOiJhcm46Y246YXV0aGluZzo2MGMxN2IzZDcyYjkyNTA5N2E3MzhkODY6dXNlcjo2MTc2NWYxMDI5MThhOGZjNjUyNDU2NDAiLCJzdGFnZSI6MX0sImlhdCI6MTYzNTE0OTQ2MiwiZXhwIjoxNjM1MTQ5ODIyfQ.2DbmVf1-JQeiRMpZBk-3y-uPIN15FL-ranE4UlMKMoM" diff --git a/lib/management/audit_log_management_client.go b/lib/management/audit_log_management_client.go index 9019f6f..8204325 100644 --- a/lib/management/audit_log_management_client.go +++ b/lib/management/audit_log_management_client.go @@ -5,7 +5,6 @@ import ( "fmt" "github.com/Authing/authing-go-sdk/lib/model" jsoniter "github.com/json-iterator/go" - "log" "net/http" ) @@ -31,7 +30,6 @@ func (c *Client) ListAuditLogs(req *model.ListAuditLogsRequest) (*struct { if err != nil { return nil, err } - log.Println(string(b)) resp := &struct { Message string `json:"message"` Code int64 `json:"code"` @@ -69,7 +67,6 @@ func (c *Client) ListUserAction(req *model.ListUserActionRequest) (*struct { if err != nil { return nil, err } - log.Println(string(b)) resp := &struct { Message string `json:"message"` Code int64 `json:"code"` diff --git a/lib/management/namespace_management_client.go b/lib/management/namespace_management_client.go index 7f9ff0b..8f15ff1 100644 --- a/lib/management/namespace_management_client.go +++ b/lib/management/namespace_management_client.go @@ -6,7 +6,6 @@ import ( "fmt" "github.com/Authing/authing-go-sdk/lib/model" jsoniter "github.com/json-iterator/go" - "log" "net/http" ) @@ -21,7 +20,6 @@ func (c *Client) CreateNamespace(request *model.EditNamespaceRequest) (*model.Na if err != nil { return nil, err } - log.Println(string(b)) resp := &struct { Message string `json:"message"` Code int64 `json:"code"` @@ -47,7 +45,6 @@ func (c *Client) UpdateNamespace(id string, request *model.EditNamespaceRequest) if err != nil { return nil, err } - log.Println(string(b)) resp := &struct { Message string `json:"message"` Code int64 `json:"code"` @@ -69,7 +66,6 @@ func (c *Client) DeleteNamespace(id string) (*string, error) { if err != nil { return nil, err } - log.Println(string(b)) resp := &struct { Message string `json:"message"` Code int64 `json:"code"` @@ -93,7 +89,6 @@ func (c *Client) ListNamespace(page, limit int) (*struct { if err != nil { return nil, err } - log.Println(string(b)) resp := &struct { Message string `json:"message"` Code int64 `json:"code"` diff --git a/lib/management/policies_management_client.go b/lib/management/policies_management_client.go index 790112e..14efcd8 100644 --- a/lib/management/policies_management_client.go +++ b/lib/management/policies_management_client.go @@ -20,7 +20,6 @@ func (c *Client) CreatePolicy(req *model.PolicyRequest) (*model.CreatePolicyResp if err != nil { return nil, err } - log.Println(string(b)) var response = &struct { Data struct { CreatePolicy model.CreatePolicyResponse `json:"createPolicy"` @@ -44,7 +43,6 @@ func (c *Client) ListPolicy(page, limit int) (*model.PaginatedPolicies, error) { if err != nil { return nil, err } - log.Println(string(b)) var response = &struct { Data struct { Policies model.PaginatedPolicies `json:"policies"` diff --git a/lib/management/principal_authentication_management_client.go b/lib/management/principal_authentication_management_client.go index e5c659a..8b9d729 100644 --- a/lib/management/principal_authentication_management_client.go +++ b/lib/management/principal_authentication_management_client.go @@ -5,7 +5,6 @@ import ( "fmt" "github.com/Authing/authing-go-sdk/lib/model" jsoniter "github.com/json-iterator/go" - "log" "net/http" ) @@ -22,7 +21,6 @@ func (c *Client) PrincipalAuthDetail(userId string) (*struct { if err != nil { return nil, err } - log.Println(string(b)) resp := &struct { Message string `json:"message"` Code int64 `json:"code"` @@ -50,7 +48,6 @@ func (c *Client) PrincipalAuthenticate(userId string, req *model.PrincipalAuthen if err != nil { return nil, err } - log.Println(string(b)) resp := &struct { Message string `json:"message"` Code int64 `json:"code"` diff --git a/lib/management/user_management_client.go b/lib/management/user_management_client.go index e8f3efd..6fdc394 100644 --- a/lib/management/user_management_client.go +++ b/lib/management/user_management_client.go @@ -39,7 +39,6 @@ func (c *Client) GetUserList(request model.QueryListRequest) (*model.PaginatedUs if err != nil { return nil, err } - log.Println(string(b)) result := model.ListUserResponse{} err = json.Unmarshal(b, &result) if err != nil { @@ -58,7 +57,6 @@ func (c *Client) GetUserDepartments(request model.GetUserDepartmentsRequest) (*m if err != nil { return nil, err } - log.Println(string(b)) result := model.GetUserDepartmentsResponse{} err = json.Unmarshal(b, &result) if err != nil { @@ -103,7 +101,6 @@ func (c *Client) CreateUser(request model.CreateUserRequest) (*model.User, error if err != nil { return nil, err } - log.Println(string(b)) var response = &struct { Data struct { CreateUser model.User `json:"createUser"` @@ -131,7 +128,6 @@ func (c *Client) UpdateUser(id string, updateInfo model.UpdateUserInput) (*model if err != nil { return nil, err } - log.Println(string(b)) var response = &struct { Data struct { UpdateUser model.User `json:"updateUser"` @@ -156,7 +152,6 @@ func (c *Client) DeleteUser(id string) (*model.CommonMessageAndCode, error) { if err != nil { return nil, err } - log.Println(string(b)) var response = &struct { Data struct { DeleteUser model.CommonMessageAndCode `json:"deleteUser"` @@ -179,7 +174,6 @@ func (c *Client) BatchDeleteUser(ids []string) (*model.CommonMessageAndCode, err if err != nil { return nil, err } - log.Println(string(b)) var response = &struct { Data struct { DeleteUsers model.CommonMessageAndCode `json:"deleteUsers"` @@ -208,7 +202,6 @@ func (c *Client) BatchGetUser(ids []string, queryField string, withCustomData bo if err != nil { return nil, err } - log.Println(string(b)) var response = &struct { Data struct { BatchGetUsers []model.User `json:"userBatch"`