> For AI agents: the complete documentation index is available at https://www.tteam.icu/llms.txt, the full documentation bundle is available at https://www.tteam.icu/llms-full.txt.

# 阿里云oss授权单目录

在生产环境中，我们通常需要为每个项目进行OSS权限分离，这样可以有效保障生产环境的安全性。

### 1、创建子账号

### 2、创建权限

```json file="./alioss-oauth/oauth.json" title="oauth.json"
{
  "Version": "1",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": "oss:ListObjects",
      "Resource": "acs:oss:*:<账户id>:<Bucket>",
      "Condition": {
        "StringLike": {
          "oss:Prefix": [
            "<授权目录>",
            "<授权目录>/*"
          ]
        }
      }
    },
    {
      "Effect": "Allow",
      "Action": [
        "oss:GetObject",
        "oss:GetObjectAcl",
        "oss:PutObject",
        "oss:DeleteObject"
      ],
      "Resource": [
        "acs:oss:oss-*:<账户id>:<Bucket>/<授权目录>/*"
      ]
    }
  ]
}
```

:::tip
其中 `acs:oss:*:<账户id>:<Bucket>` 中的 `*` 代表所有地域。
:::

### 3、为子账号授权

将刚刚创建的权限策略授予子账号即可完成授权。
