Skip to content

Commit

Permalink
fix: sts client may receive 403 error when timestamp expired, fix bai…
Browse files Browse the repository at this point in the history
  • Loading branch information
shuai.qi committed May 25, 2023
1 parent 24d4848 commit a8cd8c7
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions services/sts/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"github.com/baidubce/bce-sdk-go/auth"
"github.com/baidubce/bce-sdk-go/bce"
"github.com/baidubce/bce-sdk-go/services/sts/api"
"github.com/baidubce/bce-sdk-go/util"
)

const DEFAULT_SERVICE_DOMAIN = "sts." + bce.DEFAULT_REGION + "." + bce.DEFAULT_DOMAIN
Expand Down Expand Up @@ -57,16 +56,16 @@ func NewStsClient(ak, sk, endpoint string) (*Client, error) {
endpoint = DEFAULT_SERVICE_DOMAIN
}
defaultSignOptions := &auth.SignOptions{
HeadersToSign: auth.DEFAULT_HEADERS_TO_SIGN,
Timestamp: util.NowUTCSeconds(),
ExpireSeconds: auth.DEFAULT_EXPIRE_SECONDS}
HeadersToSign: auth.DEFAULT_HEADERS_TO_SIGN,
Timestamp: 0,
ExpireSeconds: auth.DEFAULT_EXPIRE_SECONDS}
defaultConf := &bce.BceClientConfiguration{
Endpoint: endpoint,
Region: bce.DEFAULT_REGION,
UserAgent: bce.DEFAULT_USER_AGENT,
Credentials: credentials,
SignOption: defaultSignOptions,
Retry: bce.DEFAULT_RETRY_POLICY,
Endpoint: endpoint,
Region: bce.DEFAULT_REGION,
UserAgent: bce.DEFAULT_USER_AGENT,
Credentials: credentials,
SignOption: defaultSignOptions,
Retry: bce.DEFAULT_RETRY_POLICY,
ConnectionTimeoutInMillis: bce.DEFAULT_CONNECTION_TIMEOUT_IN_MILLIS}
v1Signer := &auth.BceV1Signer{}

Expand Down

0 comments on commit a8cd8c7

Please sign in to comment.