Repository navigation
feat(#1582, #1583): IAM ListEntitiesForPolicy, UpdateUser/UpdateGroup renames, login profiles, force_destroy listings - #1711
Merged
Merged
Conversation
scttfrdmn
force-pushed
the
feat/v0134-federation
branch
2 times, most recently
from
November 25, 2026 01:16
a469592 to
de10810
Compare
scttfrdmn
force-pushed
the
feat/v0134-iam-extras
branch
from
November 25, 2026 01:46
efb136c to
60db32b
Compare
… renames, login profiles, force_destroy listings - ListEntitiesForPolicy reuses the attachment reader, adds the boundary users and roles, and pages one Marker across groups, roles and users with EntityFilter, PathPrefix and PolicyUsageFilter. - UpdateUser and UpdateGroup rename and re-path under a write lock every other IAM request reads under, moving the record, attached and inline policies, both sides of each membership, access keys (and each key's UserName) and the login profile. - Login profiles store CreateDate and PasswordResetRequired, never the password; DeleteUser refuses a user with one. - CloudFormation applies AWS::IAM::User LoginProfile and user/group Path in place. - ListMFADevices, ListSSHPublicKeys, ListSigningCertificates, ListServiceSpecificCredentials and ListVirtualMFADevices answer empty lists.
scttfrdmn
force-pushed
the
feat/v0134-iam-extras
branch
from
November 25, 2026 01:53
60db32b to
967ead5
Compare
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Open
2 tasks
… serialized; vanished credentials refused The server holds IAM's entity lock for reading across principal resolution and the authorization gate, reached through the registry (iamEntityLocker), so a rename cannot run between resolving a caller and deciding its request. IAM's handlers and GetSessionToken look a caller resolved before they took the lock up again by its unique ID; sessions follow a renamed user by that ID. A key or session whose user or role is gone is refused rather than unenforced. Tag writes to users, roles and instance profiles, through IAM or the tagging API, take one tag mutex. The CFN Arn refreshes as soon as a Path change applies. Coverage for the rollback, store-fault and refusal branches.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1582
Fixes #1583
Part of #1613. This adds
ListEntitiesForPolicy. The rest of #1613 is the other v0.134.0 workstreams, andGetFederationTokenis #1694.This PR was stacked on #1700, which has merged (1b9c19f). It is rebased onto main, so the diff is F2 alone.
ListEntitiesForPolicy. It reusesiamPolicyAttachedEntities, the attachment reader that DeletePolicy and AttachmentCount share. It adds the users and roles using the policy as a permissions boundary, unlessPolicyUsageFilter=PermissionsPolicy.EntityFilter:User,RoleandGroupnarrow the kinds.LocalManagedPolicyandAWSManagedPolicyhave no published meaning for this operation. Substrate's reading, marked as its own, is that they select by the policy's own kind: naming the other kind returns nothing.PathPrefixuses the pattern the page documents.Markerresumes across groups, roles and users, throughiamMarker/paginateIAMKeys(pageAfter).NoSuchEntity.UpdateUser/UpdateGroup(iam: route UpdateUser and UpdateGroup so a CloudFormation user or group Path change applies in place #1582). These rename and re-path. Everything stored under the name is re-keyed:UserName, so a signed request resolves to the new name;GetSessionTokensessions (AWS ties a session to the user, not its name).Ordering and atomicity. A rename runs as an
iamTxn. The new name's dependents are written first, then its entity record. Next, the pointers are flipped (access keys, group lists, STS sessions), and only then is the old entity record deleted, followed by the old dependents. So a reader outside IAM (principal resolution, the authz gate, STS) sees one name or the other, whole. Every write records what it replaced, and a failure part way through rolls back, leaving the entity wholly under its old name. A fault-injection test fails each state write in turn and asserts the old name is fully intact. A copy onto a key that already holds a stale record deletes the stale record first.Locking. The rename holds
IAMPlugin.entityMufor writing, and every other IAM operation holds it for reading. The tagging API's writes to IAM records now go through IAM (resourceTagger:tagResourceByARN/tagRecordunder the read lock), so a concurrent tag write cannot recreate a ghost record under the removed name. Race-mode tests interleave a rename with a signed request and with a tagging-API write. The rename also authorizes the target ARN ("permissions on both the source object and the target object"). Errors areEntityAlreadyExists/409,NoSuchEntity/404, andValidationErrorfor a badNewPath. Neither operation has an output shape in the model, so both answer the empty envelope.Login profiles (iam: route the login-profile operations so AWS::IAM::User LoginProfile is applied #1583).
Create,Get,UpdateandDeleteLoginProfile.CreateDateandPasswordResetRequiredonly. The password is never stored, and a test asserts it never reaches a response.UserNamedefaults to the caller where the page says so.DeleteUsernow refuses withDeleteConflictwhile the user has a login profile, access keys, inline or attached policies, or group memberships ("Cannot delete entity, must delete login profile first.", "... access keys first.", "... policies first."; observed wording).CloudFormation.
AWS::IAM::UserLoginProfileis created on deploy and created, updated or deleted on update. A stack delete removes it beforeDeleteUser, and callsDeleteLoginProfileonly when the template declared one.Pathis applied throughUpdateUser/UpdateGroup, replacingcfnIAMPathRefusal. The record's ARN is refreshed, soFn::GetAtt Arnreports the new path.docs/reference/iam.md's "not applied" and "InvalidAction" paragraphs are fixed.force_destroy listings. Terraform's
aws_iam_userforce_destroyreadsListMFADevices,ListSSHPublicKeys,ListSigningCertificates,ListServiceSpecificCredentialsandListVirtualMFADevices. None was routed. Each now answers an empty list: substrate models none of these credentials, so empty is the true answer. The per-user four answerNoSuchEntityfor an absent user, and all five validateMaxItems. No follow-up issue is needed.The routed-operation catalog goes from 1,211 to 1,223 (IAM 97 → 109). The wire-model snapshot was refetched.
Provenance
The
DeleteConflict"must delete login profile first" wording and theNoSuchEntity"Login Profile for User … cannot be found." wording are observed through the AWS CLI and Terraform. The path,Password is requiredand login-profileEntityAlreadyExistsmessages, and theListEntitiesForPolicyEntityFilterreading, are substrate's own; the CHANGELOG lists them.Compatibility
DeleteUserrefuses a user that still has a login profile, access keys, inline policies, attached policies or group memberships, as AWS does.Pathchange on a user or group now updates in place instead of failing the update.Review fixes (rebased onto main at 1b9c19f)
These are the nine review items: tagging writes go through IAM, under the lock; the CFN
GetAtt Arnrefresh after a path change; the transactional rename with rollback, and its fault test;GetSessionTokensessions follow the user; theDeleteUserconflicts, and a stale destination deleted on copy;DeleteLoginProfileonly when one was declared; theEntityFilterreading marked as substrate's own; the login-profile message marked as substrate's own; and substrate's own messages listed in the CHANGELOG. All gates below were re-run after the rebase.Final review round (ac584ec)
resolvePrincipaland the pre-plugin gates, and releases it before the latency sleep and the plugin call.iamEntityLocker,PluginRegistry.iamEntityReadLock), not a global.HandleRequestlooks the caller up again under its lock by unique ID (iamRefreshedPrincipal). The handler doesn't re-take the gate's read lock, so there is no recursive RLock. This is what letsauthorizeWith,GetUserwith no name and the login-profile defaults see a renamed user.Principal.iamCredential) whose user or role no longer exists is refused inCheckAccessand inauthorizeWith, instead of going unenforced. The message is substrate's own, in AWS's implicit-deny shape.*and a Deny onsqs:*, attached either to him or to his group, while renames run concurrently. No signedsqs:ListQueuessucceeds.PrincipalID(the user's AIDA ID), which also covers nit 5. A session recorded before iam: produce aws:userid and aws:PrincipalTag/, the two caller keys still without a producer #771 has no ID, so it is matched by name and ARN.IAMPlugin.tagMucovers the read-merge-write inTagUser,UntagUser,TagRole,UntagRole,TagInstanceProfile,UntagInstanceProfileandtagRecord. ThemergeResourceTagscomment is corrected.TagUserandTagResources, all land.dr.ARNrefreshes right afterapplyIAMPathsucceeds, for both users and groups.Behaviour change. A deleted role's sessions are now refused, where before they were unenforced and narrowed only by their session policies. Two F1 tests that asserted the old behaviour are renamed and now assert the refusal.
Coverage. I added tests for the refusal branches, the store faults (a new
failListon the shared fault store) and the CFN out-of-band paths. I also folded the unreachable marshal-error branches intoiamTxn.putJSONand a genericiamRetag. Patch-line coverage from the emulator package's own tests is 97.5% (960 of 985). What's left is unreachable: marshal errors, and branches shadowed by an earlier read of the same key.CHANGELOG. New entries under Fixed and Compatibility. I also removed a stale duplicate from #1700, a round-2 line saying an unbundled AWS managed policy is "accepted and not applied"; the "allows nothing" line beside it stays.
Gates run locally
make lint(0 issues),make testandmake e2e.docs-versions,docs-counts-check,cfn-schema-check, and the VitePress build (withnode_modulesremoved afterwards).SUBSTRATE_IAC=1 make iac-e2e: Terraform and CDK pass.aws_iam_userwithforce_destroyplus a group membership, a policy attachment andaws_iam_user_login_profile.