gpt4 book ai didi

azure - Terraform - Azure 如何创建 B2C 身份提供商

转载 作者:行者123 更新时间:2023-12-03 06:24:08 24 4
gpt4 key购买 nike

我有以下 terraform 代码来创建 azure - azurerm_aadb2c_directory 如下:

resource "azurerm_aadb2c_directory" "example" {
country_code = var.b2c_country_code
data_residency_location = var.b2c_data_residency_location
display_name = var.b2c_display_name
domain_name = "${var.b2c_display_name}.onmicrosoft.com"
resource_group_name = var.b2c_rg_name
sku_name = var.b2c_sku
}

现在我想创建一个身份提供者(如下面的屏幕截图中所述),但我找不到相应的 terraform 资源。

有人可以帮助我找到正确的 terraform 资源以及如何修改/创建/自定义页面,如下面的屏幕截图所示?

enter image description here

最佳答案

默认情况下,Azure Terraform 资源提供程序不包含为 Azure AD B2C 设置身份提供程序的配置。

resource "azurerm_aadb2c_directory" "example" {
country_code = "US"
data_residency_location = "United States"
display_name = "example-b2c-tenant"
domain_name = "exampleb2ctenant.onmicrosoft.com"
resource_group_name = "example-rg"
sku_name = "PremiumP1"
}

输出:-

enter image description here

enter image description here

其他提供程序用于获取现有 Azure AD B2C 租户的属性。

data "azurerm_aadb2c_directory" "example" {
resource_group_name = "example-rg"
domain_name = "exampleb2ctenant.onmicrosoft.com"
}

output "tenant_id" {
value = data.azurerm_aadb2c_directory.example.tenant_id
}

输出:-

enter image description here

I also tried checking Microsoft Rest API to update IDP in AAD B2C via
terraform, But there’s no API call to create or update IDP in azure AD
B2C.

但是您可以使用以下代码调用 Rest API,通过社交 IDP 或本地 IDP 来更新 Azure AD B2C 中应用程序的密码凭据:-

创建了一个 Google 开发者 IDP 并从注册的应用程序中获取了客户端 ID 和客户端 key :-

enter image description here

terraform {

required_providers {

azurerm = {

source = "hashicorp/azurerm"

version = "3.47.0"

}

}

}




provider "azurerm" {

features {}

subscription_id = "<subscription-id>"

}



resource "azurerm_resource_group" "appgrp" {

name = "app-grp"

location = "West Europe"

}



resource "null_resource" "configure_social_idp" {

provisioner "local-exec" {

command = <<EOF

set AZURE_TENANT_ID="<tenant-id>"

set AZURE_CLIENT_ID="<client-id>"

set AZURE_CLIENT_SECRET="<client-secret>"

set AZURE_AD_B2C_APP_ID="<app-id>"




curl -X POST \

-H "Authorization: Bearer $(az account get-access-token --resource https://graph.windows.net | jq -r .accessToken)" \

-H "Content-Type: application/json" \

-d '{

"keyCredential": {

"customKeyIdentifier": null,

"displayName": "Google",

"endDateTime": null,

"key": null,

"startDateTime": null,

"type": "Symmetric",

"usage": "Verify",

"value": "<idp-password>"

},

"passwordCredential": null,

"publicClient": null,

"replyUrls": [],

"requiredResourceAccess": [],

"web": null

}' \

"https://graph.windows.net/\<tenant-id>/applications/\<object-id>/addKeyCredential?api-version=1.6"

EOF

}

}

输出:-

enter image description here

enter image description here

引用文献:-

Terraform Registry

azurerm_aadb2c_directory | Data Sources | hashicorp/azurerm | Terraform Registry

B2C Tenants - Create - REST API (Azure Azure AD B2C) | Microsoft Learn

B2C Tenants - Update - REST API (Azure Azure AD B2C) | Microsoft Learn

关于azure - Terraform - Azure 如何创建 B2C 身份提供商,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/75685395/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com