Skip to content

Commit

Permalink
feat: 访问url增加x-bce-security-token
Browse files Browse the repository at this point in the history
  • Loading branch information
yanglu19 committed Jun 19, 2023
1 parent 1066527 commit aa5fe97
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@baiducloud/sdk",
"version": "1.0.0-rc.39",
"version": "1.0.0-rc.40",
"description": "Baidu Cloud Engine JavaScript SDK",
"main": "./index.js",
"browser": {
Expand Down
9 changes: 5 additions & 4 deletions src/bos_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,17 @@ BosClient.prototype.generatePresignedUrl = function (bucketName, key, timestamp,

var credentials = config.credentials;
var auth = new Auth(credentials.ak, credentials.sk);

if (config.sessionToken) {
params['x-bce-security-token'] = config.sessionToken;
}

var authorization = auth.generateAuthorization(
'GET', resource, params, headers, timestamp, expirationInSeconds,
headersToSign);

params.authorization = authorization;

if (config.sessionToken) {
params['x-bce-security-token'] = config.sessionToken;
}

return util.format('%s%s?%s', config.endpoint, resource, qs.encode(params));
};
Expand Down Expand Up @@ -1673,7 +1675,6 @@ BosClient.prototype.sendHTTPRequest = function (httpMethod, resource, args, conf

function doRequest() {
var agent = this._httpAgent = new HttpClient(config);

var httpContext = {
httpMethod: httpMethod,
resource: resource,
Expand Down

0 comments on commit aa5fe97

Please sign in to comment.