diff --git a/src/OpenIddict.Core/OpenIddict.Core.csproj b/src/OpenIddict.Core/OpenIddict.Core.csproj
index 493b8986..ada5a726 100644
--- a/src/OpenIddict.Core/OpenIddict.Core.csproj
+++ b/src/OpenIddict.Core/OpenIddict.Core.csproj
@@ -19,8 +19,8 @@
-
+
diff --git a/src/OpenIddict.Core/OpenIddictCoreExtensions.cs b/src/OpenIddict.Core/OpenIddictCoreExtensions.cs
index 761d6e27..8b72b5af 100644
--- a/src/OpenIddict.Core/OpenIddictCoreExtensions.cs
+++ b/src/OpenIddict.Core/OpenIddictCoreExtensions.cs
@@ -29,8 +29,6 @@ namespace Microsoft.Extensions.DependencyInjection
throw new ArgumentNullException(nameof(builder));
}
- builder.Services.AddDistributedMemoryCache();
- builder.Services.AddMemoryCache();
builder.Services.AddOptions();
builder.Services.TryAddScoped(typeof(OpenIddictApplicationManager<>));
diff --git a/src/OpenIddict.EntityFramework/OpenIddict.EntityFramework.csproj b/src/OpenIddict.EntityFramework/OpenIddict.EntityFramework.csproj
index 73282fc9..37e883cb 100644
--- a/src/OpenIddict.EntityFramework/OpenIddict.EntityFramework.csproj
+++ b/src/OpenIddict.EntityFramework/OpenIddict.EntityFramework.csproj
@@ -19,6 +19,7 @@
+
diff --git a/src/OpenIddict.EntityFramework/OpenIddictEntityFrameworkExtensions.cs b/src/OpenIddict.EntityFramework/OpenIddictEntityFrameworkExtensions.cs
index c1157418..d6833a88 100644
--- a/src/OpenIddict.EntityFramework/OpenIddictEntityFrameworkExtensions.cs
+++ b/src/OpenIddict.EntityFramework/OpenIddictEntityFrameworkExtensions.cs
@@ -32,6 +32,8 @@ namespace Microsoft.Extensions.DependencyInjection
throw new ArgumentNullException(nameof(builder));
}
+ builder.Services.AddMemoryCache();
+
builder.SetDefaultApplicationEntity()
.SetDefaultAuthorizationEntity()
.SetDefaultScopeEntity()
diff --git a/src/OpenIddict.EntityFrameworkCore/OpenIddict.EntityFrameworkCore.csproj b/src/OpenIddict.EntityFrameworkCore/OpenIddict.EntityFrameworkCore.csproj
index b78b2cff..8c8a1cdc 100644
--- a/src/OpenIddict.EntityFrameworkCore/OpenIddict.EntityFrameworkCore.csproj
+++ b/src/OpenIddict.EntityFrameworkCore/OpenIddict.EntityFrameworkCore.csproj
@@ -20,6 +20,7 @@
+
diff --git a/src/OpenIddict.EntityFrameworkCore/OpenIddictEntityFrameworkCoreExtensions.cs b/src/OpenIddict.EntityFrameworkCore/OpenIddictEntityFrameworkCoreExtensions.cs
index ecd86e09..1cc2b553 100644
--- a/src/OpenIddict.EntityFrameworkCore/OpenIddictEntityFrameworkCoreExtensions.cs
+++ b/src/OpenIddict.EntityFrameworkCore/OpenIddictEntityFrameworkCoreExtensions.cs
@@ -30,6 +30,8 @@ namespace Microsoft.Extensions.DependencyInjection
throw new ArgumentNullException(nameof(builder));
}
+ builder.Services.AddMemoryCache();
+
builder.SetDefaultApplicationEntity()
.SetDefaultAuthorizationEntity()
.SetDefaultScopeEntity()
diff --git a/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictApplicationStore.cs b/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictApplicationStore.cs
index b6f40614..16e83ba2 100644
--- a/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictApplicationStore.cs
+++ b/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictApplicationStore.cs
@@ -276,7 +276,7 @@ namespace OpenIddict.EntityFrameworkCore
///
/// Exposes a compiled query allowing to retrieve an application using its client identifier.
///
- private static Func> FindByClientId =
+ private static readonly Func> FindByClientId =
EF.CompileAsyncQuery((TContext context, string identifier) =>
(from application in context.Set().AsTracking()
where application.ClientId == identifier
@@ -304,7 +304,7 @@ namespace OpenIddict.EntityFrameworkCore
///
/// Exposes a compiled query allowing to retrieve an application using its unique identifier.
///
- private static Func> FindById =
+ private static readonly Func> FindById =
EF.CompileAsyncQuery((TContext context, TKey identifier) =>
(from application in context.Set().AsTracking()
where application.Id.Equals(identifier)
@@ -333,7 +333,7 @@ namespace OpenIddict.EntityFrameworkCore
/// Exposes a compiled query allowing to retrieve all the applications
/// associated with the specified post_logout_redirect_uri.
///
- private static Func> FindByPostLogoutRedirectUri =
+ private static readonly Func> FindByPostLogoutRedirectUri =
// To optimize the efficiency of the query a bit, only applications whose stringified
// PostLogoutRedirectUris contains the specified URL are returned. Once the applications
// are retrieved, a second pass is made to ensure only valid elements are returned.
@@ -385,7 +385,7 @@ namespace OpenIddict.EntityFrameworkCore
/// Exposes a compiled query allowing to retrieve all the
/// applications associated with the specified redirect_uri.
///
- private static Func> FindByRedirectUri =
+ private static readonly Func> FindByRedirectUri =
// To optimize the efficiency of the query a bit, only applications whose stringified
// RedirectUris property contains the specified URL are returned. Once the applications
// are retrieved, a second pass is made to ensure only valid elements are returned.
diff --git a/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictAuthorizationStore.cs b/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictAuthorizationStore.cs
index 2d9d826a..f3309daa 100644
--- a/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictAuthorizationStore.cs
+++ b/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictAuthorizationStore.cs
@@ -253,7 +253,7 @@ namespace OpenIddict.EntityFrameworkCore
/// Exposes a compiled query allowing to retrieve the authorizations corresponding
/// to the specified subject and associated with the application identifier.
///
- private static Func> FindBySubjectAndClient =
+ private static readonly Func> FindBySubjectAndClient =
// Note: due to a bug in Entity Framework Core's query visitor, the authorizations can't be
// filtered using authorization.Application.Id.Equals(key). To work around this issue,
// this compiled query uses an explicit join before applying the equality check.
@@ -298,7 +298,7 @@ namespace OpenIddict.EntityFrameworkCore
///
/// Exposes a compiled query allowing to retrieve the authorizations matching the specified parameters.
///
- private static Func> FindBySubjectClientAndStatus =
+ private static readonly Func> FindBySubjectClientAndStatus =
// Note: due to a bug in Entity Framework Core's query visitor, the authorizations can't be
// filtered using authorization.Application.Id.Equals(key). To work around this issue,
// this compiled query uses an explicit join before applying the equality check.
@@ -349,7 +349,7 @@ namespace OpenIddict.EntityFrameworkCore
///
/// Exposes a compiled query allowing to retrieve the authorizations matching the specified parameters.
///
- private static Func> FindBySubjectClientStatusAndType =
+ private static readonly Func> FindBySubjectClientStatusAndType =
// Note: due to a bug in Entity Framework Core's query visitor, the authorizations can't be
// filtered using authorization.Application.Id.Equals(key). To work around this issue,
// this compiled query uses an explicit join before applying the equality check.
@@ -408,7 +408,7 @@ namespace OpenIddict.EntityFrameworkCore
///
/// Exposes a compiled query allowing to retrieve an authorization using its unique identifier.
///
- private static Func> FindById =
+ private static readonly Func> FindById =
EF.CompileAsyncQuery((TContext context, TKey identifier) =>
(from authorization in context.Set()
.Include(authorization => authorization.Application)
@@ -439,7 +439,7 @@ namespace OpenIddict.EntityFrameworkCore
/// Exposes a compiled query allowing to retrieve all the
/// authorizations corresponding to the specified subject.
///
- private static Func> FindBySubject =
+ private static readonly Func> FindBySubject =
EF.CompileAsyncQuery((TContext context, string subject) =>
from authorization in context.Set()
.Include(authorization => authorization.Application)
diff --git a/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictScopeStore.cs b/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictScopeStore.cs
index a8364dd7..4d49c6e1 100644
--- a/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictScopeStore.cs
+++ b/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictScopeStore.cs
@@ -183,7 +183,7 @@ namespace OpenIddict.EntityFrameworkCore
///
/// Exposes a compiled query allowing to retrieve a scope using its unique identifier.
///
- private static Func> FindById =
+ private static readonly Func> FindById =
EF.CompileAsyncQuery((TContext context, TKey identifier) =>
(from scope in context.Set().AsTracking()
where scope.Id.Equals(identifier)
@@ -211,7 +211,7 @@ namespace OpenIddict.EntityFrameworkCore
///
/// Exposes a compiled query allowing to retrieve a scope using its name.
///
- private static Func> FindByName =
+ private static readonly Func> FindByName =
EF.CompileAsyncQuery((TContext context, string name) =>
(from scope in context.Set().AsTracking()
where scope.Name == name
@@ -239,7 +239,7 @@ namespace OpenIddict.EntityFrameworkCore
///
/// Exposes a compiled query allowing to retrieve a list of scopes using their name.
///
- private static Func, AsyncEnumerable> FindByNames =
+ private static readonly Func, AsyncEnumerable> FindByNames =
EF.CompileAsyncQuery((TContext context, ImmutableArray names) =>
from scope in context.Set().AsTracking()
where names.Contains(scope.Name)
@@ -268,7 +268,7 @@ namespace OpenIddict.EntityFrameworkCore
///
/// Exposes a compiled query allowing to retrieve all the scopes that contain the specified resource.
///
- private static Func> FindByResource =
+ private static readonly Func> FindByResource =
// To optimize the efficiency of the query a bit, only scopes whose stringified
// Resources column contains the specified resource are returned. Once the scopes
// are retrieved, a second pass is made to ensure only valid elements are returned.
diff --git a/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictTokenStore.cs b/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictTokenStore.cs
index 59c5590b..5df6a271 100644
--- a/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictTokenStore.cs
+++ b/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictTokenStore.cs
@@ -206,7 +206,7 @@ namespace OpenIddict.EntityFrameworkCore
/// Exposes a compiled query allowing to retrieve the list of
/// tokens corresponding to the specified application identifier.
///
- private static Func> FindByApplicationId =
+ private static readonly Func> FindByApplicationId =
// Note: due to a bug in Entity Framework Core's query visitor, the tokens can't be
// filtered using token.Application.Id.Equals(key). To work around this issue,
// this compiled query uses an explicit join before applying the equality check.
@@ -244,7 +244,7 @@ namespace OpenIddict.EntityFrameworkCore
/// Exposes a compiled query allowing to retrieve the list of
/// tokens corresponding to the specified authorization identifier.
///
- private static Func> FindByAuthorizationId =
+ private static readonly Func> FindByAuthorizationId =
// Note: due to a bug in Entity Framework Core's query visitor, the tokens can't be
// filtered using token.Authorization.Id.Equals(key). To work around this issue,
// this compiled query uses an explicit join before applying the equality check.
@@ -281,7 +281,7 @@ namespace OpenIddict.EntityFrameworkCore
///
/// Exposes a compiled query allowing to retrieve a token using its unique identifier.
///
- private static Func> FindById =
+ private static readonly Func> FindById =
EF.CompileAsyncQuery((TContext context, TKey identifier) =>
(from token in context.Set()
.Include(token => token.Application)
@@ -313,7 +313,7 @@ namespace OpenIddict.EntityFrameworkCore
/// Exposes a compiled query allowing to retrieve the list of
/// tokens corresponding to the specified reference identifier.
///
- private static Func> FindByReferenceId =
+ private static readonly Func> FindByReferenceId =
EF.CompileAsyncQuery((TContext context, string identifier) =>
(from token in context.Set()
.Include(token => token.Application)
@@ -346,7 +346,7 @@ namespace OpenIddict.EntityFrameworkCore
/// Exposes a compiled query allowing to retrieve the
/// list of tokens corresponding to the specified subject.
///
- private static Func> FindBySubject =
+ private static readonly Func> FindBySubject =
EF.CompileAsyncQuery((TContext context, string subject) =>
from token in context.Set()
.Include(token => token.Application)
diff --git a/src/OpenIddict.MongoDb/OpenIddict.MongoDb.csproj b/src/OpenIddict.MongoDb/OpenIddict.MongoDb.csproj
index 6f4455e2..9310c7e3 100644
--- a/src/OpenIddict.MongoDb/OpenIddict.MongoDb.csproj
+++ b/src/OpenIddict.MongoDb/OpenIddict.MongoDb.csproj
@@ -21,6 +21,7 @@
+
diff --git a/src/OpenIddict.MongoDb/OpenIddictMongoDbExtensions.cs b/src/OpenIddict.MongoDb/OpenIddictMongoDbExtensions.cs
index e54c4c1a..8215db7f 100644
--- a/src/OpenIddict.MongoDb/OpenIddictMongoDbExtensions.cs
+++ b/src/OpenIddict.MongoDb/OpenIddictMongoDbExtensions.cs
@@ -29,6 +29,8 @@ namespace Microsoft.Extensions.DependencyInjection
throw new ArgumentNullException(nameof(builder));
}
+ builder.Services.AddMemoryCache();
+
builder.SetDefaultApplicationEntity()
.SetDefaultAuthorizationEntity()
.SetDefaultScopeEntity()
diff --git a/src/OpenIddict.Server/OpenIddictServerExtensions.cs b/src/OpenIddict.Server/OpenIddictServerExtensions.cs
index 9a13deb2..e2541fd7 100644
--- a/src/OpenIddict.Server/OpenIddictServerExtensions.cs
+++ b/src/OpenIddict.Server/OpenIddictServerExtensions.cs
@@ -33,6 +33,9 @@ namespace Microsoft.Extensions.DependencyInjection
}
builder.Services.AddAuthentication();
+ builder.Services.AddDistributedMemoryCache();
+ builder.Services.AddMemoryCache();
+ builder.Services.AddOptions();
builder.Services.TryAddScoped();
builder.Services.TryAddScoped();
diff --git a/src/OpenIddict.Validation/OpenIddictValidationExtensions.cs b/src/OpenIddict.Validation/OpenIddictValidationExtensions.cs
index 438f6ad6..cac9a165 100644
--- a/src/OpenIddict.Validation/OpenIddictValidationExtensions.cs
+++ b/src/OpenIddict.Validation/OpenIddictValidationExtensions.cs
@@ -33,6 +33,7 @@ namespace Microsoft.Extensions.DependencyInjection
}
builder.Services.AddAuthentication();
+ builder.Services.AddOptions();
builder.Services.TryAddScoped();
builder.Services.TryAddScoped();