azure-active-directory - 如何获取自定义 B2C 策略以将 oauth2 承载(令牌)发送到我的自定义注册/登录 API
问题描述
我正在尝试让我的自定义 B2C 策略与我的自定义 SignUp/SignIn API 通信并通过 oauth2 承载(不是静态承载)进行身份验证。我已按照此处的说明进行操作:1(信中)但无法使其正常工作。我无法获取自定义策略以将带有不记名令牌的授权标头发送到我的 API,不确定原因。
这是我的配置:
<ClaimsProvider>
<DisplayName>REST APIs</DisplayName>
<TechnicalProfiles>
<!--OAUTH2.0 customization START-->
<TechnicalProfile Id="REST-AcquireAccessToken">
<DisplayName></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://login.microsoftonline.com/mytenant.onmicrosoft.com/oauth2/v2.0/token</Item>
<Item Key="AuthenticationType">Basic</Item>
<Item Key="SendClaimsIn">Form</Item>
</Metadata>
<CryptographicKeys>
<Key Id="BasicAuthenticationUsername" StorageReferenceId="B2C_1A_SecureRESTClientId" />
<Key Id="BasicAuthenticationPassword" StorageReferenceId="B2C_1A_SecureRESTClientSecret" />
</CryptographicKeys>
<InputClaims>
<InputClaim ClaimTypeReferenceId="grant_type" DefaultValue="client_credentials" />
<InputClaim ClaimTypeReferenceId="scope" DefaultValue="https://graph.microsoft.com/.default" />
</InputClaims>
<OutputClaims>
<OutputClaim ClaimTypeReferenceId="bearerToken" PartnerClaimType="access_token" />
</OutputClaims>
<UseTechnicalProfileForSessionManagement ReferenceId="SM-Noop" />
</TechnicalProfile>
<!--OAUTH2.0 customization END-->
<TechnicalProfile Id="REST-GetProfile">
<DisplayName>Get user extended profile Azure Function web hook</DisplayName>
<Protocol Name="Proprietary" Handler="Web.TPEngine.Providers.RestfulProvider, Web.TPEngine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
<Metadata>
<!-- Set the ServiceUrl with your own REST API endpoint -->
<Item Key="ServiceUrl">https://url_to_API/api/SignIn?</Item>
<Item Key="SendClaimsIn">Body</Item>
<Item Key="AuthenticationType">Bearer</Item>
<Item Key="UseClaimAsBearerToken">bearerToken</Item>
<Item Key="AllowInsecureAuthInProduction">false</Item>
</Metadata>
<InputClaims>
<!-- Claims sent to your REST API -->
<InputClaim ClaimTypeReferenceId="bearerToken"/>
<InputClaim ClaimTypeReferenceId="objectId" />
<InputClaim ClaimTypeReferenceId="extension_MemberId" />
<InputClaim ClaimTypeReferenceId="email" />
</InputClaims>
<OutputClaims>
<!-- Claims parsed from your REST API -->
<OutputClaim ClaimTypeReferenceId="extension_MemberId" PartnerClaimType="extension_MemberId"/>
<OutputClaim ClaimTypeReferenceId="email" />
</OutputClaims>
<UseTechnicalProfileForSessionManagement ReferenceId="SM-Noop" />
文档中未提及但在帖子中看到的内容是,您需要在注册/登录过程中添加一个编排步骤以调用“获取访问令牌” - 但不是 100% 确定它需要它。
<OrchestrationStep Order="5" Type="ClaimsExchange">
<ClaimsExchanges>
<ClaimsExchange Id="RESTGetAccessToken" TechnicalProfileReferenceId="REST-AcquireAccessToken" />
</ClaimsExchanges>
</OrchestrationStep>
<OrchestrationStep Order="6" Type="ClaimsExchange">
<ClaimsExchanges>
<ClaimsExchange Id="RESTGetProfile" TechnicalProfileReferenceId="REST-GetProfile" />
</ClaimsExchanges>
</OrchestrationStep>
我在没有配置授权的情况下检查了我的 API,并且可以看到自定义 B2C 策略正在调用它,但是我根本看不到任何承载令牌的证据(查看了 c# 代码中的 Request.Headers)。另外,我不确定如何配置我的 API 授权方面,文档中也省略了(不幸的是)。
有了以上内容,我是否遗漏了什么?我应该看到带有不记名令牌的授权标头吗?
很感谢任何形式的帮助!
解决方案
推荐阅读
- matlab - 有什么方法可以快速将 C/C++ 函数公开为 MATLAB MEX 文件?
- tensorflow - keras fit_generator:“zip”对象没有属性“shape”
- node.js - 错误:尝试登录后发送标题后无法设置标题
- javascript - 如何在javascript中动态地将复选框添加到表格中
- android - 手动编译apk但是aapt报错
- r - CRON 不执行 R 脚本文件
- laravel - 如何在 Laravel 中编写代码,以便在不刷新页面的情况下执行请求?
- django - 我应该在哪里排序和过滤?后端还是前端?
- android - 当使用 setExactAndAllowWhileIdle 每天发送通知时,它只能工作一天
- reactjs - 如何在 React 中获取点击的元素?