Documentation
¶
Index ¶
- Constants
- Variables
- func AppendSubstitute(dst []byte, pattern string, values map[string][]string, escape bool) []byte
- func Substitute(pattern string, values map[string][]string, escape bool) string
- type Function
- func NewBinaryEqualsFunc(qualifier string, key Key, values ...string) (Function, error)
- func NewBoolFunc(key Key, value bool) (Function, error)
- func NewDateEqualsFunc(key Key, value time.Time) (Function, error)
- func NewDateGreaterThanEqualsFunc(key Key, value time.Time) (Function, error)
- func NewDateGreaterThanFunc(key Key, value time.Time) (Function, error)
- func NewDateLessThanEqualsFunc(key Key, value time.Time) (Function, error)
- func NewDateLessThanFunc(key Key, value time.Time) (Function, error)
- func NewDateNotEqualsFunc(key Key, value time.Time) (Function, error)
- func NewIPAddressFunc(key Key, IPNets ...*net.IPNet) (Function, error)
- func NewNotIPAddressFunc(key Key, IPNets ...*net.IPNet) (Function, error)
- func NewNullFunc(key Key, value bool) (Function, error)
- func NewNumericEqualsFunc(key Key, value int) (Function, error)
- func NewNumericGreaterThanEqualsFunc(key Key, value int) (Function, error)
- func NewNumericGreaterThanFunc(key Key, value int) (Function, error)
- func NewNumericGreaterThanIfExistsFunc(key Key, value int) (Function, error)
- func NewNumericLessThanEqualsFunc(key Key, value int) (Function, error)
- func NewNumericLessThanFunc(key Key, value int) (Function, error)
- func NewNumericNotEqualsFunc(key Key, value int) (Function, error)
- func NewStringEqualsFunc(qualifier string, key Key, values ...string) (Function, error)
- func NewStringEqualsIgnoreCaseFunc(qualifier string, key Key, values ...string) (Function, error)
- func NewStringLikeFunc(qualifier string, key Key, values ...string) (Function, error)
- func NewStringNotEqualsFunc(qualifier string, key Key, values ...string) (Function, error)
- func NewStringNotEqualsIgnoreCaseFunc(qualifier string, key Key, values ...string) (Function, error)
- func NewStringNotLikeFunc(qualifier string, key Key, values ...string) (Function, error)
- type Functions
- func (functions Functions) CheckVariables() error
- func (functions Functions) Clone() Functions
- func (functions Functions) Equals(funcs Functions) bool
- func (functions Functions) Evaluate(values map[string][]string) bool
- func (functions *Functions) GobDecode(data []byte) error
- func (functions Functions) GobEncode() ([]byte, error)
- func (functions Functions) Keys() KeySet
- func (functions Functions) MarshalJSON() ([]byte, error)
- func (functions Functions) String() string
- func (functions *Functions) UnmarshalJSON(data []byte) error
- func (functions Functions) VariablesAllowed() bool
- type Key
- type KeyName
- type KeySet
- type Value
- func (v Value) GetBool() (bool, error)
- func (v Value) GetInt() (int, error)
- func (v Value) GetString() (string, error)
- func (v Value) GetType() reflect.Kind
- func (v Value) MarshalJSON() ([]byte, error)
- func (v *Value) StoreBool(b bool)
- func (v *Value) StoreInt(i int)
- func (v *Value) StoreString(s string)
- func (v Value) String() string
- func (v *Value) UnmarshalJSON(data []byte) error
- type ValueSet
Constants ¶
const ( // VarAsterisk expands to a literal '*'. VarAsterisk = "${*}" // VarQuestion expands to a literal '?'. VarQuestion = "${?}" // VarDollar expands to a literal '$'. VarDollar = "${$}" )
Predefined policy variables, each expanding to one literal character. A policy uses them where it needs the character itself rather than a wildcard or the start of a variable.
Variables ¶
var AdminActionKeys = []KeyName{ AdminPolicyName, }
AdminActionKeys are the condition keys that describe what one kind of admin action works on, such as the policy it names. The policy package lists which actions take each of them.
var AllSupportedAdminKeys = append(append([]KeyName{}, CommonAdminKeys...), AdminActionKeys...)
AllSupportedAdminKeys - is list of all admin supported keys.
var AllSupportedKeys = []KeyName{ S3SignatureVersion, S3AuthType, S3SignatureAge, S3XAmzCopySource, S3XAmzServerSideEncryption, S3XAmzServerSideEncryptionCustomerAlgorithm, S3XAmzMetadataDirective, S3XAmzStorageClass, S3XAmzServerSideEncryptionAwsKmsKeyID, S3XAmzObjectIfMatch, S3XAmzAnnotationDirective, S3XAmzContentSha256, S3LocationConstraint, S3Prefix, S3Delimiter, S3MaxKeys, MemoryPrefix, MemoryMaxKeys, S3VersionID, S3ObjectLockRemainingRetentionDays, S3ObjectLockMode, S3ObjectLockLegalHold, S3ObjectLockRetainUntilDate, S3TablesKMSKeyArn, S3TablesSSEAlgorithm, S3TablesNamespace, S3TablesTableName, S3TablesViewName, S3TablesFunctionName, S3TablesRegisterLocation, S3TablesWarehouseTag, S3TablesTableTag, AWSReferer, AWSSourceIP, AWSUserAgent, AWSSecureTransport, AWSCurrentTime, AWSEpochTime, AWSPrincipalType, AWSUserID, AWSUsername, AWSGroups, AWSSourceIdentity, LDAPUser, LDAPUsername, LDAPGroups, RequestObjectTag, ExistingObjectTag, RequestObjectTagKeys, JWTSub, JWTIss, JWTAud, JWTJti, JWTName, JWTUpn, JWTGroups, JWTGivenName, JWTFamilyName, JWTMiddleName, JWTNickName, JWTPrefUsername, JWTProfile, JWTPicture, JWTWebsite, JWTEmail, JWTGender, JWTBirthdate, JWTPhoneNumber, JWTAddress, JWTScope, JWTClientID, STSDurationSeconds, STSSourceIdentity, SVCDurationSeconds, AdminPolicyName, }
AllSupportedKeys - is list of all all supported keys.
var AllSupportedSTSKeys = []KeyName{ AWSPrincipalType, AWSSecureTransport, STSDurationSeconds, STSSourceIdentity, AWSSourceIdentity, LDAPUser, AWSUserID, AWSGroups, LDAPGroups, LDAPUsername, AWSUsername, }
AllSupportedSTSKeys is the all supported conditions for STS policies
var CommonAdminKeys = append([]KeyName{ AWSReferer, AWSSourceIP, AWSUserAgent, AWSSecureTransport, AWSCurrentTime, AWSEpochTime, AWSPrincipalType, AWSUserID, AWSUsername, AWSGroups, AWSSourceIdentity, LDAPUser, LDAPUsername, LDAPGroups, SVCDurationSeconds, }, JWTKeys...)
CommonAdminKeys are the condition keys every admin action takes: they describe the request and its principal, not what the action works on.
var CommonKeys = append([]KeyName{ S3SignatureVersion, S3AuthType, S3SignatureAge, S3XAmzContentSha256, S3LocationConstraint, S3ExpressSessionMode, AWSReferer, AWSSourceIP, AWSUserAgent, AWSSecureTransport, AWSCurrentTime, AWSEpochTime, AWSPrincipalType, AWSUserID, AWSUsername, AWSGroups, AWSSourceIdentity, LDAPUser, LDAPUsername, LDAPGroups, }, JWTKeys...)
CommonKeys - is list of all common condition keys.
var CommonKeysMap map[KeyName]bool
CommonKeysMap is a lookup of CommonKeys.
var JWTKeys = []KeyName{ JWTSub, JWTIss, JWTAud, JWTJti, JWTName, JWTUpn, JWTGroups, JWTGivenName, JWTFamilyName, JWTMiddleName, JWTNickName, JWTPrefUsername, JWTProfile, JWTPicture, JWTWebsite, JWTEmail, JWTGender, JWTBirthdate, JWTPhoneNumber, JWTAddress, JWTScope, JWTClientID, }
JWTKeys - Supported JWT keys, non-exhaustive list please expand as new claims are standardized.
var Names = map[string]struct{}{ // contains filtered or unexported fields }
Names - list of all supported condition names.
var Qualifiers = map[string]struct{}{ // contains filtered or unexported fields }
Qualifiers - list of all supported condition qualifiers.
Functions ¶
func AppendSubstitute ¶
AppendSubstitute is Substitute that appends the result to dst, so a caller whose result stays local can expand without allocating.
func Substitute ¶
Substitute expands the policy variables in pattern using the request's condition values. A variable that is unknown or carries no value is left as written. An expanded value is never scanned for further variables.
The escapes ${*}, ${?} and ${$} expand to a literal character. Set escape to match the result with wildcard.MatchEscaped. Leave it unset to compare the result as text.
Types ¶
type Function ¶
type Function interface {
// String() - returns string representation of function.
String() string
// contains filtered or unexported methods
}
Function - condition function interface.
func NewBinaryEqualsFunc ¶
NewBinaryEqualsFunc - returns new BinaryEquals function.
func NewBoolFunc ¶
NewBoolFunc - returns new Bool function.
func NewDateEqualsFunc ¶
NewDateEqualsFunc - returns new DateEquals function.
func NewDateGreaterThanEqualsFunc ¶
NewDateGreaterThanEqualsFunc - returns new DateGreaterThanEquals function.
func NewDateGreaterThanFunc ¶
NewDateGreaterThanFunc - returns new DateGreaterThan function.
func NewDateLessThanEqualsFunc ¶
NewDateLessThanEqualsFunc - returns new DateLessThanEquals function.
func NewDateLessThanFunc ¶
NewDateLessThanFunc - returns new DateLessThan function.
func NewDateNotEqualsFunc ¶
NewDateNotEqualsFunc - returns new DateNotEquals function.
func NewIPAddressFunc ¶
NewIPAddressFunc - returns new IP address function.
func NewNotIPAddressFunc ¶
NewNotIPAddressFunc - returns new Not IP address function.
func NewNullFunc ¶
NewNullFunc - returns new Null function.
func NewNumericEqualsFunc ¶
NewNumericEqualsFunc - returns new NumericEquals function.
func NewNumericGreaterThanEqualsFunc ¶
NewNumericGreaterThanEqualsFunc - returns new NumericGreaterThanEquals function.
func NewNumericGreaterThanFunc ¶
NewNumericGreaterThanFunc - returns new NumericGreaterThan function.
func NewNumericGreaterThanIfExistsFunc ¶
NewNumericGreaterThanIfExistsFunc - returns new NumericGreaterThanIfExists function.
func NewNumericLessThanEqualsFunc ¶
NewNumericLessThanEqualsFunc - returns new NumericLessThanEquals function.
func NewNumericLessThanFunc ¶
NewNumericLessThanFunc - returns new NumericLessThan function.
func NewNumericNotEqualsFunc ¶
NewNumericNotEqualsFunc - returns new NumericNotEquals function.
func NewStringEqualsFunc ¶
NewStringEqualsFunc - returns new StringEquals function.
func NewStringEqualsIgnoreCaseFunc ¶
NewStringEqualsIgnoreCaseFunc - returns new StringEqualsIgnoreCase function.
func NewStringLikeFunc ¶
NewStringLikeFunc - returns new StringLike function.
func NewStringNotEqualsFunc ¶
NewStringNotEqualsFunc - returns new StringNotEquals function.
type Functions ¶
type Functions []Function
Functions - list of functions.
func NewFunctions ¶
NewFunctions - returns new Functions with given function list.
func (Functions) CheckVariables ¶
CheckVariables refuses a condition key carrying a /<variable> suffix its name does not take: only the tag keys, such as s3:ExistingObjectTag/<tag>, take one.
func (Functions) Evaluate ¶
Evaluate - evaluates all functions with given values map. Each function is evaluated sequencely and next function is called only if current function succeeds.
func (Functions) MarshalJSON ¶
MarshalJSON - encodes Functions to JSON data.
func (*Functions) UnmarshalJSON ¶
UnmarshalJSON - decodes JSON data to Functions.
func (Functions) VariablesAllowed ¶
VariablesAllowed reports whether every key in functions carries only a suffix it takes.
type Key ¶
type Key struct {
// contains filtered or unexported fields
}
Key - conditional key whose name and it's optional variable.
func (Key) MarshalJSON ¶
MarshalJSON - encodes Key to JSON data.
func (*Key) UnmarshalJSON ¶
UnmarshalJSON - decodes JSON data to Key.
func (Key) VariableAllowed ¶
VariableAllowed reports whether key's /<variable> suffix, if any, is one its name takes. A policy naming a key with a suffix it does not take is refused, and such a key evaluates with no value.
type KeyName ¶
type KeyName string
KeyName - conditional key which is used to fetch values for any condition. Refer https://docs.aws.amazon.com/IAM/latest/UserGuide/list_s3.html for more information about available condition keys.
const ( // S3TablesKMSKeyArn filters access by the AWS KMS key ARN used for S3 Tables encryption. S3TablesKMSKeyArn KeyName = "s3tables:KMSKeyArn" // S3TablesSSEAlgorithm filters access by the server-side encryption algorithm for S3 Tables. S3TablesSSEAlgorithm KeyName = "s3tables:SSEAlgorithm" // S3TablesNamespace filters access by the namespace within an S3 Tables bucket. S3TablesNamespace KeyName = "s3tables:namespace" // S3TablesTableName filters access by the S3 Tables table name within a namespace. S3TablesTableName KeyName = "s3tables:tableName" // S3TablesViewName filters access by the S3 Tables view name within a namespace. S3TablesViewName KeyName = "s3tables:viewName" // S3TablesFunctionName filters access by the S3 Tables function name within a namespace. S3TablesFunctionName KeyName = "s3tables:functionName" // S3TablesRegisterLocation filters access by the metadata location for table/view registration. S3TablesRegisterLocation KeyName = "s3tables:registerLocation" // S3TablesWarehouseTag filters access by tags on the table warehouse. S3TablesWarehouseTag KeyName = "s3tables:WarehouseTag" // S3TablesTableTag filters access by tags on the table. S3TablesTableTag KeyName = "s3tables:TableTag" // S3XAmzCopySource - key representing x-amz-copy-source HTTP header applicable to PutObject API only. S3XAmzCopySource KeyName = "s3:x-amz-copy-source" // S3XAmzServerSideEncryption - key representing x-amz-server-side-encryption HTTP header applicable // to PutObject API only. S3XAmzServerSideEncryption KeyName = "s3:x-amz-server-side-encryption" // S3XAmzServerSideEncryptionCustomerAlgorithm - key representing // x-amz-server-side-encryption-customer-algorithm HTTP header applicable to PutObject API only. S3XAmzServerSideEncryptionCustomerAlgorithm KeyName = "s3:x-amz-server-side-encryption-customer-algorithm" // S3XAmzMetadataDirective - key representing x-amz-metadata-directive HTTP header applicable to // PutObject API only. S3XAmzMetadataDirective KeyName = "s3:x-amz-metadata-directive" // S3XAmzContentSha256 - set a static content-sha256 for all calls for a given action. S3XAmzContentSha256 KeyName = "s3:x-amz-content-sha256" // S3XAmzStorageClass - key representing x-amz-storage-class HTTP header applicable to PutObject API // only. S3XAmzStorageClass KeyName = "s3:x-amz-storage-class" // S3XAmzServerSideEncryptionAwsKmsKeyID - key representing x-amz-server-side-encryption-aws-kms-key-id // HTTP header for S3 API calls S3XAmzServerSideEncryptionAwsKmsKeyID KeyName = "s3:x-amz-server-side-encryption-aws-kms-key-id" // S3XAmzObjectIfMatch - key representing the x-amz-object-if-match HTTP header used by the // object annotation APIs (PutObjectAnnotation/DeleteObjectAnnotation) for optimistic concurrency. S3XAmzObjectIfMatch KeyName = "s3:x-amz-object-if-match" // S3XAmzAnnotationDirective - key representing the x-amz-annotation-directive HTTP header // of CopyObject, which controls whether annotations are copied (COPY) or excluded (EXCLUDE). S3XAmzAnnotationDirective KeyName = "s3:x-amz-annotation-directive" // S3LocationConstraint - key representing LocationConstraint XML tag of CreateBucket API only. S3LocationConstraint KeyName = "s3:LocationConstraint" // S3Prefix - key representing prefix query parameter of ListBucket API only. S3Prefix KeyName = "s3:prefix" // S3Delimiter - key representing delimiter query parameter of ListBucket API only. S3Delimiter KeyName = "s3:delimiter" // MemoryPrefix - key representing the prefix query parameter of the AIStor // Memory list and search APIs. It scopes enumeration within a cortex, which // a resource ARN cannot express: a list names a query, not a record, so // putting the prefix in the resource path would make one ARN mean a single // record under a read action and a set of siblings under a list action. // // memory:Search takes it for the same reason and depends on it more, since // search returns object content: without the key its grant has only two // states, none or the whole cortex. MemoryPrefix KeyName = "memory:prefix" // MemoryMaxKeys - key representing the limit query parameter of the AIStor // Memory list APIs only. It caps a single page, bounding what one request // can enumerate. MemoryMaxKeys KeyName = "memory:max-keys" // S3VersionID - Enables you to limit the permission for the // s3:PutObjectVersionTagging action to a specific object version. S3VersionID KeyName = "s3:versionid" // S3MaxKeys - key representing max-keys query parameter of ListBucket API only. S3MaxKeys KeyName = "s3:max-keys" // S3ObjectLockRemainingRetentionDays - key representing object-lock-remaining-retention-days // Enables enforcement of an object relative to the remaining retention days, you can set // minimum and maximum allowable retention periods for a bucket using a bucket policy. // This key are specific for s3:PutObjectRetention API. S3ObjectLockRemainingRetentionDays KeyName = "s3:object-lock-remaining-retention-days" // S3ObjectLockMode - key representing object-lock-mode // Enables enforcement of the specified object retention mode S3ObjectLockMode KeyName = "s3:object-lock-mode" // S3ObjectLockRetainUntilDate - key representing object-lock-retain-util-date // Enables enforcement of a specific retain-until-date S3ObjectLockRetainUntilDate KeyName = "s3:object-lock-retain-until-date" // S3ObjectLockLegalHold - key representing object-local-legal-hold // Enables enforcement of the specified object legal hold status S3ObjectLockLegalHold KeyName = "s3:object-lock-legal-hold" // AWSReferer - key representing Referer header of any API. AWSReferer KeyName = "aws:Referer" // AWSSourceIP - key representing client's IP address (not intermittent proxies) of any API. AWSSourceIP KeyName = "aws:SourceIp" // AWSUserAgent - key representing UserAgent header for any API. AWSUserAgent KeyName = "aws:UserAgent" // AWSSecureTransport - key representing if the clients request is authenticated or not. AWSSecureTransport KeyName = "aws:SecureTransport" // AWSCurrentTime - key representing the current time. AWSCurrentTime KeyName = "aws:CurrentTime" // AWSEpochTime - key representing the current epoch time. AWSEpochTime KeyName = "aws:EpochTime" // AWSPrincipalType - user principal type currently supported values are "User" and "Anonymous". AWSPrincipalType KeyName = "aws:principaltype" // AWSUserID - user unique ID, in MinIO this value is same as your user Access Key. AWSUserID KeyName = "aws:userid" // AWSUsername - user friendly name, in MinIO this value is same as your user Access Key. AWSUsername KeyName = "aws:username" // AWSGroups - groups for any authenticating Access Key. AWSGroups KeyName = "aws:groups" // AWSSourceIdentity - the source identity of the session that signed the // request, set when the session was assumed and fixed for its lifetime. AWSSourceIdentity KeyName = "aws:SourceIdentity" // S3SignatureVersion - identifies the version of AWS Signature that you want to support for authenticated requests. S3SignatureVersion KeyName = "s3:signatureversion" // S3SignatureAge - identifies the maximum age of presgiend URL allowed S3SignatureAge KeyName = "s3:signatureAge" // S3AuthType - optionally use this condition key to restrict incoming requests to use a specific authentication method. S3AuthType KeyName = "s3:authType" // S3ExpressSessionMode - optionally use this condition key to control who can create a ReadWrite or ReadOnly session. S3ExpressSessionMode = "s3express:SessionMode" // Refer https://docs.aws.amazon.com/AmazonS3/latest/userguide/tagging-and-policies.html ExistingObjectTag KeyName = "s3:ExistingObjectTag" RequestObjectTagKeys KeyName = "s3:RequestObjectTagKeys" RequestObjectTag KeyName = "s3:RequestObjectTag" )
Condition key names.
const ( // JWTSub - JWT subject claim substitution. JWTSub KeyName = "jwt:sub" // JWTIss issuer claim substitution. JWTIss KeyName = "jwt:iss" // JWTAud audience claim substitution. JWTAud KeyName = "jwt:aud" // JWTJti JWT unique identifier claim substitution. JWTJti KeyName = "jwt:jti" JWTUpn KeyName = "jwt:upn" JWTName KeyName = "jwt:name" JWTGroups KeyName = "jwt:groups" JWTGivenName KeyName = "jwt:given_name" JWTFamilyName KeyName = "jwt:family_name" JWTMiddleName KeyName = "jwt:middle_name" JWTNickName KeyName = "jwt:nickname" JWTPrefUsername KeyName = "jwt:preferred_username" JWTProfile KeyName = "jwt:profile" JWTPicture KeyName = "jwt:picture" JWTWebsite KeyName = "jwt:website" JWTEmail KeyName = "jwt:email" JWTGender KeyName = "jwt:gender" JWTBirthdate KeyName = "jwt:birthdate" JWTPhoneNumber KeyName = "jwt:phone_number" JWTAddress KeyName = "jwt:address" JWTScope KeyName = "jwt:scope" JWTClientID KeyName = "jwt:client_id" )
JWT claims supported substitutions. https://www.iana.org/assignments/jwt/jwt.xhtml#claims
const ( // LDAPUser - LDAP username, in MinIO this value is equal to your authenticating LDAP user DN. LDAPUser KeyName = "ldap:user" // LDAPUsername - LDAP username, in MinIO is the authenticated simple user. LDAPUsername KeyName = "ldap:username" // LDAPGroups - LDAP groups, in MinIO this value is equal LDAP Group DNs for the authenticating user. LDAPGroups KeyName = "ldap:groups" )
const ( // STSDurationSeconds - Duration seconds condition for STS policy STSDurationSeconds KeyName = "sts:DurationSeconds" // STSSourceIdentity - the source identity the session being assumed will // carry: the one requested, or the one inherited from the caller's session. STSSourceIdentity KeyName = "sts:SourceIdentity" // SVCDurationSeconds - Duration seconds condition for Admin policy SVCDurationSeconds KeyName = "svc:DurationSeconds" // AdminPolicyName - the name of the policy a policy admin action // (admin:CreatePolicy, admin:DeletePolicy, admin:GetPolicy) works on, so a // statement can grant those actions on a set of policies, for example // StringLike {"admin:PolicyName": ["app-*"]}. AdminPolicyName KeyName = "admin:PolicyName" )
func (KeyName) Name ¶
Name - returns the key name with its service prefix stripped, so a key reads the request value of the same name. The prefixes that are stripped are the keys of toTrim; a service missing from there keeps its whole name and reads a value nothing populates. A key in untrimmedKeys keeps its whole name too.
func (KeyName) TakesVariable ¶
TakesVariable reports whether key may carry a /<variable> suffix.
type KeySet ¶
type KeySet map[Key]struct{}
KeySet - set representation of slice of keys.
func (KeySet) Difference ¶
Difference - returns a key set contains difference of two keys. Example:
keySet1 := ["one", "two", "three"] keySet2 := ["two", "four", "three"] keySet1.Difference(keySet2) == ["one"]
type Value ¶
type Value struct {
// contains filtered or unexported fields
}
Value - is enum type of string, int or bool.
func NewStringValue ¶
NewStringValue - returns new string value.
func (Value) MarshalJSON ¶
MarshalJSON - encodes Value to JSON data.
func (*Value) StoreString ¶
StoreString - stores string value.
func (*Value) UnmarshalJSON ¶
UnmarshalJSON - decodes JSON data.
type ValueSet ¶
type ValueSet map[Value]struct{}
ValueSet - unique list of values.
func NewValueSet ¶
NewValueSet - returns new value set containing given values.
func (ValueSet) MarshalJSON ¶
MarshalJSON - encodes ValueSet to JSON data.
func (*ValueSet) UnmarshalJSON ¶
UnmarshalJSON - decodes JSON data.