diff --git a/go.mod b/go.mod index 2b2aedd5..ee888dfb 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/alibabacloud-go/sts-20150401 v1.1.0 github.com/alibabacloud-go/tea v1.2.1 github.com/aliyun/alibaba-cloud-sdk-go v1.62.156 - github.com/aliyun/credentials-go v1.3.0 + github.com/aliyun/credentials-go v1.3.2 github.com/briandowns/spinner v1.23.0 github.com/fatih/color v1.15.0 github.com/json-iterator/go v1.1.12 // indirect diff --git a/go.sum b/go.sum index a63d801c..59cc2e14 100644 --- a/go.sum +++ b/go.sum @@ -47,8 +47,8 @@ github.com/alibabacloud-go/tea-xml v1.1.2/go.mod h1:Rq08vgCcCAjHyRi/M7xlHKUykZCE github.com/aliyun/alibaba-cloud-sdk-go v1.62.156 h1:K4N91T1+RlSlx+t2dujeDviy4ehSGVjEltluDgmeHS4= github.com/aliyun/alibaba-cloud-sdk-go v1.62.156/go.mod h1:Api2AkmMgGaSUAhmk76oaFObkoeCPc/bKAqcyplPODs= github.com/aliyun/credentials-go v1.1.2/go.mod h1:ozcZaMR5kLM7pwtCMEpVmQ242suV6qTJya2bDq4X1Tw= -github.com/aliyun/credentials-go v1.3.0 h1:wfBNojfNJJyuHK3YUIIjRPwnlQIdmy/YMkia1XOnPtY= -github.com/aliyun/credentials-go v1.3.0/go.mod h1:8jKYhQuDawt8x2+fusqa1Y6mPxemTsBEN04dgcAcYz0= +github.com/aliyun/credentials-go v1.3.2 h1:L4WppI9rctC8PdlMgyTkF8bBsy9pyKQEzBD1bHMRl+g= +github.com/aliyun/credentials-go v1.3.2/go.mod h1:tlpz4uys4Rn7Ik4/piGRrTbXy2uLKvePgQJJduE+Y5c= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/briandowns/spinner v1.23.0 h1:alDF2guRWqa/FOZZYWjlMIx2L6H0wyewPxo/CH4Pt2A= github.com/briandowns/spinner v1.23.0/go.mod h1:rPG4gmXeN3wQV/TsAY4w8lPdIM6RX3yqeBQJSrbXjuE= @@ -207,6 +207,7 @@ golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.10.0/go.mod h1:o4eNf7Ede1fv+hwOwZsTHl9EsPFO6q6ZvYR8vYfY45I= +golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= @@ -224,7 +225,6 @@ golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= golang.org/x/net v0.11.0/go.mod h1:2L/ixqYpgIVXmeoSA/4Lu7BzTG4KIyPIryS4IsOd1oQ= golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= diff --git a/vendor/github.com/aliyun/credentials-go/credentials/access_key_credential.go b/vendor/github.com/aliyun/credentials-go/credentials/access_key_credential.go index 7bcaa974..78530e68 100644 --- a/vendor/github.com/aliyun/credentials-go/credentials/access_key_credential.go +++ b/vendor/github.com/aliyun/credentials-go/credentials/access_key_credential.go @@ -15,6 +15,15 @@ func newAccessKeyCredential(accessKeyId, accessKeySecret string) *AccessKeyCrede } } +func (s *AccessKeyCredential) GetCredential() (*CredentialModel, error) { + credential := &CredentialModel{ + AccessKeyId: tea.String(s.AccessKeyId), + AccessKeySecret: tea.String(s.AccessKeySecret), + Type: tea.String("access_key"), + } + return credential, nil +} + // GetAccessKeyId reutrns AccessKeyCreential's AccessKeyId func (a *AccessKeyCredential) GetAccessKeyId() (*string, error) { return tea.String(a.AccessKeyId), nil diff --git a/vendor/github.com/aliyun/credentials-go/credentials/bearer_token_credential.go b/vendor/github.com/aliyun/credentials-go/credentials/bearer_token_credential.go index cca29162..9df4d320 100644 --- a/vendor/github.com/aliyun/credentials-go/credentials/bearer_token_credential.go +++ b/vendor/github.com/aliyun/credentials-go/credentials/bearer_token_credential.go @@ -14,6 +14,14 @@ func newBearerTokenCredential(token string) *BearerTokenCredential { } } +func (s *BearerTokenCredential) GetCredential() (*CredentialModel, error) { + credential := &CredentialModel{ + BearerToken: tea.String(s.BearerToken), + Type: tea.String("bearer"), + } + return credential, nil +} + // GetAccessKeyId is useless for BearerTokenCredential func (b *BearerTokenCredential) GetAccessKeyId() (*string, error) { return tea.String(""), nil diff --git a/vendor/github.com/aliyun/credentials-go/credentials/credential.go b/vendor/github.com/aliyun/credentials-go/credentials/credential.go index 63ee7ce4..2603dc0c 100644 --- a/vendor/github.com/aliyun/credentials-go/credentials/credential.go +++ b/vendor/github.com/aliyun/credentials-go/credentials/credential.go @@ -30,6 +30,7 @@ type Credential interface { GetSecurityToken() (*string, error) GetBearerToken() *string GetType() *string + GetCredential() (*CredentialModel, error) } // Config is important when call NewCredential diff --git a/vendor/github.com/aliyun/credentials-go/credentials/credential_model.go b/vendor/github.com/aliyun/credentials-go/credentials/credential_model.go new file mode 100644 index 00000000..7b46c308 --- /dev/null +++ b/vendor/github.com/aliyun/credentials-go/credentials/credential_model.go @@ -0,0 +1,50 @@ +package credentials + +import "github.com/alibabacloud-go/tea/tea" + +// CredentialModel is a model +type CredentialModel struct { + // accesskey id + AccessKeyId *string `json:"accessKeyId,omitempty" xml:"accessKeyId,omitempty"` + // accesskey secret + AccessKeySecret *string `json:"accessKeySecret,omitempty" xml:"accessKeySecret,omitempty"` + // security token + SecurityToken *string `json:"securityToken,omitempty" xml:"securityToken,omitempty"` + // bearer token + BearerToken *string `json:"bearerToken,omitempty" xml:"bearerToken,omitempty"` + // type + Type *string `json:"type,omitempty" xml:"type,omitempty"` +} + +func (s CredentialModel) String() string { + return tea.Prettify(s) +} + +func (s CredentialModel) GoString() string { + return s.String() +} + +func (s *CredentialModel) SetAccessKeyId(v string) *CredentialModel { + s.AccessKeyId = &v + return s +} + +func (s *CredentialModel) SetAccessKeySecret(v string) *CredentialModel { + s.AccessKeySecret = &v + return s +} + +func (s *CredentialModel) SetSecurityToken(v string) *CredentialModel { + s.SecurityToken = &v + return s +} + +func (s *CredentialModel) SetBearerToken(v string) *CredentialModel { + s.BearerToken = &v + return s +} + +func (s *CredentialModel) SetType(v string) *CredentialModel { + s.Type = &v + return s +} diff --git a/vendor/github.com/aliyun/credentials-go/credentials/ecs_ram_role.go b/vendor/github.com/aliyun/credentials-go/credentials/ecs_ram_role.go index 5e7ddf4d..d86360fc 100644 --- a/vendor/github.com/aliyun/credentials-go/credentials/ecs_ram_role.go +++ b/vendor/github.com/aliyun/credentials-go/credentials/ecs_ram_role.go @@ -40,6 +40,22 @@ func newEcsRAMRoleCredential(roleName string, inAdvanceScale float64, runtime *u } } +func (e *EcsRAMRoleCredential) GetCredential() (*CredentialModel, error) { + if e.sessionCredential == nil || e.needUpdateCredential() { + err := e.updateCredential() + if err != nil { + return nil, err + } + } + credential := &CredentialModel{ + AccessKeyId: tea.String(e.sessionCredential.AccessKeyId), + AccessKeySecret: tea.String(e.sessionCredential.AccessKeySecret), + SecurityToken: tea.String(e.sessionCredential.SecurityToken), + Type: tea.String("ecs_ram_role"), + } + return credential, nil +} + // GetAccessKeyId reutrns EcsRAMRoleCredential's AccessKeyId // if AccessKeyId is not exist or out of date, the function will update it. func (e *EcsRAMRoleCredential) GetAccessKeyId() (*string, error) { diff --git a/vendor/github.com/aliyun/credentials-go/credentials/oidc_credential.go b/vendor/github.com/aliyun/credentials-go/credentials/oidc_credential.go index 7267383c..de0acc7f 100644 --- a/vendor/github.com/aliyun/credentials-go/credentials/oidc_credential.go +++ b/vendor/github.com/aliyun/credentials-go/credentials/oidc_credential.go @@ -5,6 +5,7 @@ import ( "fmt" "io/ioutil" "os" + "strconv" "time" "github.com/alibabacloud-go/tea/tea" @@ -55,6 +56,22 @@ func newOIDCRoleArnCredential(accessKeyId, accessKeySecret, roleArn, OIDCProvide } } +func (e *OIDCCredential) GetCredential() (*CredentialModel, error) { + if e.sessionCredential == nil || e.needUpdateCredential() { + err := e.updateCredential() + if err != nil { + return nil, err + } + } + credential := &CredentialModel{ + AccessKeyId: tea.String(e.sessionCredential.AccessKeyId), + AccessKeySecret: tea.String(e.sessionCredential.AccessKeySecret), + SecurityToken: tea.String(e.sessionCredential.SecurityToken), + Type: tea.String("oidc_role_arn"), + } + return credential, nil +} + // GetAccessKeyId reutrns OIDCCredential's AccessKeyId // if AccessKeyId is not exist or out of date, the function will update it. func (r *OIDCCredential) GetAccessKeyId() (*string, error) { @@ -138,6 +155,9 @@ func (r *OIDCCredential) updateCredential() (err error) { if r.Policy != "" { request.QueryParams["Policy"] = r.Policy } + if r.RoleSessionExpiration > 0 { + request.QueryParams["DurationSeconds"] = strconv.Itoa(r.RoleSessionExpiration) + } request.QueryParams["RoleSessionName"] = r.RoleSessionName request.QueryParams["Version"] = "2015-04-01" request.QueryParams["SignatureNonce"] = utils.GetUUID() diff --git a/vendor/github.com/aliyun/credentials-go/credentials/rsa_key_pair_credential.go b/vendor/github.com/aliyun/credentials-go/credentials/rsa_key_pair_credential.go index de251568..82988eca 100644 --- a/vendor/github.com/aliyun/credentials-go/credentials/rsa_key_pair_credential.go +++ b/vendor/github.com/aliyun/credentials-go/credentials/rsa_key_pair_credential.go @@ -42,6 +42,22 @@ func newRsaKeyPairCredential(privateKey, publicKeyId string, sessionExpiration i } } +func (e *RsaKeyPairCredential) GetCredential() (*CredentialModel, error) { + if e.sessionCredential == nil || e.needUpdateCredential() { + err := e.updateCredential() + if err != nil { + return nil, err + } + } + credential := &CredentialModel{ + AccessKeyId: tea.String(e.sessionCredential.AccessKeyId), + AccessKeySecret: tea.String(e.sessionCredential.AccessKeySecret), + SecurityToken: tea.String(e.sessionCredential.SecurityToken), + Type: tea.String("rsa_key_pair"), + } + return credential, nil +} + // GetAccessKeyId reutrns RsaKeyPairCredential's AccessKeyId // if AccessKeyId is not exist or out of date, the function will update it. func (r *RsaKeyPairCredential) GetAccessKeyId() (*string, error) { diff --git a/vendor/github.com/aliyun/credentials-go/credentials/sts_credential.go b/vendor/github.com/aliyun/credentials-go/credentials/sts_credential.go index ba07dab4..5a9973f2 100644 --- a/vendor/github.com/aliyun/credentials-go/credentials/sts_credential.go +++ b/vendor/github.com/aliyun/credentials-go/credentials/sts_credential.go @@ -17,6 +17,16 @@ func newStsTokenCredential(accessKeyId, accessKeySecret, securityToken string) * } } +func (s *StsTokenCredential) GetCredential() (*CredentialModel, error) { + credential := &CredentialModel{ + AccessKeyId: tea.String(s.AccessKeyId), + AccessKeySecret: tea.String(s.AccessKeySecret), + SecurityToken: tea.String(s.SecurityToken), + Type: tea.String("sts"), + } + return credential, nil +} + // GetAccessKeyId reutrns StsTokenCredential's AccessKeyId func (s *StsTokenCredential) GetAccessKeyId() (*string, error) { return tea.String(s.AccessKeyId), nil diff --git a/vendor/github.com/aliyun/credentials-go/credentials/sts_role_arn_credential.go b/vendor/github.com/aliyun/credentials-go/credentials/sts_role_arn_credential.go index 77fa3da2..3ddf32fa 100644 --- a/vendor/github.com/aliyun/credentials-go/credentials/sts_role_arn_credential.go +++ b/vendor/github.com/aliyun/credentials-go/credentials/sts_role_arn_credential.go @@ -66,6 +66,22 @@ func newRAMRoleArnWithExternalIdCredential(accessKeyId, accessKeySecret, roleArn } } +func (e *RAMRoleArnCredential) GetCredential() (*CredentialModel, error) { + if e.sessionCredential == nil || e.needUpdateCredential() { + err := e.updateCredential() + if err != nil { + return nil, err + } + } + credential := &CredentialModel{ + AccessKeyId: tea.String(e.sessionCredential.AccessKeyId), + AccessKeySecret: tea.String(e.sessionCredential.AccessKeySecret), + SecurityToken: tea.String(e.sessionCredential.SecurityToken), + Type: tea.String("ram_role_arn"), + } + return credential, nil +} + // GetAccessKeyId reutrns RamRoleArnCredential's AccessKeyId // if AccessKeyId is not exist or out of date, the function will update it. func (r *RAMRoleArnCredential) GetAccessKeyId() (*string, error) { diff --git a/vendor/github.com/aliyun/credentials-go/credentials/uri_credential.go b/vendor/github.com/aliyun/credentials-go/credentials/uri_credential.go index e8f303fc..d03006c9 100644 --- a/vendor/github.com/aliyun/credentials-go/credentials/uri_credential.go +++ b/vendor/github.com/aliyun/credentials-go/credentials/uri_credential.go @@ -37,6 +37,22 @@ func newURLCredential(URL string) *URLCredential { } } +func (e *URLCredential) GetCredential() (*CredentialModel, error) { + if e.sessionCredential == nil || e.needUpdateCredential() { + err := e.updateCredential() + if err != nil { + return nil, err + } + } + credential := &CredentialModel{ + AccessKeyId: tea.String(e.sessionCredential.AccessKeyId), + AccessKeySecret: tea.String(e.sessionCredential.AccessKeySecret), + SecurityToken: tea.String(e.sessionCredential.SecurityToken), + Type: tea.String("credential_uri"), + } + return credential, nil +} + // GetAccessKeyId reutrns URLCredential's AccessKeyId // if AccessKeyId is not exist or out of date, the function will update it. func (e *URLCredential) GetAccessKeyId() (*string, error) { diff --git a/vendor/modules.txt b/vendor/modules.txt index 0823253f..84351138 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -54,7 +54,7 @@ github.com/aliyun/alibaba-cloud-sdk-go/sdk/errors github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses github.com/aliyun/alibaba-cloud-sdk-go/sdk/utils -# github.com/aliyun/credentials-go v1.3.0 +# github.com/aliyun/credentials-go v1.3.2 ## explicit; go 1.14 github.com/aliyun/credentials-go/credentials github.com/aliyun/credentials-go/credentials/request