如何避免在AD B2C自定义策略API连接器中避免硬编码ServiceRL?

发布于 2025-01-29 05:12:10 字数 2032 浏览 2 评论 0原文

我的B2C自定义策略中有一个REST API连接器。所有示例我都看到了硬码serviceurl元数据项目中的serviceurl serviceurl 在其余技术配置文件中。例如:

<ClaimsProvider>
      <DisplayName>REST APIs</DisplayName>
      <TechnicalProfiles>
        <TechnicalProfile Id="REST-MyApiConnector">
          <DisplayName>This an example of my API connector</DisplayName>
          <Protocol Name="Proprietary" Handler="Web.TPEngine.Providers.RestfulProvider, Web.TPEngine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
          <Metadata>
            <Item Key="ServiceUrl">https://someapi.com/api/endpoint</Item>
            <Item Key="SendClaimsIn">Url</Item>
            <Item Key="AuthenticationType">Basic</Item>
            <Item Key="AllowInsecureAuthInProduction">false</Item>
          </Metadata>
          <CryptographicKeys>
            <Key Id="BasicAuthenticationUsername" StorageReferenceId="B2C_1A_RestApiUsername" />
            <Key Id="BasicAuthenticationPassword" StorageReferenceId="B2C_1A_RestApiPassword" />
          </CryptographicKeys>
          <InputClaims>
          </InputClaims>
          <OutputClaims>
          </OutputClaims>
          <UseTechnicalProfileForSessionManagement ReferenceId="SM-Noop" />
        </TechnicalProfile>
      </TechnicalProfiles>
    </ClaimsProvider>  

我在github问题上看到了一个摘要( https://github.com /microsoftDocs/azure-docs/desiss/58267 )海报似乎已经从某些外部设置中拉出了serviceurl

<Item Key="ServiceUrl">{Settings:CID-ApiUrl}/{user_id}</Item>

我似乎找不到有关此的进一步信息。有没有办法将诸如serviceurl之类的东西存储在某些外部设置中,然后可以在自定义策略中访问以避免必须进行编码URL?

I have a REST API connector in my B2C custom policy. All examples I have seen hard code the value of the ServiceUrl metadata item in the REST technical profile. For example:

<ClaimsProvider>
      <DisplayName>REST APIs</DisplayName>
      <TechnicalProfiles>
        <TechnicalProfile Id="REST-MyApiConnector">
          <DisplayName>This an example of my API connector</DisplayName>
          <Protocol Name="Proprietary" Handler="Web.TPEngine.Providers.RestfulProvider, Web.TPEngine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
          <Metadata>
            <Item Key="ServiceUrl">https://someapi.com/api/endpoint</Item>
            <Item Key="SendClaimsIn">Url</Item>
            <Item Key="AuthenticationType">Basic</Item>
            <Item Key="AllowInsecureAuthInProduction">false</Item>
          </Metadata>
          <CryptographicKeys>
            <Key Id="BasicAuthenticationUsername" StorageReferenceId="B2C_1A_RestApiUsername" />
            <Key Id="BasicAuthenticationPassword" StorageReferenceId="B2C_1A_RestApiPassword" />
          </CryptographicKeys>
          <InputClaims>
          </InputClaims>
          <OutputClaims>
          </OutputClaims>
          <UseTechnicalProfileForSessionManagement ReferenceId="SM-Noop" />
        </TechnicalProfile>
      </TechnicalProfiles>
    </ClaimsProvider>  

I have seen a snippet on a GitHub issue (https://github.com/MicrosoftDocs/azure-docs/issues/58267) where the poster seems to have pulled the ServiceUrl from some external settings:

<Item Key="ServiceUrl">{Settings:CID-ApiUrl}/{user_id}</Item>

I can't seem to find any further information on this. Is there a way to store things like the ServiceUrl in some external settings that can then be accessed within the custom policy to avoid having to hardcode the URL?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

溺深海 2025-02-05 05:12:10

一旦将其部署到B2C,就无法动态加载服务器。但是,有一个非常有用的VS代码扩展名,可以在开发过程中有所帮助。从以下文档中转到“策略设置”部分: >

简而言之,它有助于定义变量,并根据appsettings.json文件中存储的值替换它们。您可以为不同环境具有多组设置。然后使用一个命令替换所有变量,并将最终策略获取到另一个文件夹。

然后,您可以将它们部署到您的B2C租户。另一个选择是替换CI/CD管道中的变量并将其部署到租户。

Loading the ServiceUrl dynamically is not possible once it is deployed to B2C. But there is a very useful VS Code extension which should help during development. Go to the policy settings section from the following documentation: Azure AD B2C Tools for VSCode

In short, it helps to define variables, and replace them based on values stored in an appsettings.json file. You can have multiple sets of settings for different environments. Then use a single command to replace all variables and get the final policies to another folder.

You can then deploy them to your b2c tenant. Another option is to replace the variables from a CI/CD pipelines and deploy them to the tenant.

烂柯人 2025-02-05 05:12:10

这不是动态的。他们将使用CICD管道将其填充到租户之前。

It’s not dynamic. They would be using CICD pipeline to populate them before uploading into the tenant.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文