Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve callout for group access in storage #7973

Merged
merged 2 commits into from
Sep 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ Refer to the following examples to understand how you can further customize auth

## Access Types

Authentication is required to continue using Amplify Storage, please make sure you set it up if you haven't already - [documentation to set up Auth](/[platform]/build-a-backend/auth/set-up-auth/).

<Callout>

**Note:** Paths in access definitions cannot have a '/' at the beginning of the string.
Expand All @@ -44,15 +46,10 @@ By default, all paths are denied to all types of users unless explicitly granted

</Callout>

Authentication is required to continue using Amplify Storage, please make sure you set it up if you haven't already - [documentation to set up Auth](/[platform]/build-a-backend/auth/set-up-auth/).

<BlockSwitcher>
<Block name="Guest Users">
{/* it's not actually files that are like /media/*hey right? so instead it should be all files that are under the media/ */}
To grant all guest (i.e. not signed in) users of your application read access to files under `media/`, use the following `access` values.

{/* I would flip this guide to have the conceptual first so you don't need explanations like the ones in the comments */}

```ts title="amplify/storage/resource.ts"
export const storage = defineStorage({
name: 'myProjectFiles',
Expand All @@ -66,6 +63,14 @@ export const storage = defineStorage({

</Block>
<Block name="Authenticated Users">
<Callout>

**Note:** When a user is part of a group, they are assigned the group role, which means permissions defined for the authenticated role will not apply for this user.

To grant access to users within a group, you must explicitly define access permissions for the group against the desired prefix.

</Callout>

To grant all authenticated (i.e. signed in) users of your application read access to files under `media/`, use the following `access` configuration.

```ts title="amplify/storage/resource.ts"
Expand All @@ -78,13 +83,14 @@ export const storage = defineStorage({
})
});
```

</Block>
<Block name="User Groups">

<Callout>

**Note:** When a user is part of a group that has access rules defined in the `amplify/storage/resource.ts` file, those group-specific access rules will take priority over any general access rules set for authenticated users.
**Note:** When a user is part of a group, they are assigned the group role, which means permissions defined for the authenticated role will not apply for this user.

To grant access to users within a group, you must explicitly define access permissions for the group against the desired prefix.

</Callout>

Expand Down Expand Up @@ -227,7 +233,7 @@ export const storage = defineStorage({

The access control matrix for this configuration is

| | media/\* | media/profile-pictures/\* | media/albums/\* | other/\* |
| Path | media/\* | media/profile-pictures/\* | media/albums/\* | other/\* |
| --- | --- | --- | --- | --- |
| **Authenticated Users** | read, write, delete | NONE | read | read, write |
| **Guest users** | NONE | read | NONE | read |
Expand Down