fix(storage): merge authenticated and group permissions in resolveLocationsForCurrentSession#14793
Merged
Merged
Conversation
…ationsForCurrentSession resolvePermissions treated authenticated and groups* rules as mutually exclusive: when the user belonged to a Cognito group it returned only the matched group's permissions (or undefined if no group rule existed for that path), causing StorageBrowser to hide folders that were reachable only via allow.authenticated and to under-report permissions on paths that combined allow.authenticated with allow.groups. Return the deduped union of authenticated and matching groups<Name> permissions so the two rule types are additive, matching IAM. Fixes aws-amplify/amplify-ui#6930
🦋 Changeset detectedLatest commit: 871af03 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
44ce841 to
cd0237c
Compare
soberm
approved these changes
Apr 28, 2026
bobbor
approved these changes
Apr 30, 2026
This was referenced Apr 30, 2026
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.
Description of changes
Fixes the permission resolution in resolveLocationsForCurrentSession (consumed by StorageBrowser's listPaths) so that allow.authenticated and allow.groups(...) access rules are treated as additive rather than mutually exclusive, matching how IAM evaluates the generated policies.
Root cause. In packages/storage/src/internals/apis/listPaths/resolveLocationsForCurrentSession.ts, the resolvePermissions helper, when the current user was in a Cognito
group, returned:
This produced two user-visible bugs in StorageBrowser (Amplify Gen 2):
Fix. Return the deduped union of authenticated and matching groups permissions when the user is in a group, so the two rule types are additive. The existing group-key lookup (access.includes(groups)) is preserved to minimize behavioral risk.
No public API changes; behavior change is confined to how per-location permissions are derived for authenticated users in a Cognito group.
Issue #, if available
Fixes aws-amplify/amplify-ui#6930
Description of how you validated changes
Issue 2's union semantics.
longer vanish when a group is set but no group rule matches).
listPaths.test.ts mocks resolveLocationsForCurrentSession, so its contract is unaffected — confirmed passing.
Pre-commit eslint --fix on both changed files passed with no modifications.
Checklist
PR description included
yarn test passes (ran Jest for the affected packages/storage suites; 10/10 passing)
Unit Tests are changed or added (2 existing assertions corrected + 1 new regression test)
Relevant documentation is changed or added (and PR referenced) — N/A: internal helper behavior fix, no public API or documented behavior change
Checklist for repo maintainers
Verify E2E tests for existing workflows are working as expected or add E2E tests for newly added workflows
New source file paths included in this PR have been added to CODEOWNERS, if appropriate — no new source file paths added
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.