mirror of
https://github.com/minio/minio.git
synced 2025-11-07 21:02:58 -05:00
Add domain and subdomain support for MinioAPI
This change brings in domain and subdomain support - ./minio --domain "yourminiodomain.com" This change brings in a much needed feature by keeping bucketnames as part of your 'DNS' name. All your existing applications can be migrated off from s3 to Minio without little to no modifications. NOTE: Setting up DNS for your `buckets` is out of scope of this feature
This commit is contained in:
@@ -127,14 +127,15 @@ func (storage *storage) GetBucketPolicy(bucket string) (interface{}, error) {
|
||||
// get policy path
|
||||
bucketPolicy := path.Join(storage.root, bucket+"_policy.json")
|
||||
filestat, err := os.Stat(bucketPolicy)
|
||||
if filestat.IsDir() {
|
||||
return policy.BucketPolicy{}, mstorage.BackendCorrupted{Path: bucketPolicy}
|
||||
}
|
||||
|
||||
if os.IsNotExist(err) {
|
||||
return policy.BucketPolicy{}, mstorage.BucketPolicyNotFound{Bucket: bucket}
|
||||
}
|
||||
|
||||
if filestat.IsDir() {
|
||||
return policy.BucketPolicy{}, mstorage.BackendCorrupted{Path: bucketPolicy}
|
||||
}
|
||||
|
||||
file, err := os.OpenFile(bucketPolicy, os.O_RDONLY, 0666)
|
||||
defer file.Close()
|
||||
if err != nil {
|
||||
@@ -170,10 +171,13 @@ func (storage *storage) StoreBucketPolicy(bucket string, policy interface{}) err
|
||||
|
||||
// get policy path
|
||||
bucketPolicy := path.Join(storage.root, bucket+"_policy.json")
|
||||
filestat, _ := os.Stat(bucketPolicy)
|
||||
if filestat.IsDir() {
|
||||
return mstorage.BackendCorrupted{Path: bucketPolicy}
|
||||
filestat, ret := os.Stat(bucketPolicy)
|
||||
if !os.IsNotExist(ret) {
|
||||
if filestat.IsDir() {
|
||||
return mstorage.BackendCorrupted{Path: bucketPolicy}
|
||||
}
|
||||
}
|
||||
|
||||
file, err := os.OpenFile(bucketPolicy, os.O_WRONLY|os.O_CREATE, 0600)
|
||||
defer file.Close()
|
||||
if err != nil {
|
||||
|
||||
@@ -61,7 +61,8 @@ func IsValidBucket(bucket string) bool {
|
||||
if match, _ := regexp.MatchString("\\.\\.", bucket); match == true {
|
||||
return false
|
||||
}
|
||||
match, _ := regexp.MatchString("^[a-zA-Z][a-zA-Z0-9\\.\\-]+[a-zA-Z0-9]$", bucket)
|
||||
// We don't support buckets with '.' in them
|
||||
match, _ := regexp.MatchString("^[a-zA-Z][a-zA-Z0-9\\-]+[a-zA-Z0-9]$", bucket)
|
||||
return match
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user