Skip to content

iam: GetAccountAuthorizationDetails is authorizable but unimplemented #848

Closed

Description

@scttfrdmn

iam:GetAccountAuthorizationDetails appears in substrate's authorization reference
(emulator/authz_reference_gen.go:1570) — so a policy can grant or deny it — but the operation
has no handler. The IAM plugin's action switch (emulator/iam_plugin.go:47-226) has no arm for
it, so a call falls through to the default and answers unknownActionError.

That is the one asymmetry worth fixing on its own: substrate can authorize the call and then
cannot serve it. Two of substrate's own doc comments already record the absence rather than
route around it — emulator/iam_xml.go:262-266 ("GetAccountAuthorizationDetails is not among
the operations…") and emulator/iam_policy_versions.go:90.

Why it matters more than a missing operation usually does

It is the only IAM operation that returns every entity and policy in one snapshot, which is
what a consumer uses to assert on an account's whole permission surface after deploying IaC —
exactly substrate's audience. It is also the one operation that would prove three members
substrate has just shipped are consistent across every shape that reports them:
RoleLastUsed (#816), PermissionsBoundaryUsageCount (#815) and AttachmentCount (#847,
which is wrong on GetPolicy today).

What AWS documents

Retrieves information about all IAM users, groups, roles, and policies in your AWS account,
including their relationships to one another. Use this operation to obtain a snapshot of the
configuration of IAM permissions (users, groups, roles, and policies) in your account.

Request parameters

  • Filter.member.N — "A list of entity types used to filter the results. Only the entities that
    match the types you specify are included in the output. Use the value LocalManagedPolicy to
    include customer managed policies." Valid Values: User | Role | Group | LocalManagedPolicy | AWSManagedPolicy. Required: No.
  • Marker — min length 1, pattern [ -ÿ]+. Required: No.
  • MaxItems — "If you do not include this parameter, the number of items defaults to 100."
    Range 1–1000. Required: No.

Response elements — UserDetailList.member.N (UserDetail),
GroupDetailList.member.N (GroupDetail), RoleDetailList.member.N (RoleDetail),
Policies.member.N (ManagedPolicyDetail), IsTruncated, and Marker ("When IsTruncated is
true, this element is present").

Errors — ServiceFailure / 500 only. There is no NoSuchEntity and no InvalidInput; an
unparseable Filter value falls to the common ValidationError.

Policy documents are URL-encoded:

Policies returned by this operation are URL-encoded compliant with RFC 3986. You can use a URL
decoding method to convert the policy back to plain JSON text.

That is a real wire difference from GetPolicyVersion, and a consumer that does not decode sees
escaped text — so it has to be got right rather than approximated.

The nested shapes are deep. From the sample response, a RoleDetail member carries
RolePolicyList, AttachedManagedPolicies, InstanceProfileList (each entry carrying its own
Roles list, whose members carry AssumeRolePolicyDocument, RoleId and RoleLastUsed),
Path, Arn, RoleName, AssumeRolePolicyDocument, CreateDate, RoleId. A
ManagedPolicyDetail member carries PolicyVersionList (with Document, IsDefaultVersion,
VersionId, CreateDate per version) plus AttachmentCount, IsAttachable, DefaultVersionId,
PolicyId, CreateDate, UpdateDate.

Acceptance criteria

  • GetAccountAuthorizationDetails is routed and returns UserDetailList,
    GroupDetailList, RoleDetailList and Policies in AWS's element shapes, rendered
    through the same helpers the single-entity operations use wherever one exists — the
    point is that a member cannot diverge between two operations, which is the defect iam: GetPolicy reports the stored AttachmentCount (always 0) while ListPolicies derives it #847
    describes. Where a shared helper does not fit, the reason is recorded in the doc comment.
  • Filter.member.N is honoured for all five values, and an unrecognised value is refused
    with the enum message iamEnumMessage already produces.
  • MaxItems defaults to 100, is clamped to 1–1000, and IsTruncated/Marker paginate —
    Marker present only when IsTruncated is true.
  • Every policy document in the response is URL-encoded per RFC 3986, asserted against raw
    XML rather than through a decoding client, and stated in docs/services.md as a
    difference from GetPolicyVersion.
  • RoleDetail carries RoleLastUsed (IAM: model RoleLastUsed on GetRole #816's member, whose scope note names this operation)
    and ManagedPolicyDetail carries PermissionsBoundaryUsageCount (IAM: model PermissionsBoundaryUsageCount on the policy shapes #815) and a derived
    AttachmentCount.
  • InstanceProfileList nests its Roles list, and a role in an instance profile reports
    RoleLastUsed there too, as the sample response shows.
  • Bundled AWS managed policies appear under AWSManagedPolicy and customer-managed ones
    under LocalManagedPolicy; the bundled catalog's size is checked against MaxItems's
    1000 ceiling so the default page is not silently the whole catalog.
  • The #… comments at emulator/iam_xml.go:262-266 and
    emulator/iam_policy_versions.go:90 recording the absence are replaced.
  • docs/services.md gains the operation, and make authz-reference-check still passes.

Activity

  1. added this to the v0.115.0 milestone on Sep 13, 2026
  2. added
    type: feature
    area: iam
    on Sep 13, 2026
  3. scttfrdmn commented on Sep 14, 2026

    @scttfrdmn
    OwnerAuthor

    Moved to v0.116.0, where it is the natural headline. Its prerequisite shipped in v0.115.0.

    The prerequisite is met

    This is the one operation that returns every entity and policy in a single snapshot, which makes it the thing that proves the shapes reporting a derived value cannot diverge from each other. Two of those three landed in v0.115.0:

    Size and shape

    M–L on its own: four detail shapes, InstanceProfileList nesting its own Roles list carrying RoleLastUsed, five Filter values, and MaxItems 1–1000 pagination.

    One decision to make deliberately, not in passing

    Its page states policy documents are RFC-3986 URL-encoded, which conflicts with substrate's deliberate plain-JSON rendering. That is the same contradiction API_GetRole shows — the prose claims URL-encoding and the page's own sample response is plain JSON. v0.115.0 deliberately did not pre-empt it. Whichever way it goes, it should be one decision applied to every operation that returns a policy document, not a per-operation choice.

  4. modified the milestones: v0.115.0, v0.116.0 on Sep 14, 2026
  5. scttfrdmn commented on Sep 15, 2026

    @scttfrdmn
    OwnerAuthor

    Verified this issue against the tree at b30af41 before implementing it. The scope holds and the operation is worth exactly what the body claims, but one acceptance criterion is backwards, two are stated against behaviour the tree does not have, a correctness trap is missing, and one design decision AWS does not document is unnamed. Recording all of it here so the PR is not a silent reversal.

    AC 4 is backwards — substrate already percent-encodes the document

    The body says URL-encoding here "is a real wire difference from GetPolicyVersion". It is not a difference: substrate already percent-encodes GetPolicyVersion's document. iamEscapeRFC3986 (emulator/iam_policy_versions.go:244, with isRFC3986Unreserved at :261) is applied at iam_policy_versions.go:227, and it is documented at docs/services.md:1573 ("Returns the document, URL-encoded per RFC 3986") and :2724.

    Substrate's plain-JSON policy-document renderings are only two, and both are deliberate and already recorded:

    • AssumeRolePolicyDocument — emulator/iam_xml.go:279-285, rationale at :258-272: botocore's after-call.iam handler unquotes then json.loads every policyDocumentType member, and unquoting plain JSON is a no-op.
    • inline PolicyDocument (GetRolePolicy/GetUserPolicy/GetGroupPolicy) — emulator/iam_plugin.go:2035.

    The resolution, and it needs no breaking change: follow the per-shape pages, not the operation page's blanket note. Only PolicyVersion.Document's own type page carries the RFC-3986 mandate ("The policy document returned in this structure is URL-encoded compliant with RFC 3986…"). PolicyDetail.PolicyDocument carries no such sentence, and neither does RoleDetail.AssumeRolePolicyDocument. And API_GetAccountAuthorizationDetails' blanket claim is contradicted by its own sample response, in which every document is rendered as plain JSON. API_GetRole shows the same contradiction.

    So:

    • PolicyVersionList[].Document reuses iamPolicyVersionXML — percent-encoded, byte-identical to GetPolicyVersion.
    • UserPolicyList/GroupPolicyList/RolePolicyList PolicyDocument and RoleDetail.AssumeRolePolicyDocument reuse iam_xml.go's builders — plain JSON, byte-identical to GetRolePolicy/GetRole.

    Two conventions in one document is what AWS's model has, and it satisfies the invariant this issue exists to protect — a shape must not diverge between the operations that report it — exactly, at zero compatibility cost. The alternative (encode everything) would be a breaking wire change to five shipped operations and to test/e2e/journey_iam_update_assume_role_policy_test.go:116-120, whose comment records the plain-JSON decision.

    AC 4's assertion-against-raw-XML requirement stands, and gets stronger: the test asserts that PolicyVersionList[].Document is percent-encoded while AssumeRolePolicyDocument is plain JSON in the same response body. The docs/services.md sentence AC 4 asks for is written as that per-shape rule, and records AWS's self-contradiction rather than silently resolving it.

    AC 3 says "clamped"; AWS refuses

    MaxItems outside 1–1000 must be refused, not clamped. paginateIAMKeys (iam_plugin.go:2769-2771) is if maxItems <= 0 || maxItems > 1000 { maxItems = 100 }, which silently rewrites the value at seven pre-existing operations — filed separately as #868, with the citation for why the code is ValidationError/400 here and InvalidInput in iam_simulate.go. This operation validates in the handler before calling the shared helper and inherits none of the coercion. An absent MaxItems still defaults to 100, which is what AWS documents and what iamInt's doc comment (iam_query.go:57-79) protects.

    AC 6 cannot be met from the stored instance profile — IAMInstanceProfile.Roles is a frozen snapshot

    addRoleToInstanceProfile stores profile.Roles = []IAMRole{role} (iam_plugin.go:3079), a copy taken at attach time. STS writes RoleLastUsed onto the role record and never onto that embedded copy. AWS's sample response renders <RoleLastUsed> inside RoleDetailList → InstanceProfileList → Roles → member, so rendering from the stored copy reports nil there for essentially every role — and the defect is invisible to any test that attaches a profile and immediately reads it back.

    The handler therefore re-loads each embedded role by name via p.loadRole (iam_plugin.go:2639). The behavioural test attaches a role to an instance profile and then assumes it, which fails against the stored copy and passes against the re-read.

    Three existing builders are not reusable as-is, because the detail shapes have different members

    AC 1's "same helpers wherever one exists" is right in intent, but three of them render members these shapes do not have, verified member by member against the type pages:

    • iamRoleXMLFields (iam_xml.go:250-257) emits MaxSessionDuration and Description — RoleDetail has neither.
    • iamUserXMLFields (:103-107) emits PasswordLastUsed — UserDetail has no such member.
    • GroupDetail's five non-list members match iamGroupXMLFields verbatim, and iamPolicyXMLFields matches ManagedPolicyDetail's scalars.

    Note the asymmetry that makes this easy to get wrong: InstanceProfile.Roles is an array of Role, not RoleDetail, so Description and MaxSessionDuration are admissible there. The two shapes genuinely differ, and the reason goes in the doc comment as AC 1 requires.

    Three wrapper names also need hoisting to a parameter, following iamStringListXML (:572, the only wrapper-parameterized builder today): AWS uses AttachedManagedPolicies (not AttachedPolicies, hardcoded at :541) and InstanceProfileList (not InstanceProfiles, :613), plus the three *DetailLists. <Policies> already matches.

    AC 7's worry is inverted, and one decision AWS does not document is unnamed

    There are 52 bundled managed policies (ListManagedPolicies, emulator/iam_managed.go:2236) against a default MaxItems of 100. So with any customer entities at all, truncation is on the default path — not the edge case the criterion guards against. That makes the Marker round-trip the load-bearing test, not an afterthought.

    Which forces a decision the page does not settle and the body does not name: whether MaxItems counts across the four lists combined or per list. API_GetAccountAuthorizationDetails says only "the maximum number of items". Substrate pages one combined, ordered key space with composite keys ("user/alice", "policy/arn:…") so a Marker is unambiguous about which list it resumes — the interleaving precedent is iam_list_policies.go:137-139. That is substrate's reading, stated as such in docs/services.md and in the doc comment, not a claim about AWS.

    Marker emitted only when non-empty already satisfies the rest of AC 3.

    AC 8's references have drifted, and it is three rules rather than two mentions

    emulator/iam_xml.go:262-266 is now :296-300 (inside iamRoleLastUsedXML); iam_policy_versions.go:90 is still accurate; iam_xml.go:178 is a third mention (iamPermissionsBoundaryTypePolicy, which names this operation as the future second caller and exists precisely so it cannot pick the other spelling).

    More than the mentions, three doc-comment rules are broken by design here and each needs rewriting rather than deleting:

    The detail shapes are neither the single-entity shape nor the reduced list shape; they are a third population, and the rewritten comments say which member reaches which of the three and why.

    Two stale facts

    Confirmed as written

    The authorization wiring: emulator/authzref/iam.json:365-368 gives {"Name": "GetAccountAuthorizationDetails", "Resources": []} and authz_reference_gen.go:1570 gives "iam:GetAccountAuthorizationDetails": {} — an empty value meaning AWS supports no resource-level permissions — so the only wiring needed is the handler's own p.authorize(…) line, and iamAuthzOperationResource (iam_authz_resources.go:78-169) must not gain a row: :62-63 states the invariant that every no-resource-type action is absent from that table, and a test enforces it.

    The five Filter values, the 1–1000 MaxItems range with default 100, Marker's min length 1 and [ -ÿ]+ pattern, the four response lists plus IsTruncated/Marker, and ServiceFailure/500 as the only published error are all verified. One derivation is genuinely new — role name → containing instance profiles, because ListInstanceProfilesForRole is not implemented; listInstanceProfiles (iam_plugin.go:3186-3210) is the scan to copy. iamPolicyAttachmentCounts (iam_list_policies.go:209), iamBoundaryUsageCounts (iam_boundary_usage.go:61), arnPolicyName, paginateIAMKeys, iamMemberList (iam_query.go:248-260, the Filter.member.N precedent), iamEnumMessage, parseIAMBody and iamXMLResponse are reused as-is, with the policy value copied before assignment (iam_list_policies.go:131-133) because the catalog hands back shared pointers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: iamtype: feature

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions