Files
doc-exports/docs/obs/umn/obs_03_0141.html
weihongmin1 cd7925dbd2 OBS UMN 1210 Version
Reviewed-by: Sabelnikov, Dmitriy <dmitriy.sabelnikov@t-systems.com>
Co-authored-by: weihongmin1 <weihongmin1@huawei.com>
Co-committed-by: weihongmin1 <weihongmin1@huawei.com>
2025-12-10 14:10:07 +00:00

78 lines
7.0 KiB
HTML

<a name="obs_03_0141"></a><a name="obs_03_0141"></a>
<h1 class="topictitle1">Configuring a Custom Bucket Policy (Coding Mode)</h1>
<div id="body1559010359272"><p id="obs_03_0141__p574083285011">You can configure a custom bucket policy by coding. The size of a custom bucket policy cannot exceed 20 KB.</p>
<div class="section" id="obs_03_0141__section19588639165015"><h4 class="sectiontitle">Procedure</h4><ol id="obs_03_0141__ol6696653205012"><li id="obs_03_0141__li11242915363"><span>In the bucket list, click the bucket you want to operate to go to the <strong id="obs_03_0141__obs_03_0307_b5948183711913">Objects</strong> page.</span></li><li id="obs_03_0141__li832413175217"><span>In the navigation pane, choose <strong id="obs_03_0141__b9602124516101">Permissions</strong> &gt; <strong id="obs_03_0141__b1660717459108">Bucket Policies</strong>.</span></li><li id="obs_03_0141__li16486113718713"><span>Click <strong id="obs_03_0141__b1782874317560">Create</strong> and click the <strong id="obs_03_0141__b46631258122614">JSON</strong> tab.</span></li><li id="obs_03_0141__li75805462519"><span>Edit the bucket policy. Below gives a bucket policy example in JSON:</span><p><pre class="screen" id="obs_03_0141__screen866121133215"><span style="color:#222222;">{</span>
<span style="color:#222222;"> "Statement":[</span>
<span style="color:#222222;"> {</span>
<span style="color:#222222;"> "Action":[</span>
<span style="color:#222222;"> "CreateBucket",</span>
<span style="color:#222222;"> "DeleteBucket"</span>
<span style="color:#222222;"> ],</span>
<span style="color:#222222;"> "Effect":"Allow",</span>
<span style="color:#222222;"> "Principal":{</span>
<span style="color:#222222;"> "ID":[</span>
"domain/<em id="obs_03_0141__i1129343493419">account ID</em>",
"domain/<em id="obs_03_0141__i12293143410341">account ID</em>:user/<em id="obs_03_0141__i629313453411">User ID</em>"
<span style="color:#222222;"> ]</span>
<span style="color:#222222;"> },</span>
<span style="color:#222222;"> "Condition":{</span>
<span style="color:#222222;"> "NumericNotEquals":{</span>
<span style="color:#222222;"> "Referer":"sdf"</span>
<span style="color:#222222;"> },</span>
<span style="color:#222222;"> "StringNotLike":{</span>
<span style="color:#222222;"> "Delimiter":"ouio"</span>
<span style="color:#222222;"> }</span>
<span style="color:#222222;"> },</span>
<span style="color:#222222;"> "Resource":"000-02/key01"</span>
<span style="color:#222222;"> }</span>
<span style="color:#222222;"> ]</span>
<span style="color:#222222;"> }</span></pre>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="obs_03_0141__table788413983114" frame="border" border="1" rules="all"><caption><b>Table 1 </b>Parameters for creating a bucket policy in JSON</caption><thead align="left"><tr id="obs_03_0141__row3884698312"><th align="left" class="cellrowborder" valign="top" width="50%" id="mcps1.3.2.2.4.2.2.2.3.1.1"><p id="obs_03_0141__p1888415933115">Parameter</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="50%" id="mcps1.3.2.2.4.2.2.2.3.1.2"><p id="obs_03_0141__p4884189113116">Description</p>
</th>
</tr>
</thead>
<tbody><tr id="obs_03_0141__row118844913113"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.2.2.4.2.2.2.3.1.1 "><p id="obs_03_0141__p988416916313"><span style="color:#222222;">Action</span></p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.2.2.4.2.2.2.3.1.2 "><p id="obs_03_0141__p13885179143120">Actions the bucket policy applies to. For details, see <a href="obs_03_0051.html">Actions</a>.</p>
</td>
</tr>
<tr id="obs_03_0141__row48856913118"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.2.2.4.2.2.2.3.1.1 "><p id="obs_03_0141__p68858920313"><span style="color:#222222;">Effect</span></p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.2.2.4.2.2.2.3.1.2 "><p id="obs_03_0141__p15885109173115">Effect of the bucket policy. For details, see <a href="obs_03_0115.html">Effect</a>.</p>
</td>
</tr>
<tr id="obs_03_0141__row288519173115"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.2.2.4.2.2.2.3.1.1 "><p id="obs_03_0141__p11885594314"><span style="color:#222222;">Principal</span></p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.2.2.4.2.2.2.3.1.2 "><p id="obs_03_0141__p10473324123114">Users the bucket policy is applied to. You can obtain the user ID on the <strong id="obs_03_0141__b367616232377">My Credentials</strong> page by logging in to the console as the user to be authorized. Principals should be configured as follows:</p>
<ul id="obs_03_0141__ul747322483120"><li id="obs_03_0141__li647313241315"><strong id="obs_03_0141__b5650145962716">domain/</strong><em id="obs_03_0141__i437117258387">Domain ID</em> (indicating that the principal is an account)</li><li id="obs_03_0141__li2473172419318"><strong id="obs_03_0141__b15584734182817">domain/</strong><em id="obs_03_0141__i1227313238390">Domain ID</em><strong id="obs_03_0141__b1734328283">:user/</strong><em id="obs_03_0141__i173421318163919">User ID</em> (indicating that the principal is a user under an account)</li></ul>
<div class="note" id="obs_03_0141__note169801412124317"><span class="notetitle"> NOTE: </span><div class="notebody"><p id="obs_03_0141__p109801412154311"><em id="obs_03_0141__i790515346482">Domain ID</em> is the <strong id="obs_03_0141__b137894355618">Account ID</strong> that you can find on the <strong id="obs_03_0141__b1278918312564">My Credentials</strong> page.</p>
</div></div>
</td>
</tr>
<tr id="obs_03_0141__row10885189133118"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.2.2.4.2.2.2.3.1.1 "><p id="obs_03_0141__p48851198314"><span style="color:#222222;">Condition</span></p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.2.2.4.2.2.2.3.1.2 "><p id="obs_03_0141__p1088519943110">Conditions under which the bucket policy takes effect. For details, see <a href="obs_03_0120.html">Conditions</a>.</p>
</td>
</tr>
<tr id="obs_03_0141__row17885692319"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.2.2.4.2.2.2.3.1.1 "><p id="obs_03_0141__p488511933113"><span style="color:#222222;">Resource</span></p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.2.2.4.2.2.2.3.1.2 "><p id="obs_03_0141__p588515943114">Resources the bucket policy is applied to. For details, see <a href="obs_03_0118.html">Resources</a>.</p>
</td>
</tr>
</tbody>
</table>
</div>
</p></li><li id="obs_03_0141__li54216815211"><span>Click <strong id="obs_03_0141__b1283017501894">Create</strong>.</span></li></ol>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="en-us_topic_0045853584.html">Configuring a Bucket Policy</a></div>
</div>
</div>