Expand description
IAM policy Condition block evaluation (Phase 2).
Phase 1 of the opt-in IAM enforcement skipped any statement carrying a
Condition block. This module implements real evaluation of the 28
operators AWS defines, with IfExists suffix handling and
ForAllValues / ForAnyValue qualifiers, against a
ConditionContext populated at dispatch time.
§Scope
Implemented operators (authoritative list mirrored from
crate::policy_validation):
- String:
StringEquals,StringNotEquals,StringEqualsIgnoreCase,StringNotEqualsIgnoreCase,StringLike,StringNotLike - Numeric:
NumericEquals,NumericNotEquals,NumericLessThan,NumericLessThanEquals,NumericGreaterThan,NumericGreaterThanEquals - Date:
DateEquals,DateNotEquals,DateLessThan,DateLessThanEquals,DateGreaterThan,DateGreaterThanEquals - Boolean:
Bool - Binary:
BinaryEquals - IP:
IpAddress,NotIpAddress - ARN:
ArnEquals,ArnNotEquals,ArnLike,ArnNotLike - Existence:
Null
Plus the ...IfExists suffix and the ForAllValues: / ForAnyValue:
qualifiers on every operator.
Implemented global keys:
aws:username— populated from the IAM user ARN at dispatch time; absent for assumed-role / federated-user / root principals, matching AWS.aws:userid—<role-id>:<RoleSessionName>for assumed-role sessions, the IAM user’sAIDA...id for IAM users.aws:PrincipalArn,aws:PrincipalAccount,aws:PrincipalTypeaws:SourceIp— remote-address of the HTTP connection.aws:CurrentTime,aws:EpochTimeaws:SecureTransport,aws:RequestedRegionaws:MultiFactorAuthPresent—trueiff the underlying STS session was minted withSerialNumber+TokenCode.aws:MultiFactorAuthAge— seconds since the MFA-asserted session was minted; only present when MFA was supplied at mint time.aws:CalledVia— multi-value chain of service principals that re-invoked downstream services on the caller’s behalf.aws:SourceVpc,aws:SourceVpce,aws:VpcSourceIp— populated when the request transited a VPC interface endpoint.aws:FederatedProvider— SAML provider ARN forAssumeRoleWithSAML, OIDC provider ARN (orProviderIdhost) forAssumeRoleWithWebIdentity. Absent for IAM user keys, plainAssumeRole,GetSessionToken,GetFederationToken.aws:TokenIssueTime— wall-clock time at which the underlying STS credential was issued. Absent for IAM user access keys.
Service-specific keys (s3:prefix, sqs:MessageAttribute, …) are
deferred to a follow-up batch; the ConditionContext::service_keys
map is pre-wired so they can land without a signature change.
§Safe-fail semantics
Any unimplemented operator, unknown key, or parse error emits a
tracing::debug! on the fakecloud::iam::audit target and causes the
operator to evaluate to false — i.e. the statement is treated as
not applicable. Silently returning true would let real policies
grant access we can’t actually verify, which would defeat the whole
opt-in enforcement story.
Structs§
- Compiled
Condition - A statement’s fully-parsed
Conditionblock. Multiple entries are combined with AND: every entry must evaluate totruefor the statement to apply. - Condition
Context - Re-export of the data type defined in
fakecloud-core::auth— seefakecloud_core::auth::ConditionContextfor field documentation. The condition operator framework in this module is implemented against this type. Request-time values consulted when a policy statement carries aConditionblock. Populated at dispatch time from the resolvedPrincipaland the incoming HTTP request, then handed toIamPolicyEvaluator::evaluate. - Parsed
Condition - One parsed entry from a statement’s condition block: the operator, a key, and the policy-declared value list.
- Parsed
Operator Name - Parsed operator name: the base
ConditionOperator, theIfExistsflag, and theForAllValues/ForAnyValuequalifier.
Enums§
- Condition
Operator - Base condition operator name (without
IfExistssuffix orForAllValues:/ForAnyValue:qualifier). - Qualifier
ForAllValues:/ForAnyValue:qualifier applied to the operator.
Functions§
- evaluate_
condition_ block - Top-level evaluation helper used by the evaluator integration in
Batch 2. Returns
trueiff the block is empty or every entry matches. - evaluate_
entry - Evaluate a single condition entry. Convenience entry point used by the evaluator integration in Batch 2 and by unit tests.