如何为自定义策略启用 PKCE 配置

How to enable PKCE configuration for custom policies

当我们在启用 PKCE 的 Web 应用程序上测试用户流时,我们会看到一个用于配置 PKCE 的下拉列表。但是当我们尝试测试自定义策略时,我们没有得到这个。我们可以做些什么来启用此 PKCE 配置?

我不确定您在此处专门针对 PKCE 提到的下拉列表。如果您可以分享其中的屏幕截图以供参考,那就太好了。但关于 PKCE 的使用,由于 PKCE 也是 OAuth2.0 流程的一部分,因此自定义策略中的设置将与任何社交媒体 Claim Providers/Identity 提供商的设置相同。您可以从入门包中参考我们的 SocialAndLocalAccount 策略中的 Facebook 声明提供程序设置以获取更多信息。

供参考:共享 Github 声明提供者的摘录:

<ClaimsProvider>
  <Domain>github.com</Domain>
  <DisplayName>GitHub</DisplayName>
  <TechnicalProfiles>
    <TechnicalProfile Id="GitHub-OAuth2">
          <DisplayName>GitHub</DisplayName>
          <Protocol Name="OAuth2" />
          <Metadata>
            <Item Key="ProviderName">github</Item>
            <Item Key="authorization_endpoint">https://github.com/login/oauth/authorize</Item>
            <Item Key="AccessTokenEndpoint">https://github.com/login/oauth/access_token</Item>
            <Item Key="ClaimsEndpoint">https://api.github.com/user</Item>
            <Item Key="BearerTokenTransmissionMethod">AuthorizationHeader</Item>
            <Item Key="scope">user</Item>
            <Item Key="HttpBinding">GET</Item>
            <Item Key="UserAgentForClaimsExchange">CPIM-Basic/{tenant}/{policy}</Item>
            <!-- Update the Client ID below to the Application ID -->
            <Item Key="client_id">xxxxxxxxxxxxxxxxxx</Item>
          </Metadata>
          <CryptographicKeys>
            <Key Id="client_secret" StorageReferenceId="B2C_1A_GithubSecret"/>
          </CryptographicKeys>
          <OutputClaims>
            <OutputClaim ClaimTypeReferenceId="displayName" PartnerClaimType="name" />
            <OutputClaim ClaimTypeReferenceId="email" PartnerClaimType="email" />
            <OutputClaim ClaimTypeReferenceId="numericUserId" PartnerClaimType="id" />
            <!-- <OutputClaim ClaimTypeReferenceId="UserId" /> -->
            <OutputClaim ClaimTypeReferenceId="issuerUserId" />
            <OutputClaim ClaimTypeReferenceId="identityProvider" DefaultValue="github.com" AlwaysUseDefaultValue="true" />
            <OutputClaim ClaimTypeReferenceId="authenticationSource" DefaultValue="socialIdpAuthentication" AlwaysUseDefaultValue="true" />
          </OutputClaims>
          <OutputClaimsTransformations>
            <OutputClaimsTransformation ReferenceId="CreateIssuerUserId" />
            <OutputClaimsTransformation ReferenceId="CreateRandomUPNUserName"/>
            <OutputClaimsTransformation ReferenceId="CreateUserPrincipalName"/>
            <OutputClaimsTransformation ReferenceId="CreateAlternativeSecurityId"/>
            <OutputClaimsTransformation ReferenceId="CreateSubjectClaimFromAlternativeSecurityId"/>
          </OutputClaimsTransformations>
          <UseTechnicalProfileForSessionManagement ReferenceId="SM-SocialLogin" />
    </TechnicalProfile>   
  </TechnicalProfiles>    
</ClaimsProvider> 

如果您检查此示例,您会发现有一个名为 <Protocol Name="OAuth2" /> 的元素,这将为该声明提供程序启用对 OAuth2.0 协议的支持。