You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							28 lines
						
					
					
						
							688 B
						
					
					
				
			
		
		
		
			
			
			
		
		
	
	
							28 lines
						
					
					
						
							688 B
						
					
					
				
								package s3api
							 | 
						|
								
							 | 
						|
								import (
							 | 
						|
									"github.com/seaweedfs/seaweedfs/weed/s3api/s3_constants"
							 | 
						|
									"github.com/seaweedfs/seaweedfs/weed/s3api/s3err"
							 | 
						|
									"net/http"
							 | 
						|
								)
							 | 
						|
								
							 | 
						|
								func getAccountId(r *http.Request) string {
							 | 
						|
									id := r.Header.Get(s3_constants.AmzAccountId)
							 | 
						|
									if len(id) == 0 {
							 | 
						|
										return AccountAnonymous.Id
							 | 
						|
									} else {
							 | 
						|
										return id
							 | 
						|
									}
							 | 
						|
								}
							 | 
						|
								
							 | 
						|
								func (s3a *S3ApiServer) checkAccessByOwnership(r *http.Request, bucket string) s3err.ErrorCode {
							 | 
						|
									metadata, errCode := s3a.bucketRegistry.GetBucketMetadata(bucket)
							 | 
						|
									if errCode != s3err.ErrNone {
							 | 
						|
										return errCode
							 | 
						|
									}
							 | 
						|
									accountId := getAccountId(r)
							 | 
						|
									if accountId == AccountAdmin.Id || accountId == *metadata.Owner.ID {
							 | 
						|
										return s3err.ErrNone
							 | 
						|
									}
							 | 
						|
									return s3err.ErrAccessDenied
							 | 
						|
								}
							 |