From 4db136c19c681bcef6c81ead567018c2bed79c33 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Sat, 20 Feb 2016 01:52:21 -0800 Subject: [PATCH] web: Add targetProto for putObjectURL,getObjectURL SSL requests. Currently the default request was based on the 'minio server' SSL configuration. But inside a proxy this is invalid browser needs to send which protocol it wishes the PresignedURL should be generated for. --- routers.go | 2 -- web-handlers.go | 25 +++++++++++++++++-------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/routers.go b/routers.go index 1f995240a..496396d36 100644 --- a/routers.go +++ b/routers.go @@ -52,7 +52,6 @@ type webAPI struct { Client minio.CloudStorageClient // private params. - inSecure bool // Enabled if TLS is false. apiAddress string // api destination address. // accessKeys kept to be used internally. accessKeyID string @@ -130,7 +129,6 @@ func initWeb(conf cloudServerConfig) *webAPI { FSPath: conf.Path, AccessLog: conf.AccessLog, Client: client, - inSecure: inSecure, apiAddress: conf.Address, accessKeyID: conf.AccessKeyID, secretAccessKey: conf.SecretAccessKey, diff --git a/web-handlers.go b/web-handlers.go index 1dced342d..c21e4d8c2 100644 --- a/web-handlers.go +++ b/web-handlers.go @@ -242,9 +242,10 @@ func (web *webAPI) ListObjects(r *http.Request, args *ListObjectsArgs, reply *Li // PutObjectURLArgs - args to generate url for upload access. type PutObjectURLArgs struct { - TargetHost string `json:"targetHost"` - BucketName string `json:"bucketName"` - ObjectName string `json:"objectName"` + TargetHost string `json:"targetHost"` + TargetProto string `json:"targetProto"` + BucketName string `json:"bucketName"` + ObjectName string `json:"objectName"` } // PutObjectURLRep - reply for presigned upload url request. @@ -258,7 +259,11 @@ func (web *webAPI) PutObjectURL(r *http.Request, args *PutObjectURLArgs, reply * if !isJWTReqAuthenticated(r) { return &json2.Error{Message: "Unauthorized request"} } - client, e := minio.New(args.TargetHost, web.accessKeyID, web.secretAccessKey, web.inSecure) + + // disableSSL is true if no 'https:' proto is found. + disableSSL := (args.TargetProto != "https:") + + client, e := minio.New(args.TargetHost, web.accessKeyID, web.secretAccessKey, disableSSL) if e != nil { return &json2.Error{Message: e.Error()} } @@ -273,9 +278,10 @@ func (web *webAPI) PutObjectURL(r *http.Request, args *PutObjectURLArgs, reply * // GetObjectURLArgs - args to generate url for download access. type GetObjectURLArgs struct { - TargetHost string `json:"targetHost"` - BucketName string `json:"bucketName"` - ObjectName string `json:"objectName"` + TargetHost string `json:"targetHost"` + TargetProto string `json:"targetProto"` + BucketName string `json:"bucketName"` + ObjectName string `json:"objectName"` } // GetObjectURLRep - reply for presigned download url request. @@ -296,7 +302,10 @@ func (web *webAPI) GetObjectURL(r *http.Request, args *GetObjectURLArgs, reply * return &json2.Error{Message: e.Error()} } - client, e := minio.New(args.TargetHost, web.accessKeyID, web.secretAccessKey, web.inSecure) + // disableSSL is true if no 'https:' proto is found. + disableSSL := (args.TargetProto != "https:") + + client, e := minio.New(args.TargetHost, web.accessKeyID, web.secretAccessKey, disableSSL) if e != nil { return &json2.Error{Message: e.Error()} }