Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add signedHost field to presignedUrl #1234

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/minio.js
Original file line number Diff line number Diff line change
Expand Up @@ -1194,10 +1194,14 @@ export class Client extends TypedClient {
// * `expiry` _number_: expiry in seconds (optional, default 7 days)
// * `reqParams` _object_: request parameters (optional) e.g {versionId:"10fa9946-3f64-4137-a58f-888065c0732e"}
// * `requestDate` _Date_: A date object, the url will be issued at (optional)
presignedUrl(method, bucketName, objectName, expires, reqParams, requestDate, cb) {
// * `signedHost` _string_: The hostname that will be allowed to access the resource (optional)
presignedUrl(method, bucketName, objectName, expires, reqParams, requestDate, signedHost, cb) {
if (this.anonymous) {
throw new errors.AnonymousRequestError('Presigned ' + method + ' url cannot be generated for anonymous requests')
}
if (isFunction(signedHost)) {
cb = signedHost
}
if (isFunction(requestDate)) {
cb = requestDate
requestDate = new Date()
Expand Down Expand Up @@ -1233,7 +1237,11 @@ export class Client extends TypedClient {
// This statement is added to ensure that we send error through
// callback on presign failure.
var url
var reqOptions = this.getRequestOptions({ method, region, bucketName, objectName, query })
var headers = {}
if(signedHost) {
headers.host = signedHost
}
var reqOptions = this.getRequestOptions({ method, region, bucketName, objectName, query, headers })

this.checkAndRefreshCreds()
try {
Expand Down