注意:
- 此教學課程需要存取 Oracle Cloud。若要註冊免費帳戶,請參閱開始使用 Oracle Cloud Infrastructure Free Tier 。
- 它會使用 Oracle Cloud Infrastructure 證明資料、租用戶及區間的範例值。完成實驗室時,請將這些值替代為您雲端環境特定的值。
設定您 Oracle Cloud 租用戶的初始管理員模型
簡介
雲端安全性需要共用責任模型。Oracle 身為雲端供應商,負責提供安全的基礎架構和平台服務。而身為租用戶擁有者的您,則負責管理及控制對您在租用戶中建立之資源的存取。當您第一次建立 Oracle Cloud Infrastructure (OCI) 租用戶時,有一個使用者帳戶是租用戶管理員群組的成員,可授予整個租用戶及其中所有資源的完整存取權。
當您開始新增其他管理員、指派權限、建立資源以及填入資料時,請務必儘早思考您的安全模型,如此一來您就不必瞭解如何清理出路的問題。
本教學課程中描述的安全模型代表了一般設計,必須符合組織的特定安全原則和租用戶管理方法。Oracle Cloud Infrastructure Identity and Access Management (OCI IAM) 政策模型非常具有彈性,可以輕鬆調整或修改模型以符合不同的設計。
目標
- 設定各種不同類型 OCI 管理員的初始租用戶層級存取權
- 瞭解 OCI 政策模型的功能
- 允許設定專用的緊急存取帳戶
必要條件
- 使用初始管理員帳戶存取 OCI 租用戶
- 存取 Cloud Shell
- 瞭解 UNIX 命令行的基本知識
作業 1:設定起始租用戶設定值
為了簡化建立租用戶存取的基準模型,以及建立用於在 OCI 內使用租用戶層次資源的高層次角色,可以使用 OCI CLI 編寫初始權益命令檔,然後從 Cloud Shell 執行。
下方提供了為下列核心存取功能集建立群組和原則敘述句的樣板命令檔,以及為所有 OCI 管理員提供基準存取層次。
- 租用戶管理程式:負責 OCI 帳戶管理和租用戶層級建構,例如預算和訂閱的區域
- 政策管理員:負責建立與維護安全政策及支援資源
- 安全管理員:負責設定安全服務,例如 OCI Identity and Access Management (OCI IAM)、雲端保全、安全區域、漏洞掃描及租用戶層級警示
- 安全分析師:負責檢閱雲端保全、漏洞掃描及稽核事件等服務的安全發現項目
這些政策的目的是建立適用於大多數客戶的初始權益集。以下各節會說明這些特定存取功能和潛在其他原則的更多詳細資訊。
這些群組應與 OCI IAM 識別網域中已存在的角色搭配使用;包括為環境設定認證機制的安全性管理員,以及用於管理使用者上線和指派的使用者管理員。在外部身分識別管理解決方案中管理使用者的部署中,可能不需要使用者管理員。
如果您不熟悉 OCI IAM 原則語法,請檢閱 OCI IAM 文件以瞭解原則敘述句的結構。
基準存取指令碼
注意:此命令檔僅適用於具有 IAM 網域的 OCI 環境。部分較舊租用戶的環境可能沒有 IAM 網域。若要確認您的環境是否具有 IAM 網域,請依照此處的指示進行。
#!/bin/bash
#Update the below with details for the environment
tenancy_ocid=ocid1.tenancy.oc1..aaaaaaaa....
#Group names
tenancy_manager_group=TenancyManagers
pol_admin_group=PolicyAdmins
sec_admin_group=SecurityAdmin
sec_analyst_group=SecurityAnalysts
#All_Users_Policy
oci iam policy create -c $tenancy_ocid --name "All_Users_Policy" \
--description "General purpose permissions intended for all users of the tenancy." \
--statements "[\"allow any-user to inspect tag-defaults in tenancy where all{ request.domain.name = 'default', request.principal.type = 'user' }\", \
\"allow any-user to inspect limits in tenancy where all{ request.domain.name = 'default', request.principal.type = 'user' }\", \
\"allow any-user to inspect tenancies in tenancy where all{ request.domain.name = 'default', request.principal.type = 'user' }\", \
\"allow any-user to inspect compartments in tenancy where all{ request.domain.name = 'default', request.principal.type = 'user' }\", \
\"allow any-user to read policies in tenancy where all{ request.domain.name = 'default', request.principal.type = 'user' }\", \
\"allow any-user to read objectstorage-namespaces in tenancy where all{ request.domain.name = 'default', request.principal.type = 'user' }\", \
\"allow any-user to read announcements in tenancy where all{ request.domain.name = 'default', request.principal.type = 'user' }\", \
\"allow any-user to use cloud-shell in tenancy where all{ request.domain.name = 'default', request.principal.type = 'user' }\"]"
#Tenancy Managers
oci iam group create --name $tenancy_manager_group \
--description "Group for Tenancy Managers for OCI, who can manage tenancy-level constructs, such as budgets and regions."
oci iam policy create -c $tenancy_ocid --name "Tenancy_Managers_Policy" \
--description "Policy statements which define the 'Tenancy Manager' role, which allows for managing tenancy-level configuration and objects." \
--statements "[\"define tenancy usage-report as ocid1.tenancy.oc1..aaaaaaaaned4fkpkisbwjlr56u7cj63lf3wffbilvqknstgtvzub7vhqkggq\", \
\"allow group ${tenancy_manager_group} to read usage-report in tenancy\", \
\"allow group ${tenancy_manager_group} to read resource-availability in tenancy\", \
\"allow group ${tenancy_manager_group} to manage quotas in tenancy\", \
\"allow group ${tenancy_manager_group} to manage tenancies in tenancy\", \
\"allow group ${tenancy_manager_group} to manage objectstorage-namespaces in tenancy\", \
\"allow group ${tenancy_manager_group} to manage buckets in tenancy where request.operation = 'UpdateNamespaceMetadata'\", \
\"allow group ${tenancy_manager_group} to manage usage-budgets in tenancy\", \
\"allow group ${tenancy_manager_group} to manage organizations-family in tenancy\", \
\"allow group ${tenancy_manager_group} to {AUDIT_CONFIGURATION} in tenancy\", \
\"endorse group ${tenancy_manager_group} to read objects in tenancy usage-report\"]"
#Policy Admins
oci iam group create --name $pol_admin_group \
--description "Group for Policy Administrators for OCI, who create and maintain IAM Policies and supporting resources."
oci iam policy create -c $tenancy_ocid --name "Policy_Admins_Policy" \
--description "Policy statements which define the 'Policy Admin' role, who create and maintain IAM Policies and supporting resources." \
--statements "[\"allow group ${pol_admin_group} to inspect groups in tenancy\", \
\"allow group ${pol_admin_group} to read users in tenancy\", \
\"allow group ${pol_admin_group} to manage groups in tenancy where target.group.name != 'Administrators'\", \
\"allow group ${pol_admin_group} to manage compartments in tenancy\", \
\"allow group ${pol_admin_group} to manage dynamic-groups in tenancy\", \
\"allow group ${pol_admin_group} to manage domains in tenancy where request.permission != 'DOMAIN_RESOURCES_ADMINISTER'\", \
\"allow group ${pol_admin_group} to manage network-sources in tenancy\", \
\"allow group ${pol_admin_group} to manage policies in tenancy\", \
\"allow group ${pol_admin_group} to manage tag-namespaces in tenancy\", \
\"allow group ${pol_admin_group} to manage iamworkrequests in tenancy\"]"
#Security Admin
oci iam group create --name $sec_admin_group \
--description "Group for Security Admins for OCI, who can manage Cloud Guard and Data Safe"
oci iam policy create -c $tenancy_ocid --name "Security_Admins_Policy" \
--description "Policy statements which define the 'Security Admin' role, which allows for managing Cloud Guard and Data Safe." \
--statements "[\"allow group ${sec_admin_group} to inspect groups in tenancy\", \
\"allow group ${sec_admin_group} to read repos in tenancy\", \
\"allow group ${sec_admin_group} to manage cloud-guard-family in tenancy\", \
\"allow group ${sec_admin_group} to manage data-safe in tenancy\"]"
#Security Analyst
oci iam group create --name $sec_analyst_group \
--description "Group for Security Analysts for OCI, which provides read access to resources in the tenancy, and the ability to use Cloud Guard"
oci iam policy create -c $tenancy_ocid --name "Security_Analysts_Policy" \
--description "Policy statements which define the 'Security Analyst' role, which allows for read access to the tenancy, and the ability to work with Cloud Guard." \
--statements "[\"allow group ${sec_analyst_group} to read all-resources in tenancy\", \
\"allow group ${sec_analyst_group} to read audit-events in tenancy\", \
\"allow group ${sec_analyst_group} to read cloud-guard-family in tenancy\", \
\"allow group ${sec_analyst_group} to use cloud-guard-config in tenancy\", \
\"allow group ${sec_analyst_group} to manage cloud-guard-detectors in tenancy\", \
\"allow group ${sec_analyst_group} to manage cloud-guard-problems in tenancy\", \
\"allow group ${sec_analyst_group} to manage cloud-guard-detector-recipes in tenancy\", \
\"allow group ${sec_analyst_group} to manage cloud-guard-managed-lists in tenancy\", \
\"allow group ${sec_analyst_group} to manage cloud-guard-user-preferences in tenancy\"]"
作業 2:更新程序檔
-
將指令碼複製到文字編輯器,以在環境中執行前進行任何必要的調整。
-
將
tenancy_ocid變數更新為您租用戶的正確值。您可以從 https://cloud.oracle.com/tenancy 提供的租用戶詳細資訊頁面或按一下 OCI 主控台儀表板中的租用戶名稱,取得租用戶 OCID。
-
視需要更新群組名稱。群組名稱可能需要配合命名方案,特別是有意從外部識別管理系統植入。
-
複查並更新政策聲明,以符合您組織的需求。下列各節概述這些原則敘述句的修改以及其他原則敘述句。
瞭解權限模型
在此高層次,由此命令檔實行的權益設計會將租用戶管理責任區分為較窄的角色,以便更能反映出環境中可能存在之不同類型的管理員。它也旨在防止在租用戶層級操作的使用者在專屬 OCI 區間之外建立基礎架構資源。
確保在區間中建立的資源可改善租用戶治理,因為可以在區間層次設定預算和資源配額。由於可以在這些原則中直接參照區間,因此它還會簡化管理這些資源的原則模型。
此程序檔是專門用於儲存的,僅授予最低一組權限給每個群組。視您的組織想要使用 OCI 的方式而定,可能需要額外權限。下列各節詳細探討指令檔所建立的權益,並包含潛在變更的範例。
透過「所有使用者」原則進行基準存取
在 OCI 中,除非已設定原則來提供存取權,否則使用者將無法存取。為了提高使用者生產力,並提供使用者有意義的租用資訊,此命令檔會為所有使用者建立一組基準存取。這些原則授權使用 Cloud Shell,並且能夠讀取公告並查看訂閱的區域。
建議的原則也旨在讓使用者檢視物件,以限制使用者與租用戶互動的能力,包括服務限制和原則,協助使用者在需要額外存取或資源時發出通知的要求。
一般而言,建議將預設 OCI IAM 識別網域用於 OCI 資源管理,並不允許透過任何其他識別網域進行認證的使用者存取 OCI 主控台。因此,提供的命令檔會限制透過預設網域認證的使用者存取。您的安全設計可支援使用多個識別網域來管理 OCI 存取。例如,您可以有一個生產環境管理員的生產環境網域,以及一個非生產環境管理員的非生產環境網域。在此情況下,可以修改基準存取原則中的條件來擷取每個網域,如下所示:
... where all{ request.domain.name in ('<prod_domain_name>, '<non-prod_domain_name>'), request.principal.type = 'user' }
視您的租用戶設計而定,您可能會想要新增下列原則。
allow any-user to use tag-namespaces in tenancy where all{ request.domain.name = 'default', request.principal.type = 'user' }
此原則允許所有使用者針對可修改的資源套用、更新或移除定義的標記。如果資源擁有者應該能夠為了自己的追蹤目的修改標記,或針對存取管理用途修改標記,就應該這麼做。如果您的設計使用標記預設值進行成本追蹤或其他用途,則可能不適合使用。
租用戶管理程式
租用戶管理程式權益的適用對象是擁有租用戶治理責任的使用者,包括管理成本和預算,以及租用戶訂閱的區域。
租用戶管理員的指令碼所建立的原則可能需要進行少量的調整,才能提供使用量報表的存取權。命令檔使用預設租用戶 ID 進行費用分析,但是部分租用戶 (視其狀態而定) 可以使用替代的租用戶 ID。如果租用戶管理程式無法存取使用狀況報表,就必須更新原則以使用 OCI 主控台之用量報表區段中顯示的值。

原則管理員
也許是協助離開使用管理員群組的最重要功能,就是指派「原則管理員」權益。這些權益是由負責設定租用戶內存取權益的管理員所使用。在提供的命令檔建立的模型中,原則管理員負責定義權益,但不會將使用者指派給這些群組。使用者管理權益是透過指定「IAM 網域」內的「使用者管理員」角色來授予。在某些部署中,視您組織的安全性設計而定,單一管理員可指派兩個職責。
注意:「原則管理員」權益的範圍非常窄,但可用它來建立原則,以授予環境內任何層次的存取,包括提升自己的存取層次,應視為具有高度權限的權益。
安全管理員
「安全管理」角色適用於負責在環境中設定安全服務的使用者,例如雲端保全和資料安全。
您也可以新增下列敘述句,讓安全管理員能夠設定租用戶層級警示:
allow group SecurityAdmins to manage cloudevents-rules in tenancy where target.compartment.id = '<tenancy_ocid>'
allow group SecurityAdmins to use metrics in tenancy
這些允許安全管理員設定租用戶層級發生之事件的警示,包括登入或建立雲端保全問題。這些事件需要採取一些動作,例如通知,通知使其變得有意義,不過此動作並不需要位於根 (租用戶) 區間中。負責處理這些事件的服務可改為位於用於其他安全用途的子區間中。例如,可以新增像是下列的原則,以為了安全考量而授權通知組態:
allow group SecurityAdmins to manage ons-family in compartment security_resources
安全分析師
「安全分析員」角色適用於負責複查 OCI 租用戶內動作和事件的使用者。為了調查並驗證與雲端保全問題關聯的問題,安全分析師需要整個租用戶的讀取存取權。
作業 3:使用 Cloud Shell 執行命令檔
對命令檔進行任何必要的修改之後,您就可以在 OCI 主控台內使用 Cloud Shell 執行此命令檔。
注意: 不需要 Cloud Shell,但提供執行命令檔的簡單機制,因為它已預先設定好 OCI CLI,並且使用登入使用者的認證相關資訊環境。
-
從 OCI 主控台標頭的開發人員工具圖示開啟 Cloud Shell。

Cloud Shell 可能需要一些時間才能初始化,尤其是首次存取時。
-
將更新的命令檔複製到您的 Cloud Shell 環境,例如使用
vi:$vi policy_scaffold.sh在
vi中,按i以輸入[INSERT]模式,然後將指令碼內容貼到檔案中,再按esc,然後按:wq以儲存並結束。 -
讓指令碼執行檔,然後執行它來建立初始權益。
$chmod +x policy_scaffold.sh $./policy_scaffold.sh -
監督輸出,確保已正確建立每個 Group 和 Policy 物件。問題可手動解決,或是透過調整,然後從命令檔內重新執行個別 OCI CLI 命令。
作業 4:指派使用者並保護管理員群組
執行命令檔之後,就可以將使用者指派給建立的群組,並授予使用者關聯的權益。
指定少數管理角色之後,最好將 OCI 管理員群組限制為緊急存取案例。OCI 至少需要將一個使用者帳戶指定給管理員群組,才能在識別中斷或設定錯誤時,復原對租用戶的存取。否則,便可能建立一種狀況,讓使用者無法指派存取權,而您的所有管理員都可能從您的環境鎖定。
如需更多資訊和詳細建議,請參閱 Managing Emergency Access Accounts in Oracle Cloud Infrastructure 。
接下來的步驟
建置一組初始的用戶管理角色之後,這些角色可用來作為建立個別專案角色的基礎,或是擴充這些核心管理員的功能。
此處使用的模型有兩個主要目標。首先,它允許將 OCI 環境的管理員從管理員群組中移除,並使其特定職責更密切地量身打造的角色。其次,它會防止具有租用戶層次存取的使用者在根區間中建立基礎架構資源。建立其他原則時,建議維持此設計原則,並只建立以根目錄為目標區間的原則。除了安全性優點之外,此功能也可簡化成本追蹤與專案治理。
若要深入瞭解,請參閱 Oracle Cloud Infrastructure 安全性指南。
相關連結
確認
- 作者:Callan Howell-Pavia (技術人員的主要成員 (OCI Identity/IDCS))
其他學習資源
探索 docs.oracle.com/learn 的其他實驗室,或者存取更多 Oracle Learning YouTube 頻道上的免費學習內容。此外,請瀏覽 education.oracle.com/learning-explorer 以成為 Oracle Learning 檔案總管。
如需產品文件,請造訪 Oracle Help Center 。
Set up an initial administrator model for your Oracle Cloud tenancy
F82183-01
May 2023
Copyright © 2023, Oracle and/or its affiliates.