Documentation
¶
Index ¶
Constants ¶
const ( // AWS IAM variables VarUsername = "aws:username" // Current authenticated username VarUserID = "aws:userid" // Current authenticated user UUID VarSourceIP = "aws:SourceIp" // Request source IP address VarCurrentTime = "aws:CurrentTime" // Current timestamp (ISO 8601) VarUserAgent = "aws:UserAgent" // HTTP User-Agent header // S3-specific variables VarS3Prefix = "s3:prefix" // Object key prefix for ListObjects VarS3Delimiter = "s3:delimiter" // Delimiter for ListObjects )
Variable names supported by the policy engine
Variables ¶
This section is empty.
Functions ¶
func ExtractVariables ¶
ExtractVariables returns a list of all variable names found in the input string
func HasVariables ¶
HasVariables returns true if the input string contains any ${...} variable patterns
Types ¶
type Context ¶
type Context struct {
// User identity
Username string
UserID uuid.UUID
// Request metadata
SourceIP net.IP
CurrentTime time.Time
UserAgent string
// S3-specific context
S3Prefix string
S3Delimiter string
}
Context holds values for variable substitution during policy evaluation
func ForUser ¶
ForUser creates a minimal variable context for a specific user Useful when you have user info but no HTTP request
func ForUserSimple ¶
ForUserSimple creates a context from basic user info (username and UUID)
func FromRequest ¶
FromRequest builds a variable context from an HTTP request It extracts user identity, request metadata, and prepares for S3-specific context
func Minimal ¶
func Minimal() *Context
Minimal creates a context with only current time Useful for anonymous requests or when user info isn't available
func (*Context) Substitute ¶
Substitute replaces all ${variable} patterns in the input string with their values from the context. Returns the substituted string and any error encountered.
Examples:
- "arn:aws:s3:::bucket/${aws:username}/*" → "arn:aws:s3:::bucket/alice/*"
- "prefix/${aws:userid}/data" → "prefix/550e8400-e29b-41d4-a716-446655440000/data"
func (*Context) SubstituteInterface ¶
SubstituteInterface handles substitution for interface{} values (string or []string) This is useful for Resource and Action fields in policy statements which can be either type
func (*Context) SubstituteSlice ¶
SubstituteSlice applies substitution to all strings in a slice
func (*Context) WithS3Context ¶
WithS3Context adds S3-specific variables (prefix, delimiter) to the context This should be called when evaluating policies for ListObjects operations