-
Notifications
You must be signed in to change notification settings - Fork 3
/
get_credential_type.go
101 lines (93 loc) · 3.6 KB
/
get_credential_type.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
package bingauth
import (
"bytes"
"encoding/json"
"fmt"
)
type getCredentialTypeReq struct {
CheckPhones bool `json:"checkPhones"`
Country string `json:"country"`
FederationFlags int `json:"federationFlags"`
FlowToken string `json:"flowToken"`
Forceotclogin bool `json:"forceotclogin"`
IsCookieBannerShown bool `json:"isCookieBannerShown"`
IsExternalFederationDisallowed bool `json:"isExternalFederationDisallowed"`
IsFederationDisabled bool `json:"isFederationDisabled"`
IsFidoSupported bool `json:"isFidoSupported"`
IsOtherIdpSupported bool `json:"isOtherIdpSupported"`
IsRemoteConnectSupported bool `json:"isRemoteConnectSupported"`
IsRemoteNGCSupported bool `json:"isRemoteNGCSupported"`
IsSignup bool `json:"isSignup"`
OriginalRequest string `json:"originalRequest"`
Otclogindisallowed bool `json:"otclogindisallowed"`
Uaid string `json:"uaid"`
Username string `json:"username"`
}
type getCredentialTypeResp struct {
AliasDisabledForLogin bool `json:"AliasDisabledForLogin"`
Credentials struct {
CobasiApp bool `json:"CobasiApp"`
HasFido int `json:"HasFido"`
HasGitHubFed int `json:"HasGitHubFed"`
HasGoogleFed int `json:"HasGoogleFed"`
HasLinkedInFed int `json:"HasLinkedInFed"`
HasPassword int `json:"HasPassword"`
HasPhone int `json:"HasPhone"`
HasRemoteNGC int `json:"HasRemoteNGC"`
OTCNotAutoSent int `json:"OTCNotAutoSent"`
PrefCredential int `json:"PrefCredential"`
OtcLoginEligibleProofs []struct {
Data string `json:"data"`
} `json:"OtcLoginEligibleProofs"`
RemoteNgcParams struct {
SessionIdentifier string `json:"SessionIdentifier"`
Entropy string `json:"Entropy"`
} `json:"RemoteNgcParams"`
} `json:"Credentials"`
Display string `json:"Display"`
IfExistsResult int `json:"IfExistsResult"`
Location string `json:"Location"`
Username string `json:"Username"`
}
func (a *AuthStruct) getCredentialType() (err error) {
reqBody := getCredentialTypeReq{
CheckPhones: false,
Country: "",
FederationFlags: 3,
FlowToken: a.FlowToken,
Forceotclogin: false,
IsCookieBannerShown: false,
IsExternalFederationDisallowed: false,
IsFederationDisabled: false,
IsFidoSupported: false,
IsOtherIdpSupported: true,
IsRemoteConnectSupported: false,
IsRemoteNGCSupported: true,
IsSignup: false,
OriginalRequest: "",
Otclogindisallowed: false,
Uaid: a.Uaid,
Username: a.Account,
}
if a.LoginType == TYPE_DEVICE {
reqBody.IsFidoSupported = true
}
reqB, err := json.Marshal(reqBody)
if err != nil {
return
}
a.reqClient.Post().SetUrl("%v", a.UrlGetCredentialType).
SetHeader("Content-Type", "application/json").
SetBody(bytes.NewReader(reqB)).
Do()
if a.reqClient.GetStatusCode() != 200 {
return fmt.Errorf("get credential type failed, status code: %v", a.reqClient.GetStatusCode())
}
// fmt.Println(a.reqClient.GetStatusCode())
// fmt.Println(a.reqClient.GetBodyString())
err = json.Unmarshal(a.reqClient.GetBody(), &a.CredentialType)
if err != nil {
return
}
return
}