Skip to content

Commit

Permalink
pass credentials provider name to request headers
Browse files Browse the repository at this point in the history
  • Loading branch information
JacksonTian committed Aug 22, 2024
1 parent 5c47d32 commit 8389d39
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions sdk/auth/roa_signature_composer.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ func signRoaRequest(request requests.AcsRequest, credentialsProvider credentials

func completeROASignParams(request requests.AcsRequest, cc *credentials.Credentials) {
headerParams := request.GetHeaders()
headerParams["x-acs-credentials-provider"] = cc.ProviderName

if cc.SecurityToken != "" {
headerParams["x-acs-security-token"] = cc.SecurityToken
Expand Down
6 changes: 4 additions & 2 deletions sdk/auth/roa_signature_composer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ func TestRoaSignatureComposer(t *testing.T) {
assert.Nil(t, err)
signRoaRequest(request, provider)
assert.Equal(t, "mock date", request.GetHeaders()["Date"])
assert.Equal(t, "acs accessKeyId:degLHXLEN6rMojj+bOlK74U9iic=", request.GetHeaders()["Authorization"])
assert.Equal(t, "static_ak", request.GetHeaders()["x-acs-credentials-provider"])
assert.Equal(t, "acs accessKeyId:PPPSwv0LPoLvg6rGxp7dd4uPESo=", request.GetHeaders()["Authorization"])
}

func TestRoaSignatureComposer2(t *testing.T) {
Expand All @@ -70,7 +71,8 @@ func TestRoaSignatureComposer2(t *testing.T) {
assert.Equal(t, "application/x-www-form-urlencoded", request.GetHeaders()["Content-Type"])
assert.Equal(t, "mock date", request.GetHeaders()["Date"])
assert.Equal(t, "application/xml", request.GetHeaders()["Accept"])
assert.Equal(t, "acs accessKeyId:U9uA3ftRZKixHPB08Z7Z4GOlpTY=", request.GetHeaders()["Authorization"])
assert.Equal(t, "static_ak", request.GetHeaders()["x-acs-credentials-provider"])
assert.Equal(t, "acs accessKeyId:X/tjQCOP4ZMCzQ1I1IdCra3byPA=", request.GetHeaders()["Authorization"])
}

func TestRoaSignatureComposer3(t *testing.T) {
Expand Down
1 change: 1 addition & 0 deletions sdk/auth/rpc_signature_composer.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ func signRpcRequest(request requests.AcsRequest, regionId string, provider crede
}

request.GetHeaders()["Content-Type"] = requests.Form
request.GetHeaders()["x-acs-credentials-provider"] = cc.ProviderName
formString := utils.GetUrlFormedMap(request.GetFormParams())
request.SetContent([]byte(formString))

Expand Down

0 comments on commit 8389d39

Please sign in to comment.