mirror of
https://github.com/minio/minio.git
synced 2025-01-11 15:03:22 -05:00
gateway/gcs: Complete minio browser support for gcs. (#4552)
Fixes #4460
This commit is contained in:
parent
3928c1e14c
commit
5a78266821
@ -20,7 +20,6 @@ import (
|
|||||||
"crypto/md5"
|
"crypto/md5"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"hash"
|
"hash"
|
||||||
"io"
|
"io"
|
||||||
@ -169,10 +168,6 @@ func newAzureLayer(host string) (GatewayLayer, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
creds := serverConfig.GetCredential()
|
creds := serverConfig.GetCredential()
|
||||||
if !creds.IsValid() && !globalIsEnvCreds {
|
|
||||||
return nil, errors.New("Azure backend account and secret keys should be set through ENVs")
|
|
||||||
}
|
|
||||||
|
|
||||||
c, err := storage.NewClient(creds.AccessKey, creds.SecretKey, endpoint, globalAzureAPIVersion, secure)
|
c, err := storage.NewClient(creds.AccessKey, creds.SecretKey, endpoint, globalAzureAPIVersion, secure)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return &azureObjects{}, err
|
return &azureObjects{}, err
|
||||||
|
@ -290,6 +290,11 @@ func gatewayMain(ctx *cli.Context, backendType gatewayBackend) {
|
|||||||
// Handle common env vars.
|
// Handle common env vars.
|
||||||
handleCommonEnvVars()
|
handleCommonEnvVars()
|
||||||
|
|
||||||
|
// Validate if we have access, secret set through environment.
|
||||||
|
if !globalIsEnvCreds {
|
||||||
|
fatalIf(fmt.Errorf("Access and Secret keys should be set through ENVs for backend [%s]", backendType), "")
|
||||||
|
}
|
||||||
|
|
||||||
// Create certs path.
|
// Create certs path.
|
||||||
fatalIf(createConfigDir(), "Unable to create configuration directories.")
|
fatalIf(createConfigDir(), "Unable to create configuration directories.")
|
||||||
|
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"path"
|
"path"
|
||||||
@ -120,9 +119,6 @@ func newS3Gateway(host string) (GatewayLayer, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
creds := serverConfig.GetCredential()
|
creds := serverConfig.GetCredential()
|
||||||
if !creds.IsValid() && !globalIsEnvCreds {
|
|
||||||
return nil, errors.New("S3 backend account and secret keys should be set through ENVs")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Initialize minio client object.
|
// Initialize minio client object.
|
||||||
client, err := minio.NewCore(endpoint, creds.AccessKey, creds.SecretKey, secure)
|
client, err := minio.NewCore(endpoint, creds.AccessKey, creds.SecretKey, secure)
|
||||||
|
@ -690,13 +690,15 @@ func getBucketAccessPolicy(objAPI ObjectLayer, bucketName string) (policy.Bucket
|
|||||||
policyInfo, err = layer.GetBucketPolicies(bucketName)
|
policyInfo, err = layer.GetBucketPolicies(bucketName)
|
||||||
case *azureObjects:
|
case *azureObjects:
|
||||||
policyInfo, err = layer.GetBucketPolicies(bucketName)
|
policyInfo, err = layer.GetBucketPolicies(bucketName)
|
||||||
|
case *gcsGateway:
|
||||||
|
policyInfo, err = layer.GetBucketPolicies(bucketName)
|
||||||
default:
|
default:
|
||||||
policyInfo, err = readBucketAccessPolicy(objAPI, bucketName)
|
policyInfo, err = readBucketAccessPolicy(objAPI, bucketName)
|
||||||
}
|
}
|
||||||
return policyInfo, err
|
return policyInfo, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetBucketPolicy - get bucket policy.
|
// GetBucketPolicy - get bucket policy for the requested prefix.
|
||||||
func (web *webAPIHandlers) GetBucketPolicy(r *http.Request, args *GetBucketPolicyArgs, reply *GetBucketPolicyRep) error {
|
func (web *webAPIHandlers) GetBucketPolicy(r *http.Request, args *GetBucketPolicyArgs, reply *GetBucketPolicyRep) error {
|
||||||
objectAPI := web.ObjectAPI()
|
objectAPI := web.ObjectAPI()
|
||||||
if objectAPI == nil {
|
if objectAPI == nil {
|
||||||
@ -707,9 +709,12 @@ func (web *webAPIHandlers) GetBucketPolicy(r *http.Request, args *GetBucketPolic
|
|||||||
return toJSONError(errAuthentication)
|
return toJSONError(errAuthentication)
|
||||||
}
|
}
|
||||||
|
|
||||||
policyInfo, err := readBucketAccessPolicy(objectAPI, args.BucketName)
|
var policyInfo, err = getBucketAccessPolicy(objectAPI, args.BucketName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return toJSONError(err, args.BucketName)
|
_, ok := errorCause(err).(PolicyNotFound)
|
||||||
|
if !ok {
|
||||||
|
return toJSONError(err, args.BucketName)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
reply.UIVersion = browser.UIVersion
|
reply.UIVersion = browser.UIVersion
|
||||||
@ -745,8 +750,8 @@ func (web *webAPIHandlers) ListAllBucketPolicies(r *http.Request, args *ListAllB
|
|||||||
if !isHTTPRequestValid(r) {
|
if !isHTTPRequestValid(r) {
|
||||||
return toJSONError(errAuthentication)
|
return toJSONError(errAuthentication)
|
||||||
}
|
}
|
||||||
var policyInfo, err = getBucketAccessPolicy(objectAPI, args.BucketName)
|
|
||||||
|
|
||||||
|
var policyInfo, err = getBucketAccessPolicy(objectAPI, args.BucketName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
_, ok := errorCause(err).(PolicyNotFound)
|
_, ok := errorCause(err).(PolicyNotFound)
|
||||||
if !ok {
|
if !ok {
|
||||||
@ -791,7 +796,6 @@ func (web *webAPIHandlers) SetBucketPolicy(r *http.Request, args *SetBucketPolic
|
|||||||
}
|
}
|
||||||
|
|
||||||
var policyInfo, err = getBucketAccessPolicy(objectAPI, args.BucketName)
|
var policyInfo, err = getBucketAccessPolicy(objectAPI, args.BucketName)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if _, ok := errorCause(err).(PolicyNotFound); !ok {
|
if _, ok := errorCause(err).(PolicyNotFound); !ok {
|
||||||
return toJSONError(err, args.BucketName)
|
return toJSONError(err, args.BucketName)
|
||||||
|
Loading…
Reference in New Issue
Block a user