Add new option for bucket ACL named `authenticated-read`

This provides read access to all users who are part of AuthenticatedUsers group

~~~
  $ mc access authenticated https://s3.amazonaws.com/bucketname
~~~
This commit is contained in:
Harshavardhana
2015-05-08 21:12:32 -07:00
parent 5a69d76b93
commit e57e6de098
5 changed files with 24 additions and 3 deletions
+14 -3
View File
@@ -24,6 +24,8 @@ func (b bucketACL) isValidBucketACL() bool {
case b.isReadOnly():
fallthrough
case b.isPublic():
fallthrough
case b.isAuthenticated():
return true
case b.String() == "private":
// by default its "private"
@@ -38,9 +40,10 @@ type bucketACL string
// different types of ACL's currently supported for buckets
const (
bucketPrivate = bucketACL("private")
bucketReadOnly = bucketACL("readonly")
bucketPublic = bucketACL("public")
bucketPrivate = bucketACL("private")
bucketReadOnly = bucketACL("readonly")
bucketPublic = bucketACL("public")
bucketAuthenticated = bucketACL("authenticated")
)
func (b bucketACL) String() string {
@@ -53,6 +56,9 @@ func (b bucketACL) String() string {
if string(b) == "public" {
return "public-read-write"
}
if string(b) == "authenticated" {
return "authenticated-read"
}
return string(b)
}
@@ -70,3 +76,8 @@ func (b bucketACL) isReadOnly() bool {
func (b bucketACL) isPublic() bool {
return b == bucketPublic
}
// IsAuthenticated - is acl AuthenticatedRead
func (b bucketACL) isAuthenticated() bool {
return b == bucketAuthenticated
}
+3
View File
@@ -51,6 +51,9 @@ EXAMPLES:
2. Set bucket to "public" on Amazon S3 object storage
$ mc {{.Name}} public https://s3.amazonaws.com/shared
3. Set bucket to "authenticated" on Amazon S3 object storage to provide read access to AuthenticatedUsers group
$ mc {{.Name}} authenticated https://s3.amazonaws.com/shared-authenticated
3. Set folder to world readwrite (chmod 777) on local filesystem
$ mc {{.Name}} public /shared/Music
+4
View File
@@ -233,6 +233,8 @@ func isValidBucketACL(acl string) bool {
fallthrough
case "public-read-write":
fallthrough
case "authenticated-read":
fallthrough
case "":
return true
default:
@@ -249,6 +251,8 @@ func aclToPerm(acl string) os.FileMode {
return os.FileMode(0500)
case "public-read-write":
return os.FileMode(0777)
case "authenticated-read":
return os.FileMode(0770)
default:
return os.FileMode(0700)
}
+2
View File
@@ -32,6 +32,8 @@ func isValidBucketACL(acl string) bool {
case "public-read":
fallthrough
case "public-read-write":
fallthrough
case "authenticated-read":
return true
default:
return false
+1
View File
@@ -81,6 +81,7 @@ func (s *MySuite) TestBucketACL(c *C) {
{"private", true},
{"public-read", true},
{"public-read-write", true},
{"authenticated-read", true},
{"", false},
{"readonly", false},
{"invalid", false},