mirror of
https://gitee.com/dcren/openiddict-documentation.git
synced 2025-07-15 14:04:34 +08:00
Update the documentation pages
This commit is contained in:
parent
c24ded39ce
commit
8263d95312
@ -103,7 +103,7 @@ Here's an example for the client credentials grant, used in machine-to-machi
|
|||||||
.AddCore(options =>
|
.AddCore(options =>
|
||||||
{
|
{
|
||||||
// Configure OpenIddict to use the Entity Framework Core stores and models.
|
// Configure OpenIddict to use the Entity Framework Core stores and models.
|
||||||
// Note: call ReplaceDefaultEntities() to replace the default OpenIddict entities.
|
// Note: call ReplaceDefaultEntities() to replace the default entities.
|
||||||
options.UseEntityFrameworkCore()
|
options.UseEntityFrameworkCore()
|
||||||
.UseDbContext<ApplicationDbContext>();
|
.UseDbContext<ApplicationDbContext>();
|
||||||
})
|
})
|
||||||
@ -121,7 +121,7 @@ Here's an example for the client credentials grant, used in machine-to-machi
|
|||||||
options.AddDevelopmentEncryptionCertificate()
|
options.AddDevelopmentEncryptionCertificate()
|
||||||
.AddDevelopmentSigningCertificate();
|
.AddDevelopmentSigningCertificate();
|
||||||
|
|
||||||
// Register the ASP.NET Core host and configure the ASP.NET Core-specific options.
|
// Register the ASP.NET Core host and configure the ASP.NET Core options.
|
||||||
options.UseAspNetCore()
|
options.UseAspNetCore()
|
||||||
.EnableTokenEndpointPassthrough();
|
.EnableTokenEndpointPassthrough();
|
||||||
})
|
})
|
||||||
@ -173,7 +173,7 @@ Here's an example for the client credentials grant, used in machine-to-machi
|
|||||||
});
|
});
|
||||||
</code></pre></li>
|
</code></pre></li>
|
||||||
</ul>
|
</ul>
|
||||||
<p>-> [!NOTE]</p>
|
<p>-> [!WARNING]</p>
|
||||||
<blockquote><p>Important: if you change the default entity primary key (e.g. to <code>int</code> or <code>Guid</code> instead of <code>string</code>), make sure you use the <code>options.ReplaceDefaultEntities<TKey>()</code>
|
<blockquote><p>Important: if you change the default entity primary key (e.g. to <code>int</code> or <code>Guid</code> instead of <code>string</code>), make sure you use the <code>options.ReplaceDefaultEntities<TKey>()</code>
|
||||||
core extension accepting a <code>TKey</code> generic argument and use the generic <code>options.UseOpenIddict<TKey>()</code> overload to configure Entity Framework Core to use the specified key type:</p>
|
core extension accepting a <code>TKey</code> generic argument and use the generic <code>options.UseOpenIddict<TKey>()</code> overload to configure Entity Framework Core to use the specified key type:</p>
|
||||||
<pre><code class="lang-csharp">services.AddOpenIddict()
|
<pre><code class="lang-csharp">services.AddOpenIddict()
|
||||||
@ -199,17 +199,20 @@ Implementing a custom authorization controller is required to allow OpenIddict t
|
|||||||
Here's an example for the client credentials grant:</p>
|
Here's an example for the client credentials grant:</p>
|
||||||
<pre><code class="lang-csharp">public class AuthorizationController : Controller
|
<pre><code class="lang-csharp">public class AuthorizationController : Controller
|
||||||
{
|
{
|
||||||
private readonly OpenIddictApplicationManager<OpenIddictEntityFrameworkCoreApplication> _applicationManager;
|
private readonly IOpenIddictApplicationManager_applicationManager;
|
||||||
|
|
||||||
public AuthorizationController(OpenIddictApplicationManager<OpenIddictEntityFrameworkCoreApplication> applicationManager)
|
public AuthorizationController(IOpenIddictApplicationManager applicationManager)
|
||||||
=> _applicationManager = applicationManager;
|
=> _applicationManager = applicationManager;
|
||||||
|
|
||||||
[HttpPost("~/connect/token"), Produces("application/json")]
|
[HttpPost("~/connect/token"), Produces("application/json")]
|
||||||
public async Task<IActionResult> Exchange()
|
public async Task<IActionResult> Exchange()
|
||||||
{
|
{
|
||||||
var request = HttpContext.GetOpenIddictServerRequest();
|
var request = HttpContext.GetOpenIddictServerRequest();
|
||||||
if (request.IsClientCredentialsGrantType())
|
if (!request.IsClientCredentialsGrantType())
|
||||||
{
|
{
|
||||||
|
throw new NotImplementedException("The specified grant type is not implemented.");
|
||||||
|
}
|
||||||
|
|
||||||
// Note: the client credentials are automatically validated by OpenIddict:
|
// Note: the client credentials are automatically validated by OpenIddict:
|
||||||
// if client_id or client_secret are invalid, this action won't be invoked.
|
// if client_id or client_secret are invalid, this action won't be invoked.
|
||||||
|
|
||||||
@ -234,9 +237,6 @@ Here's an example for the client credentials grant:</p>
|
|||||||
|
|
||||||
return SignIn(new ClaimsPrincipal(identity), OpenIddictServerAspNetCoreDefaults.AuthenticationScheme);
|
return SignIn(new ClaimsPrincipal(identity), OpenIddictServerAspNetCoreDefaults.AuthenticationScheme);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new NotImplementedException("The specified grant type is not implemented.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
</code></pre></li>
|
</code></pre></li>
|
||||||
<li><p><strong>Register your client application</strong> (e.g from an <code>IHostedService</code> implementation):</p>
|
<li><p><strong>Register your client application</strong> (e.g from an <code>IHostedService</code> implementation):</p>
|
||||||
@ -254,7 +254,7 @@ Here's an example for the client credentials grant:</p>
|
|||||||
var context = scope.ServiceProvider.GetRequiredService<ApplicationDbContext>();
|
var context = scope.ServiceProvider.GetRequiredService<ApplicationDbContext>();
|
||||||
await context.Database.EnsureCreatedAsync();
|
await context.Database.EnsureCreatedAsync();
|
||||||
|
|
||||||
var manager = scope.ServiceProvider.GetRequiredService<OpenIddictApplicationManager<OpenIddictEntityFrameworkCoreApplication>>();
|
var manager = scope.ServiceProvider.GetRequiredService<IOpenIddictApplicationManager>();
|
||||||
|
|
||||||
if (await manager.FindByClientIdAsync("console") is null)
|
if (await manager.FindByClientIdAsync("console") is null)
|
||||||
{
|
{
|
||||||
|
@ -45,7 +45,7 @@
|
|||||||
"output": {
|
"output": {
|
||||||
".html": {
|
".html": {
|
||||||
"relative_path": "guide/getting-started.html",
|
"relative_path": "guide/getting-started.html",
|
||||||
"hash": "B+LUpBca5+kh6NFTvwCenQ=="
|
"hash": "EubGbQd6qMqQ/UD3oj2WIw=="
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"is_incremental": false,
|
"is_incremental": false,
|
||||||
|
Loading…
Reference in New Issue
Block a user