如要進一步瞭解員工身分聯盟,請參閱「員工身分聯盟」。
如要瞭解 Secure Source Manager 中員工身分聯盟的限制,請參閱「身分聯盟:產品和限制」。
Secure Source Manager 是單一租戶服務。單一 Secure Source Manager 執行個體應只包含一個Google Cloud 客戶的使用者,除非多間有合約關係的公司需要使用單一執行個體進行協作。
如果您與多家公司合作,並想與他們共同處理原始碼,建議為每家公司建立個別的執行個體。
事前準備
-
Sign in to your Google Account.
If you don't already have one, sign up for a new account.
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator role
(
roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission. Learn how to grant roles.
-
Enable the Secure Source Manager API.
Roles required to enable APIs
To enable APIs, you need the Service Usage Admin IAM role (
roles/serviceusage.serviceUsageAdmin), which contains theserviceusage.services.enablepermission. Learn how to grant roles. -
Install the Google Cloud CLI.
-
若您採用的是外部識別資訊提供者 (IdP),請先使用聯合身分登入 gcloud CLI。
-
執行下列指令,初始化 gcloud CLI:
gcloud init -
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator role
(
roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission. Learn how to grant roles.
-
Enable the Secure Source Manager API.
Roles required to enable APIs
To enable APIs, you need the Service Usage Admin IAM role (
roles/serviceusage.serviceUsageAdmin), which contains theserviceusage.services.enablepermission. Learn how to grant roles. -
Install the Google Cloud CLI.
-
若您採用的是外部識別資訊提供者 (IdP),請先使用聯合身分登入 gcloud CLI。
-
執行下列指令,初始化 gcloud CLI:
gcloud init 設定員工身分識別資訊集區提供者,並使用下列屬性對應:
google.subjectgoogle.email
- INSTANCE_ID:要建立的執行個體名稱。
- LOCATION:要建立執行個體的區域。如要瞭解支援的位置,請參閱「位置」。
- PROJECT_ID:您要在當中建立執行個體的專案 ID。
- INSTANCE_ID:要建立的執行個體名稱。
- LOCATION:要建立執行個體的區域。如要瞭解支援的位置,請參閱「位置」。
- PROJECT_ID:您要在當中建立執行個體的專案 ID。
OPERATION_NAME:作業名稱,例如projects/my-project/locations/us-central1/operations/operation-1234567894561-5ec69948c0f2b-60dd727f-a9b97a2e。PROJECT_ID: Google Cloud 專案。LOCATION:執行個體所在的區域。- OPERATION_NAME:建立指令回應中的作業名稱。
- LOCATION:執行個體區域。
- OPERATION_NAME:建立指令回應中的作業名稱。
-
如要透過網頁介面存取 Secure Source Manager 執行個體,請將下列網址複製到瀏覽器的網址列。
INSTANCE_ID-PROJECT_NUMBER.LOCATION.sourcemanager.dev取代下列項目:
- 將 INSTANCE_ID 替換為執行個體名稱。
- 將 PROJECT_NUMBER 換成執行個體的 Google Cloud 專案編號。如要瞭解如何識別專案,請參閱「識別專案」。
- LOCATION,其中包含執行個體的所在地區。
系統會顯示 OAuth 畫面,要求您提供供應商名稱。
請以以下格式輸入工作團隊身分識別資訊提供者的名稱:
locations/global/workforcePools/POOL_ID/providers/PROVIDER_ID更改下列內容:
- 將
POOL_ID替換成您的員工身分聯盟集區 ID。 - 將
PROVIDER_ID替換成您的員工身分聯盟提供者 ID。
如要進一步瞭解員工身分聯盟集區和提供者,請參閱「管理員工身分聯盟身分集區和提供者」。
系統會提示您使用供應商憑證登入。
- 將
使用供應商憑證登入。
Secure Source Manager 網頁介面隨即開啟。您可以在這裡建立及查看存放區、問題和提取要求。
員工身分聯盟集區的工作階段持續時間到期後,您必須透過網頁介面重新登入。
資料加密
根據預設, Google Cloud 會自動使用Google-owned and Google-managed encryption keys加密靜態資料。如果您在保護資料的金鑰方面有特定的法規遵循或監管要求,可以建立以客戶自行管理的加密金鑰 (CMEK) 加密的 Secure Source Manager 執行個體。
請勿在例項 ID 或標籤鍵/值組合中儲存私密資料,因為這些資料不會以 CMEK 加密。
如果您要在專案中建立第一個 Secure Source Manager 執行個體,請執行下列指令,手動建立 Secure Source Manager 服務代理程式:
gcloud services identity create \
--service=securesourcemanager.googleapis.com \
--project=PROJECT_ID
其中 PROJECT_ID 是您建立 Secure Source Manager 執行個體的專案 ID。
建立每個產品和專案的服務帳戶 (P4SA) 後,您必須將 Secure Source Manager 服務代理角色 (roles/securesourcemanager.serviceAgent) 授予主體 service-PROJECT-NUMBER@gcp-sa-sourcemanager.iam.gserviceaccount.com,否則執行個體建立作業會失敗。
設定員工身分聯盟
建立執行個體之前,您必須先設定 Workforce Identity Federation 集區和提供者。
建立執行個體
gcloud
使用下方的任何指令資料之前,請先替換以下項目:
執行下列指令:
Linux、macOS 或 Cloud Shell
gcloud source-manager instances create INSTANCE_ID --region=LOCATION --project=PROJECT_ID --enable-workforce-identity-federation
Windows (PowerShell)
gcloud source-manager instances create INSTANCE_ID --region=LOCATION --project=PROJECT_ID --enable-workforce-identity-federation
Windows (cmd.exe)
gcloud source-manager instances create INSTANCE_ID --region=LOCATION --project=PROJECT_ID --enable-workforce-identity-federation
系統會啟動長時間執行的建立執行個體作業。輸出內容如下:
Create request issued for [my-instance].
done: false
metadata:
'@type': type.googleapis.com/google.cloud.securesourcemanager.v1.OperationMetadata
apiVersion: v1
createTime: '2023-02-27T20:57:52.315609549Z'
requestedCancellation: false
target: projects/my-project/locations/us-central1/instances/my-instance
verb: create
name: projects/my-project/locations/us-central1/operations/operation-1234567894561-5ec69948c0f2b-60dd727f-a9b97a2e
其中 projects/my-project/locations/us-central1/operations/operation-1234567894561-5ec69948c0f2b-60dd727f-a9b97a2e 是 OPERATION_NAME。
請記錄 OPERATION_NAME,因為您需要使用該值來檢查作業狀態。
建立執行個體最多需要 60 分鐘。
API
執行這項指令前,請先替換下列值:
執行下列指令:
curl \
-X POST -H "Authorization: Bearer $(gcloud auth print-access-token)" \
https://securesourcemanager.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/instances?instance_id=INSTANCE_ID \
-H "Content-Type: application/json" \
-d "{workforce_identity_federation_config: {enabled: true}}"
系統會啟動長時間執行的建立執行個體作業。輸出結果會與下列內容相似:
{
"name": "OPERATION_NAME",
"metadata": {
"@type": "type.googleapis.com/google.cloud.securesourcemanager.v1.OperationMetadata",
"createTime": "2022-11-01T14:31:32.420469714Z",
"target": "projects/PROJECT_ID/locations/LOCATION/instances/INSTANCE_ID",
"verb": "create",
"requestedCancellation": false,
"apiVersion": "v1"
},
"done": false
}
這個輸出範例包含下列值:
請記錄 OPERATION_NAME,因為您需要使用這項資訊來檢查作業狀態。
建立執行個體最多需要 60 分鐘。
Terraform
下列範例會建立啟用員工身分聯盟的 Secure Source Manager 執行個體:
resource "google_secure_source_manager_instance" "instance" {
instance_id = "INSTANCE_ID"
location = "LOCATION"
project = "PROJECT_ID"
workforce_identity_federation_config {
enabled = true
}
}
檢查作業狀態
gcloud
使用下方的任何指令資料之前,請先替換以下項目:
執行下列指令:
Linux、macOS 或 Cloud Shell
gcloud source-manager operations describe OPERATION_NAME --region=LOCATION
Windows (PowerShell)
gcloud source-manager operations describe OPERATION_NAME --region=LOCATION
Windows (cmd.exe)
gcloud source-manager operations describe OPERATION_NAME --region=LOCATION
執行個體準備就緒後,回應內容應如下所示:
"name": "projects/my-project/locations/us-central1/operations/operation-123456789012-5ec69948c0f2b-60dd727f-a9b97a2e",
"metadata": {
"@type": "type.googleapis.com/google.cloud.securesourcemanager.v1.OperationMetadata",
"createTime": "2022-11-01T14:31:32.420469714Z",
"endTime": "2022-11-01T14:48:34.140378114Z",
"target": "projects/my-project/locations/us-central1/instances/my-instance",
"verb": "create",
"requestedCancellation": false,
"apiVersion": "v1"
},
"done": true,
"response": {
"@type": "type.googleapis.com/google.cloud.securesourcemanager.v1.Instance",
"name": "projects/my-project/locations/us-central1/instances/my-instance",
"createTime": "2022-11-01T14:31:32.416413630Z",
"updateTime": "2022-11-01T14:31:32.416413630Z",
"labels": {
"ldap": "user",
"source": "manual"
},
"state": "ACTIVE",
"hostConfig": {
"html": "my-instance-098765432109.us-central1.sourcemanager.dev",
"api": "my-instance-098765432109-api.us-central1.sourcemanager.dev",
"gitHttp": "my-instance-098765432109-git.us-central1.sourcemanager.dev"
}
}
其中 my-instance-098765432109.us-central1.sourcemanager.dev 是執行個體 HTML 網址。
API
使用任何要求資料之前,請先替換以下項目:
HTTP 方法和網址:
GET https://securesourcemanager.googleapis.com/v1/OPERATION_NAME
請展開以下其中一個選項,以傳送要求:
執行個體準備就緒後,回應內容應如下所示:
"name": "projects/my-project/locations/us-central1/operations/operation-123456789012-5ec69948c0f2b-60dd727f-a9b97a2e",
"metadata": {
"@type": "type.googleapis.com/google.cloud.securesourcemanager.v1.OperationMetadata",
"createTime": "2024-10-28T15:37:39.009812863Z",
"endTime": "2024-10-28T16:10:58.416640259Z",
"target": "projects/my-project/locations/us-central1/instances/my-instance",
"verb": "create",
"requestedCancellation": false,
"apiVersion": "v1"
},
"done": true,
"response": {
"@type": "type.googleapis.com/google.cloud.securesourcemanager.v1.Instance",
"name": "projects/my-project/locations/us-central1/instances/my-instance",
"createTime": "2024-10-28T15:37:39.004550840Z",
"updateTime": "2024-10-28T15:37:39.867857246Z",
"state": "ACTIVE",
"hostConfig": {
"html": "my-instance-326202322590.us-central1.sourcemanager.dev",
"api": "my-instance-326202322590-api.us-central1.sourcemanager.dev",
"gitHttp": "my-instance-326202322590-git.us-central1.sourcemanager.dev",
"gitSsh": "my-instance-326202322590-ssh.us-central1.sourcemanager.dev"
},
"workforceIdentityFederationConfig": {
"enabled": true
}
}
其中 my-instance-098765432109.us-central1.sourcemanager.dev 是執行個體 HTML 網址。
從檢查狀態回應中複製 HTML 網址。您需要這個網址,才能透過網頁介面存取執行個體。
存取執行個體
建立執行個體後,您可以使用瀏覽器透過網頁介面存取該執行個體。
建立 gcloud CLI 登入設定
如要使用 gcloud CLI 指令或 Git 指令,透過工作團隊身分識別集區憑證向 Secure Source Manager 執行個體進行驗證,您必須使用工作團隊身分識別集區建立登入設定。
如要建立員工身分集區登入設定,請按照「取得員工身分聯盟的短期權杖」一文中的操作說明,使用 gcloud CLI 建立瀏覽器型登入程序。
完成驗證後,您可以使用 Git 指令與 Secure Source Manager 執行個體互動。如要開始使用 Git,請參閱「使用 Git 原始碼管理」。