mirror of
https://gitee.com/dcren/openiddict-documentation.git
synced 2025-09-24 13:03:32 +08:00
Update the documentation pages
This commit is contained in:
@@ -102,8 +102,8 @@
|
||||
using <strong>individual user accounts authentication</strong> is strongly recommended as it automatically includes the default ASP.NET Core Identity UI, based on Razor Pages.</p>
|
||||
</li>
|
||||
<li><p><strong>Update your <code>.csproj</code> file</strong> to reference the latest <code>OpenIddict</code> packages:</p>
|
||||
<pre><code class="lang-xml"><PackageReference Include="OpenIddict.AspNetCore" Version="4.0.0" />
|
||||
<PackageReference Include="OpenIddict.EntityFrameworkCore" Version="4.0.0" />
|
||||
<pre><code class="lang-xml"><PackageReference Include="OpenIddict.AspNetCore" Version="4.1.0" />
|
||||
<PackageReference Include="OpenIddict.EntityFrameworkCore" Version="4.1.0" />
|
||||
</code></pre></li>
|
||||
<li><p><strong>Configure the OpenIddict core, server and validation services</strong> in <code>Startup.ConfigureServices</code>.
|
||||
Here's an example for the client credentials grant, used in machine-to-machine scenarios:</p>
|
||||
@@ -226,13 +226,19 @@ Here's an example for the client credentials grant:</p>
|
||||
var identity = new ClaimsIdentity(TokenValidationParameters.DefaultAuthenticationType, Claims.Name, Claims.Role);
|
||||
|
||||
// Use the client_id as the subject identifier.
|
||||
identity.AddClaim(Claims.Subject,
|
||||
await _applicationManager.GetClientIdAsync(application),
|
||||
Destinations.AccessToken, Destinations.IdentityToken);
|
||||
identity.SetClaim(Claims.Subject, await _applicationManager.GetClientIdAsync(application));
|
||||
identity.SetClaim(Claims.Name, await _applicationManager.GetDisplayNameAsync(application));
|
||||
|
||||
identity.AddClaim(Claims.Name,
|
||||
await _applicationManager.GetDisplayNameAsync(application),
|
||||
Destinations.AccessToken, Destinations.IdentityToken);
|
||||
identity.SetDestinations(static claim => claim.Type switch
|
||||
{
|
||||
// Allow the "name" claim to be stored in both the access and identity tokens
|
||||
// when the "profile" scope was granted (by calling principal.SetScopes(...)).
|
||||
Claims.Name when claim.Subject.HasScope(Scopes.Profile)
|
||||
=> new[] { Destinations.AccessToken, Destinations.IdentityToken },
|
||||
|
||||
// Otherwise, only store the claim in the access tokens.
|
||||
_ => new[] { Destinations.AccessToken }
|
||||
});
|
||||
|
||||
return SignIn(new ClaimsPrincipal(identity), OpenIddictServerAspNetCoreDefaults.AuthenticationScheme);
|
||||
}
|
||||
|
Reference in New Issue
Block a user