mirror of
https://gitee.com/dcren/openiddict-documentation.git
synced 2025-09-22 12:09:18 +08:00
Update the documentation pages
This commit is contained in:
@@ -76,7 +76,7 @@
|
|||||||
<div class="NOTE"><h5>Note</h5><p>Tokens generated using the opt-in ASP.NET Core Data Protection integration rely on their own key ring, distinct from the credentials discussed in this documentation.
|
<div class="NOTE"><h5>Note</h5><p>Tokens generated using the opt-in ASP.NET Core Data Protection integration rely on their own key ring, distinct from the credentials discussed in this documentation.
|
||||||
For more information about Data Protection, visit <a href="https://docs.microsoft.com/en-us/aspnet/core/security/data-protection/introduction">ASP.NET Core Data Protection</a>.</p>
|
For more information about Data Protection, visit <a href="https://docs.microsoft.com/en-us/aspnet/core/security/data-protection/introduction">ASP.NET Core Data Protection</a>.</p>
|
||||||
</div>
|
</div>
|
||||||
<h2 id="registering-credentials-in-the-server-options">Registering credentials in the server options</h2>
|
<h2 id="registering-credentials-in-the-authorization-server-options">Registering credentials in the authorization server options</h2>
|
||||||
<p>OpenIddict allows registering one or multiple keys (raw keys or embedded in X.509 certificates).</p>
|
<p>OpenIddict allows registering one or multiple keys (raw keys or embedded in X.509 certificates).</p>
|
||||||
<div class="NOTE"><h5>Note</h5><p>When multiple keys/certificates are registered (which can be useful to implement keys rotation), OpenIddict chooses the most appropriate key based on the following algorithm:</p>
|
<div class="NOTE"><h5>Note</h5><p>When multiple keys/certificates are registered (which can be useful to implement keys rotation), OpenIddict chooses the most appropriate key based on the following algorithm:</p>
|
||||||
<ul>
|
<ul>
|
||||||
@@ -161,7 +161,7 @@ var data = certificate.Export(X509ContentType.Pfx, string.Empty);
|
|||||||
<li>On Azure, certificates can be uploaded and exposed to Azure App Services applications using the special <code>WEBSITE_LOAD_CERTIFICATES</code> flag.
|
<li>On Azure, certificates can be uploaded and exposed to Azure App Services applications using the special <code>WEBSITE_LOAD_CERTIFICATES</code> flag.
|
||||||
For more information, visit <a href="https://docs.microsoft.com/en-us/azure/app-service/configure-ssl-certificate-in-code">https://docs.microsoft.com/en-us/azure/app-service/configure-ssl-certificate-in-code</a></li>
|
For more information, visit <a href="https://docs.microsoft.com/en-us/azure/app-service/configure-ssl-certificate-in-code">https://docs.microsoft.com/en-us/azure/app-service/configure-ssl-certificate-in-code</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
<h2 id="importing-credentials-in-the-validation-options">Importing credentials in the validation options</h2>
|
<h2 id="importing-credentials-in-the-apiresource-validation-options">Importing credentials in the API/resource validation options</h2>
|
||||||
<h3 id="using-the-optionsuselocalserver-integration">Using the <code>options.UseLocalServer()</code> integration</h3>
|
<h3 id="using-the-optionsuselocalserver-integration">Using the <code>options.UseLocalServer()</code> integration</h3>
|
||||||
<p>When the API and the authorization server are part of the same project, both the signing and
|
<p>When the API and the authorization server are part of the same project, both the signing and
|
||||||
encryption credentials can be easily imported by calling <code>options.UseLocalServer()</code>:</p>
|
encryption credentials can be easily imported by calling <code>options.UseLocalServer()</code>:</p>
|
||||||
|
229
configuration/mongodb-integration.html
Normal file
229
configuration/mongodb-integration.html
Normal file
@@ -0,0 +1,229 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<!--[if IE]><![endif]-->
|
||||||
|
<html>
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||||
|
<title>MongoDB integration </title>
|
||||||
|
<meta name="viewport" content="width=device-width">
|
||||||
|
<meta name="title" content="MongoDB integration ">
|
||||||
|
<meta name="generator" content="docfx 2.56.7.0">
|
||||||
|
|
||||||
|
<link rel="shortcut icon" href="../images/favicon.ico">
|
||||||
|
<link rel="stylesheet" href="../styles/docfx.vendor.css">
|
||||||
|
<link rel="stylesheet" href="../styles/docfx.css">
|
||||||
|
<link rel="stylesheet" href="../styles/main.css">
|
||||||
|
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
|
||||||
|
<meta property="docfx:navrel" content="../toc.html">
|
||||||
|
<meta property="docfx:tocrel" content="toc.html">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</head> <body data-spy="scroll" data-target="#affix" data-offset="120">
|
||||||
|
<div id="wrapper">
|
||||||
|
<header>
|
||||||
|
|
||||||
|
<nav id="autocollapse" class="navbar navbar-inverse ng-scope" role="navigation">
|
||||||
|
<div class="container">
|
||||||
|
<div class="navbar-header">
|
||||||
|
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar">
|
||||||
|
<span class="sr-only">Toggle navigation</span>
|
||||||
|
<span class="icon-bar"></span>
|
||||||
|
<span class="icon-bar"></span>
|
||||||
|
<span class="icon-bar"></span>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<a class="navbar-brand" href="../index.html">
|
||||||
|
<img id="logo" class="svg" src="../images/logo.png" alt="">
|
||||||
|
</a> </div>
|
||||||
|
<div class="collapse navbar-collapse" id="navbar">
|
||||||
|
<form class="navbar-form navbar-right" role="search" id="search">
|
||||||
|
<div class="form-group">
|
||||||
|
<input type="text" class="form-control" id="search-query" placeholder="Search" autocomplete="off">
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
<div class="subnav navbar navbar-default">
|
||||||
|
<div class="container hide-when-search" id="breadcrumb">
|
||||||
|
<ul class="breadcrumb">
|
||||||
|
<li></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
<div role="main" class="container body-content hide-when-search">
|
||||||
|
|
||||||
|
<div class="sidenav hide-when-search">
|
||||||
|
<a class="btn toc-toggle collapse" data-toggle="collapse" href="#sidetoggle" aria-expanded="false" aria-controls="sidetoggle">Show / Hide Table of Contents</a>
|
||||||
|
<div class="sidetoggle collapse" id="sidetoggle">
|
||||||
|
<div id="sidetoc"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="article row grid-right">
|
||||||
|
<div class="col-md-10">
|
||||||
|
<article class="content wrap" id="_content" data-uid="">
|
||||||
|
<h1 id="mongodb-integration">MongoDB integration</h1>
|
||||||
|
|
||||||
|
<p>To configure OpenIddict to use MongoDB as the database for applications, authorizations, scopes and tokens, you'll need to:</p>
|
||||||
|
<ul>
|
||||||
|
<li><p><strong>Reference the <code>OpenIddict.MongoDb</code> package</strong>:</p>
|
||||||
|
<pre><code class="lang-xml"><PackageReference Include="OpenIddict.MongoDb" Version="3.0.5" />
|
||||||
|
</code></pre></li>
|
||||||
|
<li><p><strong>Configure OpenIddict to use the MongoDB stores</strong>:</p>
|
||||||
|
<pre><code class="lang-csharp">services.AddOpenIddict()
|
||||||
|
.AddCore(options =>
|
||||||
|
{
|
||||||
|
// Note: to use a remote server, call the MongoClient constructor overload
|
||||||
|
// that accepts a connection string or an instance of MongoClientSettings.
|
||||||
|
options.UseMongoDb()
|
||||||
|
.UseDatabase(new MongoClient().GetDatabase("openiddict"));
|
||||||
|
})
|
||||||
|
</code></pre></li>
|
||||||
|
<li><p><strong>Create indexes to improve performance</strong> (recommended): for that, you can use the following script to
|
||||||
|
initialize the database and create the indexes used by the OpenIddict entities:</p>
|
||||||
|
<pre><code class="lang-csharp">using System.Threading;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.Options;
|
||||||
|
using MongoDB.Driver;
|
||||||
|
using OpenIddict.MongoDb;
|
||||||
|
using OpenIddict.MongoDb.Models;
|
||||||
|
|
||||||
|
var services = new ServiceCollection();
|
||||||
|
services.AddOpenIddict()
|
||||||
|
.AddCore(options => options.UseMongoDb());
|
||||||
|
|
||||||
|
services.AddSingleton(new MongoClient("mongodb://localhost:27017").GetDatabase("openiddict"));
|
||||||
|
|
||||||
|
var provider = services.BuildServiceProvider();
|
||||||
|
var context = provider.GetRequiredService<IOpenIddictMongoDbContext>();
|
||||||
|
var options = provider.GetRequiredService<IOptionsMonitor<OpenIddictMongoDbOptions>>().CurrentValue;
|
||||||
|
var database = await context.GetDatabaseAsync(CancellationToken.None);
|
||||||
|
|
||||||
|
var applications = database.GetCollection<OpenIddictMongoDbApplication>(
|
||||||
|
options.ApplicationsCollectionName);
|
||||||
|
|
||||||
|
await applications.Indexes.CreateManyAsync(new[]
|
||||||
|
{
|
||||||
|
new CreateIndexModel<OpenIddictMongoDbApplication>(
|
||||||
|
Builders<OpenIddictMongoDbApplication>.IndexKeys.Ascending(
|
||||||
|
application => application.ClientId),
|
||||||
|
new CreateIndexOptions
|
||||||
|
{
|
||||||
|
Unique = true
|
||||||
|
}),
|
||||||
|
|
||||||
|
new CreateIndexModel<OpenIddictMongoDbApplication>(
|
||||||
|
Builders<OpenIddictMongoDbApplication>.IndexKeys.Ascending(
|
||||||
|
application => application.PostLogoutRedirectUris),
|
||||||
|
new CreateIndexOptions
|
||||||
|
{
|
||||||
|
Background = true
|
||||||
|
}),
|
||||||
|
|
||||||
|
new CreateIndexModel<OpenIddictMongoDbApplication>(
|
||||||
|
Builders<OpenIddictMongoDbApplication>.IndexKeys.Ascending(
|
||||||
|
application => application.RedirectUris),
|
||||||
|
new CreateIndexOptions
|
||||||
|
{
|
||||||
|
Background = true
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
var authorizations = database.GetCollection<OpenIddictMongoDbAuthorization>(
|
||||||
|
options.AuthorizationsCollectionName);
|
||||||
|
|
||||||
|
await authorizations.Indexes.CreateOneAsync(new CreateIndexModel<OpenIddictMongoDbAuthorization>(
|
||||||
|
Builders<OpenIddictMongoDbAuthorization>.IndexKeys
|
||||||
|
.Ascending(authorization => authorization.ApplicationId)
|
||||||
|
.Ascending(authorization => authorization.Scopes)
|
||||||
|
.Ascending(authorization => authorization.Status)
|
||||||
|
.Ascending(authorization => authorization.Subject)
|
||||||
|
.Ascending(authorization => authorization.Type),
|
||||||
|
new CreateIndexOptions
|
||||||
|
{
|
||||||
|
Background = true
|
||||||
|
}));
|
||||||
|
|
||||||
|
var scopes = database.GetCollection<OpenIddictMongoDbScope>(
|
||||||
|
options.ScopesCollectionName);
|
||||||
|
|
||||||
|
await scopes.Indexes.CreateOneAsync(new CreateIndexModel<OpenIddictMongoDbScope>(
|
||||||
|
Builders<OpenIddictMongoDbScope>.IndexKeys.Ascending(scope => scope.Name),
|
||||||
|
new CreateIndexOptions
|
||||||
|
{
|
||||||
|
Unique = true
|
||||||
|
}));
|
||||||
|
|
||||||
|
var tokens = database.GetCollection<OpenIddictMongoDbToken>(
|
||||||
|
options.TokensCollectionName);
|
||||||
|
|
||||||
|
await tokens.Indexes.CreateManyAsync(new[]
|
||||||
|
{
|
||||||
|
new CreateIndexModel<OpenIddictMongoDbToken>(
|
||||||
|
Builders<OpenIddictMongoDbToken>.IndexKeys.Ascending(token => token.ReferenceId),
|
||||||
|
new CreateIndexOptions<OpenIddictMongoDbToken>
|
||||||
|
{
|
||||||
|
// Note: partial filter expressions are not supported on Azure Cosmos DB.
|
||||||
|
// As a workaround, the expression and the unique constraint can be removed.
|
||||||
|
PartialFilterExpression =
|
||||||
|
Builders<OpenIddictMongoDbToken>.Filter.Exists(token => token.ReferenceId),
|
||||||
|
Unique = true
|
||||||
|
}),
|
||||||
|
|
||||||
|
new CreateIndexModel<OpenIddictMongoDbToken>(
|
||||||
|
Builders<OpenIddictMongoDbToken>.IndexKeys
|
||||||
|
.Ascending(token => token.ApplicationId)
|
||||||
|
.Ascending(token => token.Status)
|
||||||
|
.Ascending(token => token.Subject)
|
||||||
|
.Ascending(token => token.Type),
|
||||||
|
new CreateIndexOptions
|
||||||
|
{
|
||||||
|
Background = true
|
||||||
|
})
|
||||||
|
});
|
||||||
|
</code></pre></li>
|
||||||
|
</ul>
|
||||||
|
</article>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="hidden-sm col-md-2" role="complementary">
|
||||||
|
<div class="sideaffix">
|
||||||
|
<div class="contribution">
|
||||||
|
<ul class="nav">
|
||||||
|
<li>
|
||||||
|
<a href="https://github.com/openiddict/openiddict-documentation/blob/dev/configuration/mongodb-integration.md/#L1" class="contribution-link">Improve this Doc</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<nav class="bs-docs-sidebar hidden-print hidden-xs hidden-sm affix" id="affix">
|
||||||
|
<h5>In This Article</h5>
|
||||||
|
<div></div>
|
||||||
|
</nav>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<footer>
|
||||||
|
<div class="grad-bottom"></div>
|
||||||
|
<div class="footer">
|
||||||
|
<div class="container">
|
||||||
|
<span class="pull-right">
|
||||||
|
<a href="#top">Back to top</a>
|
||||||
|
</span>
|
||||||
|
|
||||||
|
<span>Generated by <strong>DocFX</strong></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</footer>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script type="text/javascript" src="../styles/docfx.vendor.js"></script>
|
||||||
|
<script type="text/javascript" src="../styles/docfx.js"></script>
|
||||||
|
<script type="text/javascript" src="../styles/main.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
@@ -27,6 +27,9 @@
|
|||||||
<li>
|
<li>
|
||||||
<a href="encryption-and-signing-credentials.html" name="" title="Encryption and signing credentials">Encryption and signing credentials</a>
|
<a href="encryption-and-signing-credentials.html" name="" title="Encryption and signing credentials">Encryption and signing credentials</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li>
|
||||||
|
<a href="mongodb-integration.html" name="" title="MongoDB integration">MongoDB integration</a>
|
||||||
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="proof-key-for-code-exchange.html" name="" title="Proof Key for Code Exchange">Proof Key for Code Exchange</a>
|
<a href="proof-key-for-code-exchange.html" name="" title="Proof Key for Code Exchange">Proof Key for Code Exchange</a>
|
||||||
</li>
|
</li>
|
||||||
|
@@ -5637,7 +5637,7 @@
|
|||||||
"output": {
|
"output": {
|
||||||
".html": {
|
".html": {
|
||||||
"relative_path": "configuration/encryption-and-signing-credentials.html",
|
"relative_path": "configuration/encryption-and-signing-credentials.html",
|
||||||
"hash": "lvfp+KasSL8PFb2HTzMYhQ=="
|
"hash": "iFuVtyllFrW9BzppnmPRig=="
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"is_incremental": false,
|
"is_incremental": false,
|
||||||
@@ -5655,6 +5655,18 @@
|
|||||||
"is_incremental": false,
|
"is_incremental": false,
|
||||||
"version": ""
|
"version": ""
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "Conceptual",
|
||||||
|
"source_relative_path": "configuration/mongodb-integration.md",
|
||||||
|
"output": {
|
||||||
|
".html": {
|
||||||
|
"relative_path": "configuration/mongodb-integration.html",
|
||||||
|
"hash": "OBbgaaZ+b0E3MY4vEl7/kw=="
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"is_incremental": false,
|
||||||
|
"version": ""
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "Conceptual",
|
"type": "Conceptual",
|
||||||
"source_relative_path": "configuration/proof-key-for-code-exchange.md",
|
"source_relative_path": "configuration/proof-key-for-code-exchange.md",
|
||||||
@@ -5673,7 +5685,7 @@
|
|||||||
"output": {
|
"output": {
|
||||||
".html": {
|
".html": {
|
||||||
"relative_path": "configuration/toc.html",
|
"relative_path": "configuration/toc.html",
|
||||||
"hash": "OsKSxgt/kroRjpQlAjf8PA=="
|
"hash": "v0DMuwk5yrDID+1ORgzjDQ=="
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"is_incremental": false,
|
"is_incremental": false,
|
||||||
@@ -7977,7 +7989,7 @@
|
|||||||
"ConceptualDocumentProcessor": {
|
"ConceptualDocumentProcessor": {
|
||||||
"can_incremental": false,
|
"can_incremental": false,
|
||||||
"incrementalPhase": "build",
|
"incrementalPhase": "build",
|
||||||
"total_file_count": 131,
|
"total_file_count": 132,
|
||||||
"skipped_file_count": 0
|
"skipped_file_count": 0
|
||||||
},
|
},
|
||||||
"ManagedReferenceDocumentProcessor": {
|
"ManagedReferenceDocumentProcessor": {
|
||||||
|
Reference in New Issue
Block a user