Documentation ¶
Index ¶
- type Effect
- type ID
- type Policy
- func CreateAnonReadOnlyBucketPolicy(bucketName string) *Policy
- func CreateAnonReadOnlyObjectPolicy(bucketName, prefix string) *Policy
- func CreateAnonWriteOnlyBucketPolicy(bucketName string) *Policy
- func CreateAnonWriteOnlyObjectPolicy(bucketName, prefix string) *Policy
- func CreateUserBucketPolicy(bucketName, accessKey string) *Policy
- func CreateUserPolicy(accessKey string, actions []s3action.Action, bucketName string) *Policy
- func ParseConfig(reader io.Reader, bucketName string) (*Policy, error)
- type PolicyDocument
- type Principal
- func (p Principal) Clone() Principal
- func (p Principal) Equals(pp Principal) bool
- func (p Principal) Intersection(principal Principal) set.StringSet
- func (p Principal) IsValid() bool
- func (p Principal) MarshalJSON() ([]byte, error)
- func (p Principal) MarshalMsgpack() ([]byte, error)
- func (p Principal) Match(principal string) bool
- func (p *Principal) UnmarshalJSON(data []byte) error
- func (p *Principal) UnmarshalMsgpack(data []byte) error
- type Resource
- func (r Resource) IsValid() bool
- func (r Resource) MarshalJSON() ([]byte, error)
- func (r Resource) MarshalMsgpack() ([]byte, error)
- func (r Resource) Match(resource string, conditionValues map[string][]string) bool
- func (r Resource) String() string
- func (r *Resource) UnmarshalJSON(data []byte) error
- func (r *Resource) UnmarshalMsgpack(data []byte) error
- func (r Resource) Validate(bucketName string) error
- type ResourceSet
- func (resourceSet ResourceSet) Add(resource Resource)
- func (resourceSet ResourceSet) BucketResourceExists() bool
- func (resourceSet ResourceSet) Clone() ResourceSet
- func (resourceSet ResourceSet) Contains(resource Resource) bool
- func (resourceSet ResourceSet) Equals(sresourceSet ResourceSet) bool
- func (resourceSet ResourceSet) IsEmpty() bool
- func (resourceSet ResourceSet) MarshalJSON() ([]byte, error)
- func (resourceSet ResourceSet) MarshalMsgpack() ([]byte, error)
- func (resourceSet ResourceSet) Match(resource string, conditionValues map[string][]string) bool
- func (resourceSet ResourceSet) ObjectResourceExists() bool
- func (resourceSet ResourceSet) String() string
- func (resourceSet ResourceSet) ToSlice() []Resource
- func (resourceSet *ResourceSet) UnmarshalJSON(data []byte) error
- func (resourceSet *ResourceSet) UnmarshalMsgpack(data []byte) error
- func (resourceSet ResourceSet) Validate(bucketName string) error
- type Statement
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Effect ¶
type Effect string
Effect - policy statement effect Allow or Deny.
const ( // Allow - allow effect. Allow Effect = "Allow" // Deny - deny effect. Deny = "Deny" )
type Policy ¶
Policy - iam bucket iamp.
func CreateAnonReadOnlyBucketPolicy ¶
CreateAnonReadOnlyBucketPolicy creates a bucket policy for anonymous read-only access
func CreateAnonReadOnlyObjectPolicy ¶
CreateAnonReadOnlyObjectPolicy - create a policy for anonymous read only access to an object
func CreateAnonWriteOnlyBucketPolicy ¶
CreateAnonWriteOnlyBucketPolicy creates a policy that allows anonymous users to write to a bucket
func CreateAnonWriteOnlyObjectPolicy ¶
CreateAnonWriteOnlyObjectPolicy creates a policy that allows anonymous users to upload objects to a bucket
func CreateUserBucketPolicy ¶
CreateUserBucketPolicy create user policy according accessKey and bucket
func CreateUserPolicy ¶
CreateUserPolicy create user policy according action and bucket
func ParseConfig ¶
ParseConfig - parses data in given reader to Policy.
func (*Policy) IsAllowed ¶
IsAllowed - checks given policy args is allowed to continue the Rest API.
func (*Policy) UnmarshalJSON ¶
UnmarshalJSON - decodes JSON data to Iamp.
type PolicyDocument ¶
type PolicyDocument struct { Version string `json:"Version"` Statement []Statement `json:"Statement"` }
PolicyDocument policy document
func (*PolicyDocument) Merge ¶
func (p *PolicyDocument) Merge(input PolicyDocument) PolicyDocument
Merge merges two policies documents and drop duplicate statements if any.
func (*PolicyDocument) String ¶
func (p *PolicyDocument) String() string
type Principal ¶
Principal - policy principal.
"Principal": { "AWS": [ "arn:aws:iam::123456789012:root", "999999999999", "CanonicalUser": "79a59df900b949e55d96a1e698fbacedfd6e09d98eacf8f8d5218e7cd47ef2be" ] }
The user, service, or account that receives permissions that are defined in a policy. The principal is A in the statement "A has permission to do B to C."
func NewPrincipal ¶
NewPrincipal - creates new Principal.
func (Principal) Intersection ¶
Intersection - returns principals available in both Principal.
func (Principal) MarshalJSON ¶
MarshalJSON - encodes Principal to JSON data.
func (Principal) MarshalMsgpack ¶
func (*Principal) UnmarshalJSON ¶
UnmarshalJSON - decodes JSON data to Principal.
func (*Principal) UnmarshalMsgpack ¶
type Resource ¶
The Resource element specifies the object or objects that the statement covers. Statements must include either a Resource or a NotResource element. An entity that users can work with in AWS, such as an EC2 instance, an Amazon DynamoDB table, an Amazon S3 bucket, an IAM user, or an AWS OpsWorks stack. Resource - resource in policy statement. "Resource": "arn:aws:iam::account-ID-without-hyphens:user/accounting/*"
func NewResource ¶
NewResource - creates new resource.
func (Resource) MarshalJSON ¶
MarshalJSON - encodes Resource to JSON data.
func (Resource) MarshalMsgpack ¶
func (Resource) Match ¶
Match - matches object name with resource pattern, including specific conditionals.
func (*Resource) UnmarshalJSON ¶
UnmarshalJSON - decodes JSON data to Resource.
func (*Resource) UnmarshalMsgpack ¶
type ResourceSet ¶
type ResourceSet map[Resource]struct{}
ResourceSet - set of resources in policy statement.
func NewResourceSet ¶
func NewResourceSet(resources ...Resource) ResourceSet
NewResourceSet - creates new resource set.
func (ResourceSet) Add ¶
func (resourceSet ResourceSet) Add(resource Resource)
Add - adds resource to resource set.
func (ResourceSet) BucketResourceExists ¶
func (resourceSet ResourceSet) BucketResourceExists() bool
BucketResourceExists - checks if at least one bucket resource exists in the set.
func (ResourceSet) Clone ¶
func (resourceSet ResourceSet) Clone() ResourceSet
Clone clones ResourceSet structure
func (ResourceSet) Contains ¶
func (resourceSet ResourceSet) Contains(resource Resource) bool
Contains - checks if string is in the set.
func (ResourceSet) Equals ¶
func (resourceSet ResourceSet) Equals(sresourceSet ResourceSet) bool
Equals - checks whether given resource set is equal to current resource set or not.
func (ResourceSet) IsEmpty ¶
func (resourceSet ResourceSet) IsEmpty() bool
IsEmpty - returns whether the set is empty or not.
func (ResourceSet) MarshalJSON ¶
func (resourceSet ResourceSet) MarshalJSON() ([]byte, error)
MarshalJSON - encodes ResourceSet to JSON data.
func (ResourceSet) MarshalMsgpack ¶
func (resourceSet ResourceSet) MarshalMsgpack() ([]byte, error)
func (ResourceSet) Match ¶
func (resourceSet ResourceSet) Match(resource string, conditionValues map[string][]string) bool
Match - matches object name with anyone of resource pattern in resource set.
func (ResourceSet) ObjectResourceExists ¶
func (resourceSet ResourceSet) ObjectResourceExists() bool
ObjectResourceExists - checks if at least one object resource exists in the set.
func (ResourceSet) String ¶
func (resourceSet ResourceSet) String() string
func (ResourceSet) ToSlice ¶
func (resourceSet ResourceSet) ToSlice() []Resource
ToSlice - returns slice of resources from the resource set.
func (*ResourceSet) UnmarshalJSON ¶
func (resourceSet *ResourceSet) UnmarshalJSON(data []byte) error
UnmarshalJSON - decodes JSON data to ResourceSet.
func (*ResourceSet) UnmarshalMsgpack ¶
func (resourceSet *ResourceSet) UnmarshalMsgpack(data []byte) error
func (ResourceSet) Validate ¶
func (resourceSet ResourceSet) Validate(bucketName string) error
Validate - validates ResourceSet is for given bucket or not.
type Statement ¶
type Statement struct { SID ID `json:"Sid"` Effect Effect `json:"Effect"` Principal Principal `json:"Principal"` Actions s3action.ActionSet `json:"Action"` Resources ResourceSet `json:"Resource"` Conditions condition.Conditions `json:"Condition,omitempty"` }
Statement { "Version": "2012-10-17", "Statement": [ { "Sid": "Only allow writes to my bucket with bucket owner full control", "Effect": "Allow", "Principal": { "AWS": [ "arn:aws:iam::111122223333:user/ExampleUser" ] }, "Action": [ "s3:PutObject" ], "Resource": "arn:aws:s3:::DOC-EXAMPLE-BUCKET/*", "Conditions": { "StringEquals": { "s3:x-amz-acl": "bucket-owner-full-control" } } } ]
func NewStatement ¶
func NewStatement(sid ID, effect Effect, principal Principal, actionSet s3action.ActionSet, resourceSet ResourceSet, conditions condition.Conditions) Statement
NewStatement - creates new statement.
func (Statement) IsAllowed ¶
IsAllowed - checks given policy args is allowed to continue the Rest API.