Documentation
¶
Index ¶
- func ExtractAccessKeyID(r *http.Request) (string, error)
- func WildcardMatch(pattern, value string) bool
- type AccessKey
- type Decision
- type Engine
- type EvalRequest
- type EvalResult
- type Policy
- type Statement
- type Store
- func (s *Store) AttachUserPolicy(userName, policyName string, policy *Policy) error
- func (s *Store) CreateAccessKey(userName string) (*AccessKey, error)
- func (s *Store) CreateUser(name string) (*User, error)
- func (s *Store) GetUser(name string) (*User, error)
- func (s *Store) GetUserPolicies(userName string) ([]*Policy, error)
- func (s *Store) InitRoot(accessKeyID, secretKey string) error
- func (s *Store) LookupAccessKey(accessKeyID string) (*AccessKey, error)
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractAccessKeyID ¶
ExtractAccessKeyID parses the AWS SigV4 Authorization header from the request and returns the access key ID embedded in the Credential field.
Expected header format:
AWS4-HMAC-SHA256 Credential=<AKID>/<date>/<region>/<service>/aws4_request, ...
func WildcardMatch ¶
WildcardMatch reports whether value matches pattern. Supported wildcards:
- '*' matches any sequence of characters (including empty)
- '?' matches any single character
Types ¶
type AccessKey ¶
type AccessKey struct {
AccessKeyID string
SecretAccessKey string
UserName string
AccountID string
IsRoot bool
}
AccessKey represents an IAM access key and its associated identity.
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine evaluates IAM policies for principals using AWS IAM semantics.
func (*Engine) AddPolicy ¶
AddPolicy attaches a policy to a principal. Multiple policies may be added for the same principal; they are evaluated together.
func (*Engine) Evaluate ¶
func (e *Engine) Evaluate(req *EvalRequest) *EvalResult
Evaluate applies AWS IAM evaluation logic to the given request:
- Root is always allowed.
- Collect all statements whose Action and Resource match the request.
- If any matching statement has Effect "Deny" → explicit Deny.
- If any matching statement has Effect "Allow" → Allow.
- Otherwise → implicit Deny.
func (*Engine) RemovePolicies ¶
RemovePolicies removes all policies for a principal.
type EvalRequest ¶
EvalRequest contains the input parameters for a policy evaluation.
type EvalResult ¶
EvalResult holds the outcome of an Evaluate call.
type Statement ¶
type Statement struct {
SID string `json:"Sid,omitempty"`
Effect string `json:"Effect"` // "Allow" or "Deny"
Actions []string `json:"Action"`
Resources []string `json:"Resource"`
Conditions map[string]map[string]string `json:"Condition,omitempty"`
}
Statement is a single IAM policy statement.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store holds IAM users and access keys for a single AWS account.
func (*Store) AttachUserPolicy ¶
AttachUserPolicy attaches a named policy to the given user.
func (*Store) CreateAccessKey ¶
CreateAccessKey generates a new access key for the named user.
func (*Store) CreateUser ¶
CreateUser creates a new IAM user with the given name.
func (*Store) GetUserPolicies ¶
GetUserPolicies returns all policies attached to the named user.