# Sub-user permissions

> Grant a sub-user bucket-level or directory-level read, write, list, and tag permissions, and learn which operations each permission covers and how permissions take effect.

Permissions determine which buckets and directories a sub-user (and all AccessKeys under it) can access, and which operations it can perform. You can grant permissions on a whole bucket, or only on certain directories in a bucket.

## The four permissions

| Permission                            | Main operations included                                                                                                                         |
| :------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| **Read (读)**                          | Download files (GetObject), view file info (HeadObject), read object tags, check whether a bucket exists (HeadBucket, requires the whole bucket) |
| **Write (including delete) (写（含删除）)** | Upload, multipart upload, copy, move, **delete**                                                                                                 |
| **List (列表)**                         | List files (ListObjects), list incomplete multipart uploads (requires the whole bucket)                                                          |
| **Tags (标签)**                         | Set and delete object tags                                                                                                                       |

There is no separate "delete" permission. Granting write permission means the sub-user can delete.

Copy and move also check the source: a copy needs **read** on the source and **write** on the destination; a move needs **read** and **write** on the source and **write** on the destination.

> **Warning**
>
> A sub-user with "write" on an **entire bucket** can also change that bucket's CORS settings through the S3 API. If a sub-user only needs to upload files, grant it only directories.

Creating buckets, deleting buckets, public read, hotlink protection, and similar settings can be done only by the primary account in the console. Sub-users can't be granted these permissions.

## Steps to grant permissions

### Open permission settings

Go to **Object Storage (对象存储) › [Sub-users & Keys (子账户\&Key)](https://console.bitiful.com/accessKey)**, and in **Sub-user management (子用户管理)** click **Set permissions (设定权限)** for the sub-user. A drawer opens on the right.

### Grant on the whole bucket

Find the row for the bucket and select the permissions you need. With many buckets, use the search box at the top to **Search bucket name or directory (搜索桶名或目录)**.

### Grant on directories (optional)

Click **+ Add directory (+ 添加目录)** on the right of the bucket:

- Enter a directory path, such as `logs/app`, or click **Browse (浏览)** to multi-select in the directory tree.
- Select permissions for the directory. The default is read and list.
- Click **Add (添加)**.

You can grant permissions on a directory that doesn't exist yet. In that case you see "该目录下暂时没有对象" (there are no objects in this directory yet), which doesn't prevent adding it.

### Save

The bottom shows "有 N 项未保存的更改" (N unsaved changes). Click **Save changes (保存更改)**, and you see "权限已更新，约 1 秒内生效" (permissions updated, effective in about 1 second).

All changes take effect at once: if any one fails, none are saved, and the failed row turns red. Click **Discard changes (放弃更改)** to undo.

## How to write a directory

| Rule            | Description                                                                          |
| :-------------- | ------------------------------------------------------------------------------------ |
| Auto-completion | `logs`, `/logs`, and `logs/` are all saved as `logs/`                                |
| Scope           | All objects in the directory and all its subdirectories                              |
| Case            | Case-sensitive                                                                       |
| No wildcards    | Directory names can't contain `*` or `?`, and a trailing `*` is removed              |
| Other limits    | No consecutive `/`, no `.` or `..` levels, no invisible characters, up to 1000 bytes |
| Quantity        | Up to 20 directories per sub-user per bucket                                         |
| Per save        | Up to 200 additions and removals                                                     |

> **Info**
>
> The unit of authorization is a **directory**, not a file name prefix. Entering `log` grants `log/`, not `logs/` or `log.txt`. Granting permissions on a single file isn't supported either.

## How permissions take effect

The permissions on a file are the **sum of the whole-bucket grant and the grants on all parent directories**. They can only add up, and a subdirectory can't take them back.

| Whole bucket |  `reports/` | `reports/2026/` | Permissions on `reports/2026/a.pdf` |
| :----------: | :---------: | :-------------: | ----------------------------------- |
|     Read     |     None    |      Write      | Read, write                         |
|     None     |     Read    |      Write      | Read, write                         |
|     None     | Read, write |       Read      | Read, write                         |
|     None     |     None    |       List      | List only                           |

Checkboxes marked **Whole bucket (整桶)** or **Inherited (继承)** in the table mean the permission comes from a parent and can't be cleared in this row. When you save, if some directory grants are already fully covered by a parent, S4 asks whether to **also remove fully covered subdirectory grants (同时移除被完全覆盖的子目录授权)**. Removing them doesn't change the effective permissions.

### Behavior with directory permissions only

- When you list the bucket root, you see only the authorized directories and no other files.
- Listing incomplete multipart uploads requires "list" on the whole bucket.
- HeadBucket (which some tools use at startup to check that the bucket exists) requires "read" on the whole bucket, and returns 403 with directory permissions only.
- With write permission but no read permission, some tools report errors after uploading because they can't read back to verify. We recommend granting read as well.

Rclone users can add this to their configuration:

```ini title="rclone.conf"
no_check_bucket = true
```

## Configuration examples

| Scenario                                           | Grant                                                        |
| :------------------------------------------------- | ------------------------------------------------------------ |
| A website backend that reads and writes user files | Bucket `my-app`: read, write, list                           |
| An image host that uploads to a single directory   | `images/` in bucket `my-app`: read, write, list              |
| Read-only data analysis                            | Bucket `my-data`: read, list                                 |
| A backup server                                    | `server-01/` in bucket `my-backup`: read, write, list        |
| Multi-tenant isolation                             | One sub-user per tenant, each granted `tenants/<tenant ID>/` |

## Non-standard and other grants

Grants written in other ways earlier may show as **Non-standard (不规范)**, with a note describing the actual effect. Click **Convert to directory (转为目录)** to replace one with an equivalent directory grant, or click **Delete (删除)** to remove it.

**Other grants (其他授权)** at the bottom don't correspond to a bucket in the current account (the bucket name is a wildcard, or the bucket has been deleted) and can only be deleted.

## FAQ

<details>
<summary>I still get 403 after granting permissions</summary>

Check the following in order:

1. You clicked **Save changes**.
2. You're using a key under this sub-user.
3. The object is inside an authorized directory, with matching case.
4. Whether the tool is checking the bucket (HeadBucket) or trying to create the bucket.

</details>

<details>
<summary>Can I allow uploads but not deletes?</summary>

A sub-user's write permission includes delete. To restrict this, have your server issue [presigned URLs](https://docs.bitiful.com/en/developer/s3/presigned-url.md) that can only upload specified files, without handing the keys to the other party.

</details>

<details>
<summary>Can I grant access to another Bitiful account?</summary>

The console can grant access only to sub-users under your own account.

</details>

<details>
<summary>Do permissions affect public access?</summary>

No. Anonymous access is controlled by [public read](https://docs.bitiful.com/en/bitiful-s4/handbook/public-read.md) and is independent of sub-user permissions.

</details>
