Ejemplo n.º 1
0
// GetBucketPolicy - get bucket policy at a given path.
func (c Client) GetBucketPolicy(bucketName, objectPrefix string) (bucketPolicy policy.BucketPolicy, err error) {
	// Input validation.
	if err := isValidBucketName(bucketName); err != nil {
		return policy.BucketPolicyNone, err
	}
	if err := isValidObjectPrefix(objectPrefix); err != nil {
		return policy.BucketPolicyNone, err
	}
	policyInfo, err := c.getBucketPolicy(bucketName, objectPrefix)
	if err != nil {
		return policy.BucketPolicyNone, err
	}
	return policy.GetPolicy(policyInfo.Statements, bucketName, objectPrefix), nil
}
Ejemplo n.º 2
0
// GetBucketPolicy - get bucket policy.
func (web *webAPIHandlers) GetBucketPolicy(r *http.Request, args *GetBucketPolicyArgs, reply *GetBucketPolicyRep) error {
	objectAPI := web.ObjectAPI()
	if objectAPI == nil {
		return toJSONError(errServerNotInitialized)
	}

	if !isJWTReqAuthenticated(r) {
		return toJSONError(errAuthentication)
	}

	policyInfo, err := readBucketAccessPolicy(objectAPI, args.BucketName)
	if err != nil {
		return toJSONError(err, args.BucketName)
	}

	reply.UIVersion = miniobrowser.UIVersion
	reply.Policy = policy.GetPolicy(policyInfo.Statements, args.BucketName, args.Prefix)

	return nil
}
Ejemplo n.º 3
0
// GetBucketPolicy - get bucket policy.
func (web *webAPIHandlers) GetBucketPolicy(r *http.Request, args *GetBucketPolicyArgs, reply *GetBucketPolicyRep) error {
	if !isJWTReqAuthenticated(r) {
		return &json2.Error{Message: "Unauthorized request"}
	}

	objectAPI := web.ObjectAPI()
	if objectAPI == nil {
		return &json2.Error{Message: "Server not initialized"}
	}
	policyInfo, err := readBucketAccessPolicy(objectAPI, args.BucketName)
	if err != nil {
		return &json2.Error{Message: err.Error()}
	}

	bucketPolicy := policy.GetPolicy(policyInfo.Statements, args.BucketName, args.Prefix)

	reply.UIVersion = miniobrowser.UIVersion
	reply.Policy = bucketPolicy

	return nil
}