mirror of
https://gitee.com/dcren/openiddict-documentation.git
synced 2025-07-15 23:13:34 +08:00
Update the documentation pages
This commit is contained in:
parent
16a1ddbeb8
commit
5a02224f34
@ -218,7 +218,64 @@ store the tenant name. Once added, the URIs can include a placeholder of the sam
|
|||||||
Description="The tenant used to identify the Zendesk instance" />
|
Description="The tenant used to identify the Zendesk instance" />
|
||||||
</Provider>
|
</Provider>
|
||||||
</code></pre></div>
|
</code></pre></div>
|
||||||
<h2 id="test-the-generated-provider">Test the generated provider</h2>
|
<h2 id="if-the-provider-doesnt-support-standard-openid-connect-userinfo-map-the-provider-specific-claims-to-their-claimtypes-equivalent">If the provider doesn't support standard OpenID Connect userinfo, map the provider-specific claims to their <code>ClaimTypes</code> equivalent</h2>
|
||||||
|
<p>If the provider doesn't return an <code>id_token</code> and doesn't offer a standard userinfo endpoint, it is likely it uses custom parameters
|
||||||
|
to represent things like the user identifier. If so, update the <code>MapCustomWebServicesFederationClaims</code> event handler to map these
|
||||||
|
parameters to the usual WS-Federation claims exposed by the .NET BCL <code>ClaimTypes</code> class, which simplifies integration with libraries
|
||||||
|
like ASP.NET Core Identity:</p>
|
||||||
|
<pre><code class="lang-csharp">/// <summary>
|
||||||
|
/// Contains the logic responsible for mapping select custom claims to
|
||||||
|
/// their WS-Federation equivalent for the providers that require it.
|
||||||
|
/// </summary>
|
||||||
|
public sealed class MapCustomWebServicesFederationClaims : IOpenIddictClientHandler<ProcessAuthenticationContext>
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the default descriptor definition assigned to this handler.
|
||||||
|
/// </summary>
|
||||||
|
public static OpenIddictClientHandlerDescriptor Descriptor { get; }
|
||||||
|
= OpenIddictClientHandlerDescriptor.CreateBuilder<ProcessAuthenticationContext>()
|
||||||
|
.AddFilter<RequireWebServicesFederationClaimMappingEnabled>()
|
||||||
|
.UseSingletonHandler<MapCustomWebServicesFederationClaims>()
|
||||||
|
.SetOrder(MapStandardWebServicesFederationClaims.Descriptor.Order + 1_000)
|
||||||
|
.SetType(OpenIddictClientHandlerType.BuiltIn)
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public ValueTask HandleAsync(ProcessAuthenticationContext context)
|
||||||
|
{
|
||||||
|
if (context is null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(context));
|
||||||
|
}
|
||||||
|
|
||||||
|
context.MergedPrincipal.SetClaim(ClaimTypes.Email, context.Registration.ProviderType switch
|
||||||
|
{
|
||||||
|
// ServiceChannel returns the user identifier as a custom "Email" node:
|
||||||
|
ProviderTypes.ServiceChannel => (string?) context.UserinfoResponse?["Email"],
|
||||||
|
|
||||||
|
_ => context.MergedPrincipal.GetClaim(ClaimTypes.Email)
|
||||||
|
});
|
||||||
|
|
||||||
|
context.MergedPrincipal.SetClaim(ClaimTypes.Name, context.Registration.ProviderType switch
|
||||||
|
{
|
||||||
|
// ServiceChannel returns the user identifier as a custom "UserName" node:
|
||||||
|
ProviderTypes.ServiceChannel => (string?) context.UserinfoResponse?["UserName"],
|
||||||
|
|
||||||
|
_ => context.MergedPrincipal.GetClaim(ClaimTypes.Name)
|
||||||
|
});
|
||||||
|
|
||||||
|
context.MergedPrincipal.SetClaim(ClaimTypes.NameIdentifier, context.Registration.ProviderType switch
|
||||||
|
{
|
||||||
|
// ServiceChannel returns the user identifier as a custom "UserId" node:
|
||||||
|
ProviderTypes.ServiceChannel => (string?) context.UserinfoResponse?["UserId"],
|
||||||
|
|
||||||
|
_ => context.MergedPrincipal.GetClaim(ClaimTypes.NameIdentifier)
|
||||||
|
});
|
||||||
|
|
||||||
|
return default;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</code></pre><h2 id="test-the-generated-provider">Test the generated provider</h2>
|
||||||
<p>If the targeted service is fully standard-compliant, no additional configuration should be required at this point.
|
<p>If the targeted service is fully standard-compliant, no additional configuration should be required at this point.
|
||||||
To confirm it, build the solution and add an instance of the new provider to the <code>OpenIddict.Sandbox.AspNetCore.Client</code> sandbox:</p>
|
To confirm it, build the solution and add an instance of the new provider to the <code>OpenIddict.Sandbox.AspNetCore.Client</code> sandbox:</p>
|
||||||
<ul>
|
<ul>
|
||||||
|
@ -1600,7 +1600,7 @@
|
|||||||
"output": {
|
"output": {
|
||||||
".html": {
|
".html": {
|
||||||
"relative_path": "guides/contributing-a-new-web-provider.html",
|
"relative_path": "guides/contributing-a-new-web-provider.html",
|
||||||
"hash": "t+F4qikdH+m7k3ak2irnfA=="
|
"hash": "TVxxQxHBmAEQiyh1LF4KZQ=="
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"is_incremental": false,
|
"is_incremental": false,
|
||||||
|
Loading…
Reference in New Issue
Block a user