Documentation
¶
Overview ¶
Copyright 2023 SUSE, LLC..
Licensed under the Apache License, Version 2.0 (the "License"); You may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Constants
- Variables
- type BucketPolicy
- type PolicyStatement
- func (ps *PolicyStatement) Actions(actions ...action) *PolicyStatement
- func (ps *PolicyStatement) Allows() *PolicyStatement
- func (ps *PolicyStatement) Denies() *PolicyStatement
- func (ps *PolicyStatement) EjectPrincipals(users ...string)
- func (ps *PolicyStatement) ForPrincipals(users ...string) *PolicyStatement
- func (ps *PolicyStatement) ForResources(resources ...string) *PolicyStatement
- func (ps *PolicyStatement) ForSubResources(resources ...string) *PolicyStatement
- func (ps *PolicyStatement) WithSID(sid string) *PolicyStatement
- type S3Agent
- func (s *S3Agent) CreateBucket(name string) error
- func (s *S3Agent) CreateBucketNoInfoLogging(name string) error
- func (s *S3Agent) DeleteBucket(name string) (bool, error)
- func (s *S3Agent) DeleteObjectInBucket(bucketname string, key string) (bool, error)
- func (s *S3Agent) GetBucketPolicy(bucket string) (*BucketPolicy, error)
- func (s *S3Agent) GetObjectInBucket(bucketname string, key string) (string, error)
- func (s *S3Agent) PutBucketPolicy(bucket string, policy BucketPolicy) (*s3.PutBucketPolicyOutput, error)
- func (s *S3Agent) PutObjectInBucket(bucketname string, body string, key string, contentType string) (bool, error)
Constants ¶
const ( All action = "s3:*" AbortMultipartUpload action = "s3:AbortMultipartUpload" CreateBucket action = "s3:CreateBucket" DeleteBucketPolicy action = "s3:DeleteBucketPolicy" DeleteBucket action = "s3:DeleteBucket" DeleteBucketWebsite action = "s3:DeleteBucketWebsite" DeleteObject action = "s3:DeleteObject" DeleteObjectVersion action = "s3:DeleteObjectVersion" DeleteReplicationConfiguration action = "s3:DeleteReplicationConfiguration" GetAccelerateConfiguration action = "s3:GetAccelerateConfiguration" GetBucketAcl action = "s3:GetBucketAcl" GetBucketCORS action = "s3:GetBucketCORS" GetBucketLocation action = "s3:GetBucketLocation" GetBucketLogging action = "s3:GetBucketLogging" GetBucketNotification action = "s3:GetBucketNotification" GetBucketPolicy action = "s3:GetBucketPolicy" GetBucketRequestPayment action = "s3:GetBucketRequestPayment" GetBucketTagging action = "s3:GetBucketTagging" GetBucketVersioning action = "s3:GetBucketVersioning" GetBucketWebsite action = "s3:GetBucketWebsite" GetLifecycleConfiguration action = "s3:GetLifecycleConfiguration" GetObjectAcl action = "s3:GetObjectAcl" GetObject action = "s3:GetObject" GetObjectTorrent action = "s3:GetObjectTorrent" GetObjectVersionAcl action = "s3:GetObjectVersionAcl" GetObjectVersion action = "s3:GetObjectVersion" GetObjectVersionTorrent action = "s3:GetObjectVersionTorrent" GetReplicationConfiguration action = "s3:GetReplicationConfiguration" ListAllMyBuckets action = "s3:ListAllMyBuckets" ListBucketMultiPartUploads action = "s3:ListBucketMultiPartUploads" ListBucket action = "s3:ListBucket" ListBucketVersions action = "s3:ListBucketVersions" ListMultipartUploadParts action = "s3:ListMultipartUploadParts" PutAccelerateConfiguration action = "s3:PutAccelerateConfiguration" PutBucketAcl action = "s3:PutBucketAcl" PutBucketCORS action = "s3:PutBucketCORS" PutBucketLogging action = "s3:PutBucketLogging" PutBucketNotification action = "s3:PutBucketNotification" PutBucketPolicy action = "s3:PutBucketPolicy" PutBucketRequestPayment action = "s3:PutBucketRequestPayment" PutBucketTagging action = "s3:PutBucketTagging" PutBucketVersioning action = "s3:PutBucketVersioning" PutBucketWebsite action = "s3:PutBucketWebsite" PutLifecycleConfiguration action = "s3:PutLifecycleConfiguration" PutObjectAcl action = "s3:PutObjectAcl" PutObject action = "s3:PutObject" PutObjectVersionAcl action = "s3:PutObjectVersionAcl" PutReplicationConfiguration action = "s3:PutReplicationConfiguration" RestoreObject action = "s3:RestoreObject" )
Variables ¶
var AllowedActions = []action{ DeleteObject, DeleteObjectVersion, GetBucketAcl, GetBucketCORS, GetBucketLocation, GetBucketLogging, GetBucketNotification, GetBucketTagging, GetBucketVersioning, GetBucketWebsite, GetObject, GetObjectAcl, GetObjectTorrent, GetObjectVersion, GetObjectVersionAcl, GetObjectVersionTorrent, ListAllMyBuckets, ListBucket, ListBucketMultiPartUploads, ListBucketVersions, ListMultipartUploadParts, PutBucketTagging, PutBucketVersioning, PutBucketWebsite, PutBucketVersioning, PutLifecycleConfiguration, PutObject, PutObjectAcl, PutObjectVersionAcl, PutReplicationConfiguration, RestoreObject, }
AllowedActions is a lenient default list of actions
Functions ¶
This section is empty.
Types ¶
type BucketPolicy ¶
type BucketPolicy struct { // Id (optional) identifies the bucket policy Id string `json:"Id"` // Version is the version of the BucketPolicy data structure // should always be '2012-10-17' Version string `json:"Version"` Statement []PolicyStatement `json:"Statement"` }
BucketPolicy represents set of policy statements for a single bucket.
func NewBucketPolicy ¶
func NewBucketPolicy(ps ...PolicyStatement) *BucketPolicy
NewBucketPolicy obviously returns a new BucketPolicy. PolicyStatements may be passed in at creation or added after the fact. BucketPolicies should be passed to PutBucketPolicy().
func (*BucketPolicy) DropPolicyStatements ¶
func (bp *BucketPolicy) DropPolicyStatements(sid ...string) *BucketPolicy
func (*BucketPolicy) EjectPrincipals ¶
func (bp *BucketPolicy) EjectPrincipals(users ...string) *BucketPolicy
func (*BucketPolicy) ModifyBucketPolicy ¶
func (bp *BucketPolicy) ModifyBucketPolicy(ps ...PolicyStatement) *BucketPolicy
ModifyBucketPolicy new and old statement SIDs and overwrites on a match. This allows users to Get, modify, and Replace existing statements as well as add new ones.
type PolicyStatement ¶
type PolicyStatement struct { // Sid (optional) is the PolicyStatement's unique identifier Sid string `json:"Sid"` // Effect determines whether the Action(s) are 'Allow'ed or 'Deny'ed. Effect effect `json:"Effect"` // Principle is/are the Ceph user names affected by this PolicyStatement // Must be in the format of 'arn:aws:iam:::user/<ceph-user>' Principal map[string][]string `json:"Principal"` // Action is a list of s3:* actions Action []action `json:"Action"` // Resource is the ARN identifier for the S3 resource (bucket) // Must be in the format of 'arn:aws:s3:::<bucket>' Resource []string `json:"Resource"` }
PolicyStatment is the Go representation of a PolicyStatement json struct it defines what Actions that a Principle can or cannot perform on a Resource
func NewPolicyStatement ¶
func NewPolicyStatement() *PolicyStatement
NewPolicyStatement generates a new PolicyStatement. PolicyStatment methods are designed to be chain called with dot notation to allow for easy configuration at creation. This is preferable to a long parameter list.
func (*PolicyStatement) Actions ¶
func (ps *PolicyStatement) Actions(actions ...action) *PolicyStatement
Actions is the set of "s3:*" actions for the PolicyStatement is concerned
func (*PolicyStatement) Allows ¶
func (ps *PolicyStatement) Allows() *PolicyStatement
Allows sets the effect of the PolicyStatement to allow PolicyStatement's Actions
func (*PolicyStatement) Denies ¶
func (ps *PolicyStatement) Denies() *PolicyStatement
Denies sets the effect of the PolicyStatement to deny the PolicyStatement's Actions
func (*PolicyStatement) EjectPrincipals ¶
func (ps *PolicyStatement) EjectPrincipals(users ...string)
func (*PolicyStatement) ForPrincipals ¶
func (ps *PolicyStatement) ForPrincipals(users ...string) *PolicyStatement
ForPrincipals adds users to the PolicyStatement
func (*PolicyStatement) ForResources ¶
func (ps *PolicyStatement) ForResources(resources ...string) *PolicyStatement
ForResources adds resources (buckets) to the PolicyStatement with the appropriate ARN prefix
func (*PolicyStatement) ForSubResources ¶
func (ps *PolicyStatement) ForSubResources(resources ...string) *PolicyStatement
ForSubResources add contents inside the bucket to the PolicyStatement with the appropriate ARN prefix
func (*PolicyStatement) WithSID ¶
func (ps *PolicyStatement) WithSID(sid string) *PolicyStatement
type S3Agent ¶
S3Agent wraps the s3iface structure to allow for wrapper methods
func NewS3Agent ¶
func (*S3Agent) CreateBucket ¶
CreateBucket creates a bucket with the given name
func (*S3Agent) CreateBucketNoInfoLogging ¶
CreateBucket creates a bucket with the given name
func (*S3Agent) DeleteBucket ¶
DeleteBucket function deletes given bucket using s3 client
func (*S3Agent) DeleteObjectInBucket ¶
DeleteObjectInBucket function deletes given bucket using s3 client
func (*S3Agent) GetBucketPolicy ¶
func (s *S3Agent) GetBucketPolicy(bucket string) (*BucketPolicy, error)
func (*S3Agent) GetObjectInBucket ¶
GetObjectInBucket function retrieves an object from a bucket using s3 client
func (*S3Agent) PutBucketPolicy ¶
func (s *S3Agent) PutBucketPolicy(bucket string, policy BucketPolicy) (*s3.PutBucketPolicyOutput, error)
PutBucketPolicy applies the policy to the bucket