diff --git a/src/OpenIddict.MongoDb.Models/OpenIddictMongoDbApplication.cs b/src/OpenIddict.MongoDb.Models/OpenIddictMongoDbApplication.cs index 0e1a6498..73180c99 100644 --- a/src/OpenIddict.MongoDb.Models/OpenIddictMongoDbApplication.cs +++ b/src/OpenIddict.MongoDb.Models/OpenIddictMongoDbApplication.cs @@ -21,8 +21,7 @@ namespace OpenIddict.MongoDb.Models public class OpenIddictMongoDbApplication { /// - /// Gets or sets the client identifier - /// associated with the current application. + /// Gets or sets the client identifier associated with the current application. /// [BsonElement("client_id"), BsonIgnoreIfNull] public virtual string? ClientId { get; set; } @@ -42,30 +41,26 @@ namespace OpenIddict.MongoDb.Models public virtual string? ConcurrencyToken { get; set; } = Guid.NewGuid().ToString(); /// - /// Gets or sets the consent type - /// associated with the current application. + /// Gets or sets the consent type associated with the current application. /// [BsonElement("consent_type"), BsonIgnoreIfNull] public virtual string? ConsentType { get; set; } /// - /// Gets or sets the display name - /// associated with the current application. + /// Gets or sets the display name associated with the current application. /// [BsonElement("display_name"), BsonIgnoreIfNull] public virtual string? DisplayName { get; set; } /// - /// Gets or sets the localized display names - /// associated with the current application. + /// Gets or sets the localized display names associated with the current application. /// [BsonElement("display_names"), BsonIgnoreIfNull] public virtual IReadOnlyDictionary DisplayNames { get; set; } = ImmutableDictionary.Create(); /// - /// Gets or sets the unique identifier - /// associated with the current application. + /// Gets or sets the unique identifier associated with the current application. /// [BsonId, BsonRequired] public virtual ObjectId Id { get; set; } diff --git a/src/OpenIddict.MongoDb.Models/OpenIddictMongoDbAuthorization.cs b/src/OpenIddict.MongoDb.Models/OpenIddictMongoDbAuthorization.cs index afa171c6..6e78ffa3 100644 --- a/src/OpenIddict.MongoDb.Models/OpenIddictMongoDbAuthorization.cs +++ b/src/OpenIddict.MongoDb.Models/OpenIddictMongoDbAuthorization.cs @@ -20,8 +20,7 @@ namespace OpenIddict.MongoDb.Models public class OpenIddictMongoDbAuthorization { /// - /// Gets or sets the identifier of the application - /// associated with the current authorization. + /// Gets or sets the identifier of the application associated with the current authorization. /// [BsonElement("application_id"), BsonIgnoreIfDefault] public virtual ObjectId ApplicationId { get; set; } @@ -33,8 +32,7 @@ namespace OpenIddict.MongoDb.Models public virtual string? ConcurrencyToken { get; set; } = Guid.NewGuid().ToString(); /// - /// Gets or sets the unique identifier - /// associated with the current authorization. + /// Gets or sets the unique identifier associated with the current authorization. /// [BsonId, BsonRequired] public virtual ObjectId Id { get; set; } diff --git a/src/OpenIddict.MongoDb.Models/OpenIddictMongoDbScope.cs b/src/OpenIddict.MongoDb.Models/OpenIddictMongoDbScope.cs index 55488014..7d61a902 100644 --- a/src/OpenIddict.MongoDb.Models/OpenIddictMongoDbScope.cs +++ b/src/OpenIddict.MongoDb.Models/OpenIddictMongoDbScope.cs @@ -27,45 +27,39 @@ namespace OpenIddict.MongoDb.Models public virtual string? ConcurrencyToken { get; set; } = Guid.NewGuid().ToString(); /// - /// Gets or sets the public description - /// associated with the current scope. + /// Gets or sets the public description associated with the current scope. /// [BsonElement("description"), BsonIgnoreIfNull] public virtual string? Description { get; set; } /// - /// Gets or sets the localized public descriptions - /// associated with the current scope. + /// Gets or sets the localized public descriptions associated with the current scope. /// [BsonElement("descriptions"), BsonIgnoreIfNull] public virtual IReadOnlyDictionary Descriptions { get; set; } = ImmutableDictionary.Create(); /// - /// Gets or sets the display name - /// associated with the current scope. + /// Gets or sets the display name associated with the current scope. /// [BsonElement("display_name"), BsonIgnoreIfNull] public virtual string? DisplayName { get; set; } /// - /// Gets or sets the localized display names - /// associated with the current scope. + /// Gets or sets the localized display names associated with the current scope. /// [BsonElement("display_names"), BsonIgnoreIfNull] public virtual IReadOnlyDictionary DisplayNames { get; set; } = ImmutableDictionary.Create(); /// - /// Gets or sets the unique identifier - /// associated with the current scope. + /// Gets or sets the unique identifier associated with the current scope. /// [BsonId, BsonRequired] public virtual ObjectId Id { get; set; } /// - /// Gets or sets the unique name - /// associated with the current scope. + /// Gets or sets the unique name associated with the current scope. /// [BsonElement("name"), BsonIgnoreIfNull] public virtual string? Name { get; set; } diff --git a/src/OpenIddict.MongoDb.Models/OpenIddictMongoDbToken.cs b/src/OpenIddict.MongoDb.Models/OpenIddictMongoDbToken.cs index 01731de1..7a5f177f 100644 --- a/src/OpenIddict.MongoDb.Models/OpenIddictMongoDbToken.cs +++ b/src/OpenIddict.MongoDb.Models/OpenIddictMongoDbToken.cs @@ -36,22 +36,19 @@ namespace OpenIddict.MongoDb.Models public virtual string? ConcurrencyToken { get; set; } = Guid.NewGuid().ToString(); /// - /// Gets or sets the date on which the token - /// will start to be considered valid. + /// Gets or sets the date on which the token will start to be considered valid. /// [BsonElement("creation_date"), BsonIgnoreIfNull] public virtual DateTime? CreationDate { get; set; } /// - /// Gets or sets the date on which the token - /// will no longer be considered valid. + /// Gets or sets the date on which the token will no longer be considered valid. /// [BsonElement("expiration_date"), BsonIgnoreIfNull] public virtual DateTime? ExpirationDate { get; set; } /// - /// Gets or sets the unique identifier - /// associated with the current token. + /// Gets or sets the unique identifier associated with the current token. /// [BsonId, BsonRequired] public virtual ObjectId Id { get; set; } diff --git a/src/OpenIddict.MongoDb/OpenIddict.MongoDb.csproj b/src/OpenIddict.MongoDb/OpenIddict.MongoDb.csproj index 189920ca..3f756d40 100644 --- a/src/OpenIddict.MongoDb/OpenIddict.MongoDb.csproj +++ b/src/OpenIddict.MongoDb/OpenIddict.MongoDb.csproj @@ -2,6 +2,7 @@ net461;netcoreapp2.1;netcoreapp3.1;netstandard2.0;netstandard2.1 + enable false false diff --git a/src/OpenIddict.MongoDb/OpenIddictMongoDbBuilder.cs b/src/OpenIddict.MongoDb/OpenIddictMongoDbBuilder.cs index f42b4734..a94c9196 100644 --- a/src/OpenIddict.MongoDb/OpenIddictMongoDbBuilder.cs +++ b/src/OpenIddict.MongoDb/OpenIddictMongoDbBuilder.cs @@ -6,7 +6,6 @@ using System; using System.ComponentModel; -using JetBrains.Annotations; using MongoDB.Driver; using OpenIddict.Core; using OpenIddict.MongoDb; @@ -24,7 +23,7 @@ namespace Microsoft.Extensions.DependencyInjection /// Initializes a new instance of . /// /// The services collection. - public OpenIddictMongoDbBuilder([NotNull] IServiceCollection services) + public OpenIddictMongoDbBuilder(IServiceCollection services) => Services = services ?? throw new ArgumentNullException(nameof(services)); /// @@ -39,7 +38,7 @@ namespace Microsoft.Extensions.DependencyInjection /// The delegate used to configure the OpenIddict options. /// This extension can be safely called multiple times. /// The . - public OpenIddictMongoDbBuilder Configure([NotNull] Action configuration) + public OpenIddictMongoDbBuilder Configure(Action configuration) { if (configuration == null) { @@ -104,7 +103,7 @@ namespace Microsoft.Extensions.DependencyInjection /// /// The collection name /// The . - public OpenIddictMongoDbBuilder SetApplicationsCollectionName([NotNull] string name) + public OpenIddictMongoDbBuilder SetApplicationsCollectionName(string name) { if (string.IsNullOrEmpty(name)) { @@ -119,7 +118,7 @@ namespace Microsoft.Extensions.DependencyInjection /// /// The collection name /// The . - public OpenIddictMongoDbBuilder SetAuthorizationsCollectionName([NotNull] string name) + public OpenIddictMongoDbBuilder SetAuthorizationsCollectionName(string name) { if (string.IsNullOrEmpty(name)) { @@ -134,7 +133,7 @@ namespace Microsoft.Extensions.DependencyInjection /// /// The collection name /// The . - public OpenIddictMongoDbBuilder SetScopesCollectionName([NotNull] string name) + public OpenIddictMongoDbBuilder SetScopesCollectionName(string name) { if (string.IsNullOrEmpty(name)) { @@ -149,7 +148,7 @@ namespace Microsoft.Extensions.DependencyInjection /// /// The collection name /// The . - public OpenIddictMongoDbBuilder SetTokensCollectionName([NotNull] string name) + public OpenIddictMongoDbBuilder SetTokensCollectionName(string name) { if (string.IsNullOrEmpty(name)) { @@ -165,7 +164,7 @@ namespace Microsoft.Extensions.DependencyInjection /// /// The . /// The . - public OpenIddictMongoDbBuilder UseDatabase([NotNull] IMongoDatabase database) + public OpenIddictMongoDbBuilder UseDatabase(IMongoDatabase database) { if (database == null) { @@ -181,7 +180,7 @@ namespace Microsoft.Extensions.DependencyInjection /// The object to compare with the current object. /// true if the specified object is equal to the current object; otherwise, false. [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals([CanBeNull] object obj) => base.Equals(obj); + public override bool Equals(object? obj) => base.Equals(obj); /// /// Serves as the default hash function. @@ -195,6 +194,6 @@ namespace Microsoft.Extensions.DependencyInjection /// /// A string that represents the current object. [EditorBrowsable(EditorBrowsableState.Never)] - public override string ToString() => base.ToString(); + public override string? ToString() => base.ToString(); } } diff --git a/src/OpenIddict.MongoDb/OpenIddictMongoDbContext.cs b/src/OpenIddict.MongoDb/OpenIddictMongoDbContext.cs index 2733d76d..a28167fc 100644 --- a/src/OpenIddict.MongoDb/OpenIddictMongoDbContext.cs +++ b/src/OpenIddict.MongoDb/OpenIddictMongoDbContext.cs @@ -7,7 +7,6 @@ using System; using System.Threading; using System.Threading.Tasks; -using JetBrains.Annotations; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; using MongoDB.Driver; @@ -15,29 +14,21 @@ using SR = OpenIddict.Abstractions.OpenIddictResources; namespace OpenIddict.MongoDb { - /// - /// Exposes the MongoDB database used by the OpenIddict stores. - /// + /// public class OpenIddictMongoDbContext : IOpenIddictMongoDbContext { private readonly IOptionsMonitor _options; private readonly IServiceProvider _provider; public OpenIddictMongoDbContext( - [NotNull] IOptionsMonitor options, - [NotNull] IServiceProvider provider) + IOptionsMonitor options, + IServiceProvider provider) { _options = options; _provider = provider; } - /// - /// Gets the . - /// - /// - /// A that can be used to monitor the - /// asynchronous operation, whose result returns the MongoDB database. - /// + /// public ValueTask GetDatabaseAsync(CancellationToken cancellationToken) { if (cancellationToken.IsCancellationRequested) diff --git a/src/OpenIddict.MongoDb/OpenIddictMongoDbExtensions.cs b/src/OpenIddict.MongoDb/OpenIddictMongoDbExtensions.cs index fb60a184..21594a3a 100644 --- a/src/OpenIddict.MongoDb/OpenIddictMongoDbExtensions.cs +++ b/src/OpenIddict.MongoDb/OpenIddictMongoDbExtensions.cs @@ -5,7 +5,6 @@ */ using System; -using JetBrains.Annotations; using Microsoft.Extensions.DependencyInjection.Extensions; using OpenIddict.MongoDb; using OpenIddict.MongoDb.Models; @@ -24,7 +23,7 @@ namespace Microsoft.Extensions.DependencyInjection /// The services builder used by OpenIddict to register new services. /// This extension can be safely called multiple times. /// The . - public static OpenIddictMongoDbBuilder UseMongoDb([NotNull] this OpenIddictCoreBuilder builder) + public static OpenIddictMongoDbBuilder UseMongoDb(this OpenIddictCoreBuilder builder) { if (builder == null) { @@ -66,8 +65,7 @@ namespace Microsoft.Extensions.DependencyInjection /// This extension can be safely called multiple times. /// The . public static OpenIddictCoreBuilder UseMongoDb( - [NotNull] this OpenIddictCoreBuilder builder, - [NotNull] Action configuration) + this OpenIddictCoreBuilder builder, Action configuration) { if (builder == null) { diff --git a/src/OpenIddict.MongoDb/OpenIddictMongoDbHelpers.cs b/src/OpenIddict.MongoDb/OpenIddictMongoDbHelpers.cs index 60d47e14..e3b29207 100644 --- a/src/OpenIddict.MongoDb/OpenIddictMongoDbHelpers.cs +++ b/src/OpenIddict.MongoDb/OpenIddictMongoDbHelpers.cs @@ -9,7 +9,6 @@ using System.Collections.Generic; using System.Linq; using System.Runtime.CompilerServices; using System.Threading; -using JetBrains.Annotations; namespace MongoDB.Driver { @@ -25,7 +24,7 @@ namespace MongoDB.Driver /// The query source. /// The that can be used to abort the operation. /// The streamed async enumeration containing the results. - internal static IAsyncEnumerable ToAsyncEnumerable([NotNull] this IAsyncCursorSource source, CancellationToken cancellationToken) + internal static IAsyncEnumerable ToAsyncEnumerable(this IAsyncCursorSource source, CancellationToken cancellationToken) { if (source == null) { @@ -55,7 +54,7 @@ namespace MongoDB.Driver /// The query source. /// The that can be used to abort the operation. /// The streamed async enumeration containing the results. - internal static IAsyncEnumerable ToAsyncEnumerable([NotNull] this IQueryable source, CancellationToken cancellationToken) + internal static IAsyncEnumerable ToAsyncEnumerable(this IQueryable source, CancellationToken cancellationToken) { if (source == null) { diff --git a/src/OpenIddict.MongoDb/OpenIddictMongoDbOptions.cs b/src/OpenIddict.MongoDb/OpenIddictMongoDbOptions.cs index d8abbec3..8857fd58 100644 --- a/src/OpenIddict.MongoDb/OpenIddictMongoDbOptions.cs +++ b/src/OpenIddict.MongoDb/OpenIddictMongoDbOptions.cs @@ -27,7 +27,7 @@ namespace OpenIddict.MongoDb /// Gets or sets the used by the OpenIddict stores. /// If no value is explicitly set, the database is resolved from the DI container. /// - public IMongoDatabase Database { get; set; } + public IMongoDatabase? Database { get; set; } /// /// Gets or sets the name of the scopes collection (by default, openiddict.scopes). diff --git a/src/OpenIddict.MongoDb/Resolvers/OpenIddictMongoDbApplicationStoreResolver.cs b/src/OpenIddict.MongoDb/Resolvers/OpenIddictMongoDbApplicationStoreResolver.cs index ffe26ea2..1a8e93a9 100644 --- a/src/OpenIddict.MongoDb/Resolvers/OpenIddictMongoDbApplicationStoreResolver.cs +++ b/src/OpenIddict.MongoDb/Resolvers/OpenIddictMongoDbApplicationStoreResolver.cs @@ -6,7 +6,6 @@ using System; using System.Collections.Concurrent; -using JetBrains.Annotations; using Microsoft.Extensions.DependencyInjection; using OpenIddict.Abstractions; using OpenIddict.MongoDb.Models; @@ -22,7 +21,7 @@ namespace OpenIddict.MongoDb private readonly ConcurrentDictionary _cache = new ConcurrentDictionary(); private readonly IServiceProvider _provider; - public OpenIddictMongoDbApplicationStoreResolver([NotNull] IServiceProvider provider) + public OpenIddictMongoDbApplicationStoreResolver(IServiceProvider provider) => _provider = provider; /// diff --git a/src/OpenIddict.MongoDb/Resolvers/OpenIddictMongoDbAuthorizationStoreResolver.cs b/src/OpenIddict.MongoDb/Resolvers/OpenIddictMongoDbAuthorizationStoreResolver.cs index 2ecbae71..a4296f20 100644 --- a/src/OpenIddict.MongoDb/Resolvers/OpenIddictMongoDbAuthorizationStoreResolver.cs +++ b/src/OpenIddict.MongoDb/Resolvers/OpenIddictMongoDbAuthorizationStoreResolver.cs @@ -6,7 +6,6 @@ using System; using System.Collections.Concurrent; -using JetBrains.Annotations; using Microsoft.Extensions.DependencyInjection; using OpenIddict.Abstractions; using OpenIddict.MongoDb.Models; @@ -22,7 +21,7 @@ namespace OpenIddict.MongoDb private readonly ConcurrentDictionary _cache = new ConcurrentDictionary(); private readonly IServiceProvider _provider; - public OpenIddictMongoDbAuthorizationStoreResolver([NotNull] IServiceProvider provider) + public OpenIddictMongoDbAuthorizationStoreResolver(IServiceProvider provider) => _provider = provider; /// diff --git a/src/OpenIddict.MongoDb/Resolvers/OpenIddictMongoDbScopeStoreResolver.cs b/src/OpenIddict.MongoDb/Resolvers/OpenIddictMongoDbScopeStoreResolver.cs index 4316ae02..da5143d8 100644 --- a/src/OpenIddict.MongoDb/Resolvers/OpenIddictMongoDbScopeStoreResolver.cs +++ b/src/OpenIddict.MongoDb/Resolvers/OpenIddictMongoDbScopeStoreResolver.cs @@ -6,7 +6,6 @@ using System; using System.Collections.Concurrent; -using JetBrains.Annotations; using Microsoft.Extensions.DependencyInjection; using OpenIddict.Abstractions; using OpenIddict.MongoDb.Models; @@ -22,7 +21,7 @@ namespace OpenIddict.MongoDb private readonly ConcurrentDictionary _cache = new ConcurrentDictionary(); private readonly IServiceProvider _provider; - public OpenIddictMongoDbScopeStoreResolver([NotNull] IServiceProvider provider) + public OpenIddictMongoDbScopeStoreResolver(IServiceProvider provider) => _provider = provider; /// diff --git a/src/OpenIddict.MongoDb/Resolvers/OpenIddictMongoDbTokenStoreResolver.cs b/src/OpenIddict.MongoDb/Resolvers/OpenIddictMongoDbTokenStoreResolver.cs index 7caed348..22ba1c5f 100644 --- a/src/OpenIddict.MongoDb/Resolvers/OpenIddictMongoDbTokenStoreResolver.cs +++ b/src/OpenIddict.MongoDb/Resolvers/OpenIddictMongoDbTokenStoreResolver.cs @@ -6,7 +6,6 @@ using System; using System.Collections.Concurrent; -using JetBrains.Annotations; using Microsoft.Extensions.DependencyInjection; using OpenIddict.Abstractions; using OpenIddict.MongoDb.Models; @@ -22,7 +21,7 @@ namespace OpenIddict.MongoDb private readonly ConcurrentDictionary _cache = new ConcurrentDictionary(); private readonly IServiceProvider _provider; - public OpenIddictMongoDbTokenStoreResolver([NotNull] IServiceProvider provider) + public OpenIddictMongoDbTokenStoreResolver(IServiceProvider provider) => _provider = provider; /// diff --git a/src/OpenIddict.MongoDb/Stores/OpenIddictMongoDbApplicationStore.cs b/src/OpenIddict.MongoDb/Stores/OpenIddictMongoDbApplicationStore.cs index 4741da00..d8edb8fb 100644 --- a/src/OpenIddict.MongoDb/Stores/OpenIddictMongoDbApplicationStore.cs +++ b/src/OpenIddict.MongoDb/Stores/OpenIddictMongoDbApplicationStore.cs @@ -14,7 +14,6 @@ using System.Text.Encodings.Web; using System.Text.Json; using System.Threading; using System.Threading.Tasks; -using JetBrains.Annotations; using Microsoft.Extensions.Options; using MongoDB.Bson; using MongoDB.Driver; @@ -33,8 +32,8 @@ namespace OpenIddict.MongoDb where TApplication : OpenIddictMongoDbApplication { public OpenIddictMongoDbApplicationStore( - [NotNull] IOpenIddictMongoDbContext context, - [NotNull] IOptionsMonitor options) + IOpenIddictMongoDbContext context, + IOptionsMonitor options) { Context = context; Options = options; @@ -50,14 +49,7 @@ namespace OpenIddict.MongoDb /// protected IOptionsMonitor Options { get; } - /// - /// Determines the number of applications that exist in the database. - /// - /// The that can be used to abort the operation. - /// - /// A that can be used to monitor the asynchronous operation, - /// whose result returns the number of applications in the database. - /// + /// public virtual async ValueTask CountAsync(CancellationToken cancellationToken) { var database = await Context.GetDatabaseAsync(cancellationToken); @@ -66,18 +58,9 @@ namespace OpenIddict.MongoDb return await collection.CountDocumentsAsync(FilterDefinition.Empty, null, cancellationToken); } - /// - /// Determines the number of applications that match the specified query. - /// - /// The result type. - /// The query to execute. - /// The that can be used to abort the operation. - /// - /// A that can be used to monitor the asynchronous operation, - /// whose result returns the number of applications that match the specified query. - /// + /// public virtual async ValueTask CountAsync( - [NotNull] Func, IQueryable> query, CancellationToken cancellationToken) + Func, IQueryable> query, CancellationToken cancellationToken) { if (query == null) { @@ -90,13 +73,8 @@ namespace OpenIddict.MongoDb return await ((IMongoQueryable) query(collection.AsQueryable())).LongCountAsync(cancellationToken); } - /// - /// Creates a new application. - /// - /// The application to create. - /// The that can be used to abort the operation. - /// A that can be used to monitor the asynchronous operation. - public virtual async ValueTask CreateAsync([NotNull] TApplication application, CancellationToken cancellationToken) + /// + public virtual async ValueTask CreateAsync(TApplication application, CancellationToken cancellationToken) { if (application == null) { @@ -109,13 +87,8 @@ namespace OpenIddict.MongoDb await collection.InsertOneAsync(application, null, cancellationToken); } - /// - /// Removes an existing application. - /// - /// The application to delete. - /// The that can be used to abort the operation. - /// A that can be used to monitor the asynchronous operation. - public virtual async ValueTask DeleteAsync([NotNull] TApplication application, CancellationToken cancellationToken) + /// + public virtual async ValueTask DeleteAsync(TApplication application, CancellationToken cancellationToken) { if (application == null) { @@ -141,16 +114,8 @@ namespace OpenIddict.MongoDb .DeleteManyAsync(token => token.ApplicationId == application.Id, cancellationToken); } - /// - /// Retrieves an application using its client identifier. - /// - /// The client identifier associated with the application. - /// The that can be used to abort the operation. - /// - /// A that can be used to monitor the asynchronous operation, - /// whose result returns the client application corresponding to the identifier. - /// - public virtual async ValueTask FindByClientIdAsync([NotNull] string identifier, CancellationToken cancellationToken) + /// + public virtual async ValueTask FindByClientIdAsync(string identifier, CancellationToken cancellationToken) { if (string.IsNullOrEmpty(identifier)) { @@ -163,16 +128,8 @@ namespace OpenIddict.MongoDb return await collection.Find(application => application.ClientId == identifier).FirstOrDefaultAsync(cancellationToken); } - /// - /// Retrieves an application using its unique identifier. - /// - /// The unique identifier associated with the application. - /// The that can be used to abort the operation. - /// - /// A that can be used to monitor the asynchronous operation, - /// whose result returns the client application corresponding to the identifier. - /// - public virtual async ValueTask FindByIdAsync([NotNull] string identifier, CancellationToken cancellationToken) + /// + public virtual async ValueTask FindByIdAsync(string identifier, CancellationToken cancellationToken) { if (string.IsNullOrEmpty(identifier)) { @@ -186,14 +143,9 @@ namespace OpenIddict.MongoDb ObjectId.Parse(identifier)).FirstOrDefaultAsync(cancellationToken); } - /// - /// Retrieves all the applications associated with the specified post_logout_redirect_uri. - /// - /// The post_logout_redirect_uri associated with the applications. - /// The that can be used to abort the operation. - /// The client applications corresponding to the specified post_logout_redirect_uri. + /// public virtual IAsyncEnumerable FindByPostLogoutRedirectUriAsync( - [NotNull] string address, CancellationToken cancellationToken) + string address, CancellationToken cancellationToken) { if (string.IsNullOrEmpty(address)) { @@ -215,14 +167,9 @@ namespace OpenIddict.MongoDb } } - /// - /// Retrieves all the applications associated with the specified redirect_uri. - /// - /// The redirect_uri associated with the applications. - /// The that can be used to abort the operation. - /// The client applications corresponding to the specified redirect_uri. + /// public virtual IAsyncEnumerable FindByRedirectUriAsync( - [NotNull] string address, CancellationToken cancellationToken) + string address, CancellationToken cancellationToken) { if (string.IsNullOrEmpty(address)) { @@ -244,21 +191,10 @@ namespace OpenIddict.MongoDb } } - /// - /// Executes the specified query and returns the first element. - /// - /// The state type. - /// The result type. - /// The query to execute. - /// The optional state. - /// The that can be used to abort the operation. - /// - /// A that can be used to monitor the asynchronous operation, - /// whose result returns the first element returned when executing the query. - /// + /// public virtual async ValueTask GetAsync( - [NotNull] Func, TState, IQueryable> query, - [CanBeNull] TState state, CancellationToken cancellationToken) + Func, TState, IQueryable> query, + TState state, CancellationToken cancellationToken) { if (query == null) { @@ -271,113 +207,63 @@ namespace OpenIddict.MongoDb return await ((IMongoQueryable) query(collection.AsQueryable(), state)).FirstOrDefaultAsync(cancellationToken); } - /// - /// Retrieves the client identifier associated with an application. - /// - /// The application. - /// The that can be used to abort the operation. - /// - /// A that can be used to monitor the asynchronous operation, - /// whose result returns the client identifier associated with the application. - /// - public virtual ValueTask GetClientIdAsync([NotNull] TApplication application, CancellationToken cancellationToken) + /// + public virtual ValueTask GetClientIdAsync(TApplication application, CancellationToken cancellationToken) { if (application == null) { throw new ArgumentNullException(nameof(application)); } - return new ValueTask(application.ClientId); + return new ValueTask(application.ClientId); } - /// - /// Retrieves the client secret associated with an application. - /// Note: depending on the manager used to create the application, - /// the client secret may be hashed for security reasons. - /// - /// The application. - /// The that can be used to abort the operation. - /// - /// A that can be used to monitor the asynchronous operation, - /// whose result returns the client secret associated with the application. - /// - public virtual ValueTask GetClientSecretAsync([NotNull] TApplication application, CancellationToken cancellationToken) + /// + public virtual ValueTask GetClientSecretAsync(TApplication application, CancellationToken cancellationToken) { if (application == null) { throw new ArgumentNullException(nameof(application)); } - return new ValueTask(application.ClientSecret); + return new ValueTask(application.ClientSecret); } - /// - /// Retrieves the client type associated with an application. - /// - /// The application. - /// The that can be used to abort the operation. - /// - /// A that can be used to monitor the asynchronous operation, - /// whose result returns the client type of the application (by default, "public"). - /// - public virtual ValueTask GetClientTypeAsync([NotNull] TApplication application, CancellationToken cancellationToken) + /// + public virtual ValueTask GetClientTypeAsync(TApplication application, CancellationToken cancellationToken) { if (application == null) { throw new ArgumentNullException(nameof(application)); } - return new ValueTask(application.Type); + return new ValueTask(application.Type); } - /// - /// Retrieves the consent type associated with an application. - /// - /// The application. - /// The that can be used to abort the operation. - /// - /// A that can be used to monitor the asynchronous operation, - /// whose result returns the consent type of the application (by default, "explicit"). - /// - public virtual ValueTask GetConsentTypeAsync([NotNull] TApplication application, CancellationToken cancellationToken) + /// + public virtual ValueTask GetConsentTypeAsync(TApplication application, CancellationToken cancellationToken) { if (application == null) { throw new ArgumentNullException(nameof(application)); } - return new ValueTask(application.ConsentType); + return new ValueTask(application.ConsentType); } - /// - /// Retrieves the display name associated with an application. - /// - /// The application. - /// The that can be used to abort the operation. - /// - /// A that can be used to monitor the asynchronous operation, - /// whose result returns the display name associated with the application. - /// - public virtual ValueTask GetDisplayNameAsync([NotNull] TApplication application, CancellationToken cancellationToken) + /// + public virtual ValueTask GetDisplayNameAsync(TApplication application, CancellationToken cancellationToken) { if (application == null) { throw new ArgumentNullException(nameof(application)); } - return new ValueTask(application.DisplayName); + return new ValueTask(application.DisplayName); } - /// - /// Retrieves the localized display names associated with an application. - /// - /// The application. - /// The that can be used to abort the operation. - /// - /// A that can be used to monitor the asynchronous operation, - /// whose result returns all the localized display names associated with the application. - /// - public virtual ValueTask> GetDisplayNamesAsync([NotNull] TApplication application, CancellationToken cancellationToken) + /// + public virtual ValueTask> GetDisplayNamesAsync(TApplication application, CancellationToken cancellationToken) { if (application == null) { @@ -392,36 +278,20 @@ namespace OpenIddict.MongoDb return new ValueTask>(application.DisplayNames.ToImmutableDictionary()); } - /// - /// Retrieves the unique identifier associated with an application. - /// - /// The application. - /// The that can be used to abort the operation. - /// - /// A that can be used to monitor the asynchronous operation, - /// whose result returns the unique identifier associated with the application. - /// - public virtual ValueTask GetIdAsync([NotNull] TApplication application, CancellationToken cancellationToken) + /// + public virtual ValueTask GetIdAsync(TApplication application, CancellationToken cancellationToken) { if (application == null) { throw new ArgumentNullException(nameof(application)); } - return new ValueTask(application.Id.ToString()); + return new ValueTask(application.Id.ToString()); } - /// - /// Retrieves the permissions associated with an application. - /// - /// The application. - /// The that can be used to abort the operation. - /// - /// A that can be used to monitor the asynchronous operation, - /// whose result returns all the permissions associated with the application. - /// + /// public virtual ValueTask> GetPermissionsAsync( - [NotNull] TApplication application, CancellationToken cancellationToken) + TApplication application, CancellationToken cancellationToken) { if (application == null) { @@ -436,17 +306,9 @@ namespace OpenIddict.MongoDb return new ValueTask>(application.Permissions.ToImmutableArray()); } - /// - /// Retrieves the logout callback addresses associated with an application. - /// - /// The application. - /// The that can be used to abort the operation. - /// - /// A that can be used to monitor the asynchronous operation, - /// whose result returns all the post_logout_redirect_uri associated with the application. - /// + /// public virtual ValueTask> GetPostLogoutRedirectUrisAsync( - [NotNull] TApplication application, CancellationToken cancellationToken) + TApplication application, CancellationToken cancellationToken) { if (application == null) { @@ -461,16 +323,8 @@ namespace OpenIddict.MongoDb return new ValueTask>(application.PostLogoutRedirectUris.ToImmutableArray()); } - /// - /// Retrieves the additional properties associated with an application. - /// - /// The application. - /// The that can be used to abort the operation. - /// - /// A that can be used to monitor the asynchronous operation, - /// whose result returns all the additional properties associated with the application. - /// - public virtual ValueTask> GetPropertiesAsync([NotNull] TApplication application, CancellationToken cancellationToken) + /// + public virtual ValueTask> GetPropertiesAsync(TApplication application, CancellationToken cancellationToken) { if (application == null) { @@ -486,17 +340,9 @@ namespace OpenIddict.MongoDb JsonSerializer.Deserialize>(application.Properties.ToJson())); } - /// - /// Retrieves the callback addresses associated with an application. - /// - /// The application. - /// The that can be used to abort the operation. - /// - /// A that can be used to monitor the asynchronous operation, - /// whose result returns all the redirect_uri associated with the application. - /// + /// public virtual ValueTask> GetRedirectUrisAsync( - [NotNull] TApplication application, CancellationToken cancellationToken) + TApplication application, CancellationToken cancellationToken) { if (application == null) { @@ -511,16 +357,8 @@ namespace OpenIddict.MongoDb return new ValueTask>(application.RedirectUris.ToImmutableArray()); } - /// - /// Retrieves the requirements associated with an application. - /// - /// The application. - /// The that can be used to abort the operation. - /// - /// A that can be used to monitor the asynchronous operation, - /// whose result returns all the requirements associated with the application. - /// - public virtual ValueTask> GetRequirementsAsync([NotNull] TApplication application, CancellationToken cancellationToken) + /// + public virtual ValueTask> GetRequirementsAsync(TApplication application, CancellationToken cancellationToken) { if (application == null) { @@ -535,14 +373,7 @@ namespace OpenIddict.MongoDb return new ValueTask>(application.Requirements.ToImmutableArray()); } - /// - /// Instantiates a new application. - /// - /// The that can be used to abort the operation. - /// - /// A that can be used to monitor the asynchronous operation, - /// whose result returns the instantiated application, that can be persisted in the database. - /// + /// public virtual ValueTask InstantiateAsync(CancellationToken cancellationToken) { try @@ -557,15 +388,9 @@ namespace OpenIddict.MongoDb } } - /// - /// Executes the specified query and returns all the corresponding elements. - /// - /// The number of results to return. - /// The number of results to skip. - /// The that can be used to abort the operation. - /// All the elements returned when executing the specified query. + /// public virtual async IAsyncEnumerable ListAsync( - [CanBeNull] int? count, [CanBeNull] int? offset, [EnumeratorCancellation] CancellationToken cancellationToken) + int? count, int? offset, [EnumeratorCancellation] CancellationToken cancellationToken) { var database = await Context.GetDatabaseAsync(cancellationToken); var collection = database.GetCollection(Options.CurrentValue.ApplicationsCollectionName); @@ -588,18 +413,10 @@ namespace OpenIddict.MongoDb } } - /// - /// Executes the specified query and returns all the corresponding elements. - /// - /// The state type. - /// The result type. - /// The query to execute. - /// The optional state. - /// The that can be used to abort the operation. - /// All the elements returned when executing the specified query. + /// public virtual IAsyncEnumerable ListAsync( - [NotNull] Func, TState, IQueryable> query, - [CanBeNull] TState state, CancellationToken cancellationToken) + Func, TState, IQueryable> query, + TState state, CancellationToken cancellationToken) { if (query == null) { @@ -620,15 +437,9 @@ namespace OpenIddict.MongoDb } } - /// - /// Sets the client identifier associated with an application. - /// - /// The application. - /// The client identifier associated with the application. - /// The that can be used to abort the operation. - /// A that can be used to monitor the asynchronous operation. - public virtual ValueTask SetClientIdAsync([NotNull] TApplication application, - [CanBeNull] string identifier, CancellationToken cancellationToken) + /// + public virtual ValueTask SetClientIdAsync(TApplication application, + string? identifier, CancellationToken cancellationToken) { if (application == null) { @@ -640,17 +451,9 @@ namespace OpenIddict.MongoDb return default; } - /// - /// Sets the client secret associated with an application. - /// Note: depending on the manager used to create the application, - /// the client secret may be hashed for security reasons. - /// - /// The application. - /// The client secret associated with the application. - /// The that can be used to abort the operation. - /// A that can be used to monitor the asynchronous operation. - public virtual ValueTask SetClientSecretAsync([NotNull] TApplication application, - [CanBeNull] string secret, CancellationToken cancellationToken) + /// + public virtual ValueTask SetClientSecretAsync(TApplication application, + string? secret, CancellationToken cancellationToken) { if (application == null) { @@ -662,15 +465,9 @@ namespace OpenIddict.MongoDb return default; } - /// - /// Sets the client type associated with an application. - /// - /// The application. - /// The client type associated with the application. - /// The that can be used to abort the operation. - /// A that can be used to monitor the asynchronous operation. - public virtual ValueTask SetClientTypeAsync([NotNull] TApplication application, - [CanBeNull] string type, CancellationToken cancellationToken) + /// + public virtual ValueTask SetClientTypeAsync(TApplication application, + string? type, CancellationToken cancellationToken) { if (application == null) { @@ -682,15 +479,9 @@ namespace OpenIddict.MongoDb return default; } - /// - /// Sets the consent type associated with an application. - /// - /// The application. - /// The consent type associated with the application. - /// The that can be used to abort the operation. - /// A that can be used to monitor the asynchronous operation. - public virtual ValueTask SetConsentTypeAsync([NotNull] TApplication application, - [CanBeNull] string type, CancellationToken cancellationToken) + /// + public virtual ValueTask SetConsentTypeAsync(TApplication application, + string? type, CancellationToken cancellationToken) { if (application == null) { @@ -702,15 +493,9 @@ namespace OpenIddict.MongoDb return default; } - /// - /// Sets the display name associated with an application. - /// - /// The application. - /// The display name associated with the application. - /// The that can be used to abort the operation. - /// A that can be used to monitor the asynchronous operation. - public virtual ValueTask SetDisplayNameAsync([NotNull] TApplication application, - [CanBeNull] string name, CancellationToken cancellationToken) + /// + public virtual ValueTask SetDisplayNameAsync(TApplication application, + string? name, CancellationToken cancellationToken) { if (application == null) { @@ -722,15 +507,9 @@ namespace OpenIddict.MongoDb return default; } - /// - /// Sets the localized display names associated with an application. - /// - /// The application. - /// The localized display names associated with the application. - /// The that can be used to abort the operation. - /// A that can be used to monitor the asynchronous operation. - public virtual ValueTask SetDisplayNamesAsync([NotNull] TApplication application, - [CanBeNull] ImmutableDictionary names, CancellationToken cancellationToken) + /// + public virtual ValueTask SetDisplayNamesAsync(TApplication application, + ImmutableDictionary names, CancellationToken cancellationToken) { if (application == null) { @@ -742,14 +521,8 @@ namespace OpenIddict.MongoDb return default; } - /// - /// Sets the permissions associated with an application. - /// - /// The application. - /// The permissions associated with the application - /// The that can be used to abort the operation. - /// A that can be used to monitor the asynchronous operation. - public virtual ValueTask SetPermissionsAsync([NotNull] TApplication application, ImmutableArray permissions, CancellationToken cancellationToken) + /// + public virtual ValueTask SetPermissionsAsync(TApplication application, ImmutableArray permissions, CancellationToken cancellationToken) { if (application == null) { @@ -758,7 +531,7 @@ namespace OpenIddict.MongoDb if (permissions.IsDefaultOrEmpty) { - application.Permissions = null; + application.Permissions = ImmutableArray.Create(); return default; } @@ -768,14 +541,8 @@ namespace OpenIddict.MongoDb return default; } - /// - /// Sets the logout callback addresses associated with an application. - /// - /// The application. - /// The logout callback addresses associated with the application - /// The that can be used to abort the operation. - /// A that can be used to monitor the asynchronous operation. - public virtual ValueTask SetPostLogoutRedirectUrisAsync([NotNull] TApplication application, + /// + public virtual ValueTask SetPostLogoutRedirectUrisAsync(TApplication application, ImmutableArray addresses, CancellationToken cancellationToken) { if (application == null) @@ -785,7 +552,7 @@ namespace OpenIddict.MongoDb if (addresses.IsDefaultOrEmpty) { - application.PostLogoutRedirectUris = null; + application.PostLogoutRedirectUris = ImmutableArray.Create(); return default; } @@ -795,15 +562,9 @@ namespace OpenIddict.MongoDb return default; } - /// - /// Sets the additional properties associated with an application. - /// - /// The application. - /// The additional properties associated with the application. - /// The that can be used to abort the operation. - /// A that can be used to monitor the asynchronous operation. - public virtual ValueTask SetPropertiesAsync([NotNull] TApplication application, - [CanBeNull] ImmutableDictionary properties, CancellationToken cancellationToken) + /// + public virtual ValueTask SetPropertiesAsync(TApplication application, + ImmutableDictionary properties, CancellationToken cancellationToken) { if (application == null) { @@ -826,14 +587,8 @@ namespace OpenIddict.MongoDb return default; } - /// - /// Sets the callback addresses associated with an application. - /// - /// The application. - /// The callback addresses associated with the application - /// The that can be used to abort the operation. - /// A that can be used to monitor the asynchronous operation. - public virtual ValueTask SetRedirectUrisAsync([NotNull] TApplication application, + /// + public virtual ValueTask SetRedirectUrisAsync(TApplication application, ImmutableArray addresses, CancellationToken cancellationToken) { if (application == null) @@ -843,7 +598,7 @@ namespace OpenIddict.MongoDb if (addresses.IsDefaultOrEmpty) { - application.RedirectUris = null; + application.RedirectUris = ImmutableArray.Create(); return default; } @@ -853,14 +608,8 @@ namespace OpenIddict.MongoDb return default; } - /// - /// Sets the requirements associated with an application. - /// - /// The application. - /// The requirements associated with the application - /// The that can be used to abort the operation. - /// A that can be used to monitor the asynchronous operation. - public virtual ValueTask SetRequirementsAsync([NotNull] TApplication application, + /// + public virtual ValueTask SetRequirementsAsync(TApplication application, ImmutableArray requirements, CancellationToken cancellationToken) { if (application == null) @@ -870,7 +619,7 @@ namespace OpenIddict.MongoDb if (requirements.IsDefaultOrEmpty) { - application.Requirements = null; + application.Requirements = ImmutableArray.Create(); return default; } @@ -880,13 +629,8 @@ namespace OpenIddict.MongoDb return default; } - /// - /// Updates an existing application. - /// - /// The application to update. - /// The that can be used to abort the operation. - /// A that can be used to monitor the asynchronous operation. - public virtual async ValueTask UpdateAsync([NotNull] TApplication application, CancellationToken cancellationToken) + /// + public virtual async ValueTask UpdateAsync(TApplication application, CancellationToken cancellationToken) { if (application == null) { diff --git a/src/OpenIddict.MongoDb/Stores/OpenIddictMongoDbAuthorizationStore.cs b/src/OpenIddict.MongoDb/Stores/OpenIddictMongoDbAuthorizationStore.cs index f297daa5..a5b0b8cf 100644 --- a/src/OpenIddict.MongoDb/Stores/OpenIddictMongoDbAuthorizationStore.cs +++ b/src/OpenIddict.MongoDb/Stores/OpenIddictMongoDbAuthorizationStore.cs @@ -13,7 +13,6 @@ using System.Text.Encodings.Web; using System.Text.Json; using System.Threading; using System.Threading.Tasks; -using JetBrains.Annotations; using Microsoft.Extensions.Options; using MongoDB.Bson; using MongoDB.Driver; @@ -32,8 +31,8 @@ namespace OpenIddict.MongoDb where TAuthorization : OpenIddictMongoDbAuthorization { public OpenIddictMongoDbAuthorizationStore( - [NotNull] IOpenIddictMongoDbContext context, - [NotNull] IOptionsMonitor options) + IOpenIddictMongoDbContext context, + IOptionsMonitor options) { Context = context; Options = options; @@ -49,14 +48,7 @@ namespace OpenIddict.MongoDb /// protected IOptionsMonitor Options { get; } - /// - /// Determines the number of authorizations that exist in the database. - /// - /// The that can be used to abort the operation. - /// - /// A that can be used to monitor the asynchronous operation, - /// whose result returns the number of authorizations in the database. - /// + /// public virtual async ValueTask CountAsync(CancellationToken cancellationToken) { var database = await Context.GetDatabaseAsync(cancellationToken); @@ -65,18 +57,9 @@ namespace OpenIddict.MongoDb return await collection.CountDocumentsAsync(FilterDefinition.Empty, null, cancellationToken); } - /// - /// Determines the number of authorizations that match the specified query. - /// - /// The result type. - /// The query to execute. - /// The that can be used to abort the operation. - /// - /// A that can be used to monitor the asynchronous operation, - /// whose result returns the number of authorizations that match the specified query. - /// + /// public virtual async ValueTask CountAsync( - [NotNull] Func, IQueryable> query, CancellationToken cancellationToken) + Func, IQueryable> query, CancellationToken cancellationToken) { if (query == null) { @@ -89,13 +72,8 @@ namespace OpenIddict.MongoDb return await ((IMongoQueryable) query(collection.AsQueryable())).LongCountAsync(cancellationToken); } - /// - /// Creates a new authorization. - /// - /// The authorization to create. - /// The that can be used to abort the operation. - /// A that can be used to monitor the asynchronous operation. - public virtual async ValueTask CreateAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken) + /// + public virtual async ValueTask CreateAsync(TAuthorization authorization, CancellationToken cancellationToken) { if (authorization == null) { @@ -108,13 +86,8 @@ namespace OpenIddict.MongoDb await collection.InsertOneAsync(authorization, null, cancellationToken); } - /// - /// Removes an existing authorization. - /// - /// The authorization to delete. - /// The that can be used to abort the operation. - /// A that can be used to monitor the asynchronous operation. - public virtual async ValueTask DeleteAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken) + /// + public virtual async ValueTask DeleteAsync(TAuthorization authorization, CancellationToken cancellationToken) { if (authorization == null) { @@ -136,16 +109,9 @@ namespace OpenIddict.MongoDb .DeleteManyAsync(token => token.AuthorizationId == authorization.Id, cancellationToken); } - /// - /// Retrieves the authorizations corresponding to the specified - /// subject and associated with the application identifier. - /// - /// The subject associated with the authorization. - /// The client associated with the authorization. - /// The that can be used to abort the operation. - /// The authorizations corresponding to the subject/client. + /// public virtual IAsyncEnumerable FindAsync( - [NotNull] string subject, [NotNull] string client, CancellationToken cancellationToken) + string subject, string client, CancellationToken cancellationToken) { if (string.IsNullOrEmpty(subject)) { @@ -173,17 +139,10 @@ namespace OpenIddict.MongoDb } } - /// - /// Retrieves the authorizations matching the specified parameters. - /// - /// The subject associated with the authorization. - /// The client associated with the authorization. - /// The authorization status. - /// The that can be used to abort the operation. - /// The authorizations corresponding to the criteria. + /// public virtual IAsyncEnumerable FindAsync( - [NotNull] string subject, [NotNull] string client, - [NotNull] string status, CancellationToken cancellationToken) + string subject, string client, + string status, CancellationToken cancellationToken) { if (string.IsNullOrEmpty(subject)) { @@ -217,18 +176,10 @@ namespace OpenIddict.MongoDb } } - /// - /// Retrieves the authorizations matching the specified parameters. - /// - /// The subject associated with the authorization. - /// The client associated with the authorization. - /// The authorization status. - /// The authorization type. - /// The that can be used to abort the operation. - /// The authorizations corresponding to the criteria. + /// public virtual IAsyncEnumerable FindAsync( - [NotNull] string subject, [NotNull] string client, - [NotNull] string status, [NotNull] string type, CancellationToken cancellationToken) + string subject, string client, + string status, string type, CancellationToken cancellationToken) { if (string.IsNullOrEmpty(subject)) { @@ -268,19 +219,10 @@ namespace OpenIddict.MongoDb } } - /// - /// Retrieves the authorizations matching the specified parameters. - /// - /// The subject associated with the authorization. - /// The client associated with the authorization. - /// The authorization status. - /// The authorization type. - /// The minimal scopes associated with the authorization. - /// The that can be used to abort the operation. - /// The authorizations corresponding to the criteria. + /// public virtual IAsyncEnumerable FindAsync( - [NotNull] string subject, [NotNull] string client, - [NotNull] string status, [NotNull] string type, + string subject, string client, + string status, string type, ImmutableArray scopes, CancellationToken cancellationToken) { if (string.IsNullOrEmpty(subject)) @@ -324,14 +266,9 @@ namespace OpenIddict.MongoDb } } - /// - /// Retrieves the list of authorizations corresponding to the specified application identifier. - /// - /// The application identifier associated with the authorizations. - /// The that can be used to abort the operation. - /// The authorizations corresponding to the specified application. + /// public virtual IAsyncEnumerable FindByApplicationIdAsync( - [NotNull] string identifier, CancellationToken cancellationToken) + string identifier, CancellationToken cancellationToken) { if (string.IsNullOrEmpty(identifier)) { @@ -353,16 +290,8 @@ namespace OpenIddict.MongoDb } } - /// - /// Retrieves an authorization using its unique identifier. - /// - /// The unique identifier associated with the authorization. - /// The that can be used to abort the operation. - /// - /// A that can be used to monitor the asynchronous operation, - /// whose result returns the authorization corresponding to the identifier. - /// - public virtual async ValueTask FindByIdAsync([NotNull] string identifier, CancellationToken cancellationToken) + /// + public virtual async ValueTask FindByIdAsync(string identifier, CancellationToken cancellationToken) { if (string.IsNullOrEmpty(identifier)) { @@ -376,14 +305,9 @@ namespace OpenIddict.MongoDb .FirstOrDefaultAsync(cancellationToken); } - /// - /// Retrieves all the authorizations corresponding to the specified subject. - /// - /// The subject associated with the authorization. - /// The that can be used to abort the operation. - /// The authorizations corresponding to the specified subject. + /// public virtual IAsyncEnumerable FindBySubjectAsync( - [NotNull] string subject, CancellationToken cancellationToken) + string subject, CancellationToken cancellationToken) { if (string.IsNullOrEmpty(subject)) { @@ -405,40 +329,26 @@ namespace OpenIddict.MongoDb } } - /// - /// Retrieves the optional application identifier associated with an authorization. - /// - /// The authorization. - /// The that can be used to abort the operation. - /// - /// A that can be used to monitor the asynchronous operation, - /// whose result returns the application identifier associated with the authorization. - /// - public virtual ValueTask GetApplicationIdAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken) + /// + public virtual ValueTask GetApplicationIdAsync(TAuthorization authorization, CancellationToken cancellationToken) { if (authorization == null) { throw new ArgumentNullException(nameof(authorization)); } - return new ValueTask(authorization.ApplicationId.ToString()); + if (authorization.ApplicationId == ObjectId.Empty) + { + return new ValueTask(result: null); + } + + return new ValueTask(authorization.ApplicationId.ToString()); } - /// - /// Executes the specified query and returns the first element. - /// - /// The state type. - /// The result type. - /// The query to execute. - /// The optional state. - /// The that can be used to abort the operation. - /// - /// A that can be used to monitor the asynchronous operation, - /// whose result returns the first element returned when executing the query. - /// + /// public virtual async ValueTask GetAsync( - [NotNull] Func, TState, IQueryable> query, - [CanBeNull] TState state, CancellationToken cancellationToken) + Func, TState, IQueryable> query, + TState state, CancellationToken cancellationToken) { if (query == null) { @@ -451,35 +361,19 @@ namespace OpenIddict.MongoDb return await ((IMongoQueryable) query(collection.AsQueryable(), state)).FirstOrDefaultAsync(cancellationToken); } - /// - /// Retrieves the unique identifier associated with an authorization. - /// - /// The authorization. - /// The that can be used to abort the operation. - /// - /// A that can be used to monitor the asynchronous operation, - /// whose result returns the unique identifier associated with the authorization. - /// - public virtual ValueTask GetIdAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken) + /// + public virtual ValueTask GetIdAsync(TAuthorization authorization, CancellationToken cancellationToken) { if (authorization == null) { throw new ArgumentNullException(nameof(authorization)); } - return new ValueTask(authorization.Id.ToString()); + return new ValueTask(authorization.Id.ToString()); } - /// - /// Retrieves the additional properties associated with an authorization. - /// - /// The authorization. - /// The that can be used to abort the operation. - /// - /// A that can be used to monitor the asynchronous operation, - /// whose result returns all the additional properties associated with the authorization. - /// - public virtual ValueTask> GetPropertiesAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken) + /// + public virtual ValueTask> GetPropertiesAsync(TAuthorization authorization, CancellationToken cancellationToken) { if (authorization == null) { @@ -495,17 +389,8 @@ namespace OpenIddict.MongoDb JsonSerializer.Deserialize>(authorization.Properties.ToJson())); } - /// - /// Retrieves the scopes associated with an authorization. - /// - /// The authorization. - /// The that can be used to abort the operation. - /// - /// A that can be used to monitor the asynchronous operation, - /// whose result returns the scopes associated with the specified authorization. - /// - public virtual ValueTask> GetScopesAsync( - [NotNull] TAuthorization authorization, CancellationToken cancellationToken) + /// + public virtual ValueTask> GetScopesAsync(TAuthorization authorization, CancellationToken cancellationToken) { if (authorization == null) { @@ -520,71 +405,40 @@ namespace OpenIddict.MongoDb return new ValueTask>(authorization.Scopes.ToImmutableArray()); } - /// - /// Retrieves the status associated with an authorization. - /// - /// The authorization. - /// The that can be used to abort the operation. - /// - /// A that can be used to monitor the asynchronous operation, - /// whose result returns the status associated with the specified authorization. - /// - public virtual ValueTask GetStatusAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken) + /// + public virtual ValueTask GetStatusAsync(TAuthorization authorization, CancellationToken cancellationToken) { if (authorization == null) { throw new ArgumentNullException(nameof(authorization)); } - return new ValueTask(authorization.Status); + return new ValueTask(authorization.Status); } - /// - /// Retrieves the subject associated with an authorization. - /// - /// The authorization. - /// The that can be used to abort the operation. - /// - /// A that can be used to monitor the asynchronous operation, - /// whose result returns the subject associated with the specified authorization. - /// - public virtual ValueTask GetSubjectAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken) + /// + public virtual ValueTask GetSubjectAsync(TAuthorization authorization, CancellationToken cancellationToken) { if (authorization == null) { throw new ArgumentNullException(nameof(authorization)); } - return new ValueTask(authorization.Subject); + return new ValueTask(authorization.Subject); } - /// - /// Retrieves the type associated with an authorization. - /// - /// The authorization. - /// The that can be used to abort the operation. - /// - /// A that can be used to monitor the asynchronous operation, - /// whose result returns the type associated with the specified authorization. - /// - public virtual ValueTask GetTypeAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken) + /// + public virtual ValueTask GetTypeAsync(TAuthorization authorization, CancellationToken cancellationToken) { if (authorization == null) { throw new ArgumentNullException(nameof(authorization)); } - return new ValueTask(authorization.Type); + return new ValueTask(authorization.Type); } - /// - /// Instantiates a new authorization. - /// - /// The that can be used to abort the operation. - /// - /// A that can be used to monitor the asynchronous operation, - /// whose result returns the instantiated authorization, that can be persisted in the database. - /// + /// public virtual ValueTask InstantiateAsync(CancellationToken cancellationToken) { try @@ -599,15 +453,9 @@ namespace OpenIddict.MongoDb } } - /// - /// Executes the specified query and returns all the corresponding elements. - /// - /// The number of results to return. - /// The number of results to skip. - /// The that can be used to abort the operation. - /// All the elements returned when executing the specified query. + /// public virtual async IAsyncEnumerable ListAsync( - [CanBeNull] int? count, [CanBeNull] int? offset, [EnumeratorCancellation] CancellationToken cancellationToken) + int? count, int? offset, [EnumeratorCancellation] CancellationToken cancellationToken) { var database = await Context.GetDatabaseAsync(cancellationToken); var collection = database.GetCollection(Options.CurrentValue.AuthorizationsCollectionName); @@ -630,18 +478,10 @@ namespace OpenIddict.MongoDb } } - /// - /// Executes the specified query and returns all the corresponding elements. - /// - /// The state type. - /// The result type. - /// The query to execute. - /// The optional state. - /// The that can be used to abort the operation. - /// All the elements returned when executing the specified query. + /// public virtual IAsyncEnumerable ListAsync( - [NotNull] Func, TState, IQueryable> query, - [CanBeNull] TState state, CancellationToken cancellationToken) + Func, TState, IQueryable> query, + TState state, CancellationToken cancellationToken) { if (query == null) { @@ -662,11 +502,7 @@ namespace OpenIddict.MongoDb } } - /// - /// Removes the authorizations that are marked as invalid and the ad-hoc ones that have no valid/nonexpired token attached. - /// - /// The that can be used to abort the operation. - /// A that can be used to monitor the asynchronous operation. + /// public virtual async ValueTask PruneAsync(CancellationToken cancellationToken) { var database = await Context.GetDatabaseAsync(cancellationToken); @@ -699,7 +535,7 @@ namespace OpenIddict.MongoDb static IEnumerable> Buffer(IEnumerable source, int count) { - List buffer = null; + List? buffer = null; foreach (var element in source) { @@ -725,15 +561,9 @@ namespace OpenIddict.MongoDb } } - /// - /// Sets the application identifier associated with an authorization. - /// - /// The authorization. - /// The unique identifier associated with the client application. - /// The that can be used to abort the operation. - /// A that can be used to monitor the asynchronous operation. - public virtual ValueTask SetApplicationIdAsync([NotNull] TAuthorization authorization, - [CanBeNull] string identifier, CancellationToken cancellationToken) + /// + public virtual ValueTask SetApplicationIdAsync(TAuthorization authorization, + string? identifier, CancellationToken cancellationToken) { if (authorization == null) { @@ -753,15 +583,9 @@ namespace OpenIddict.MongoDb return default; } - /// - /// Sets the additional properties associated with an authorization. - /// - /// The authorization. - /// The additional properties associated with the authorization. - /// The that can be used to abort the operation. - /// A that can be used to monitor the asynchronous operation. - public virtual ValueTask SetPropertiesAsync([NotNull] TAuthorization authorization, - [CanBeNull] ImmutableDictionary properties, CancellationToken cancellationToken) + /// + public virtual ValueTask SetPropertiesAsync(TAuthorization authorization, + ImmutableDictionary properties, CancellationToken cancellationToken) { if (authorization == null) { @@ -784,14 +608,8 @@ namespace OpenIddict.MongoDb return default; } - /// - /// Sets the scopes associated with an authorization. - /// - /// The authorization. - /// The scopes associated with the authorization. - /// The that can be used to abort the operation. - /// A that can be used to monitor the asynchronous operation. - public virtual ValueTask SetScopesAsync([NotNull] TAuthorization authorization, + /// + public virtual ValueTask SetScopesAsync(TAuthorization authorization, ImmutableArray scopes, CancellationToken cancellationToken) { if (authorization == null) @@ -801,7 +619,7 @@ namespace OpenIddict.MongoDb if (scopes.IsDefaultOrEmpty) { - authorization.Scopes = null; + authorization.Scopes = ImmutableArray.Create(); return default; } @@ -811,15 +629,8 @@ namespace OpenIddict.MongoDb return default; } - /// - /// Sets the status associated with an authorization. - /// - /// The authorization. - /// The status associated with the authorization. - /// The that can be used to abort the operation. - /// A that can be used to monitor the asynchronous operation. - public virtual ValueTask SetStatusAsync([NotNull] TAuthorization authorization, - [CanBeNull] string status, CancellationToken cancellationToken) + /// + public virtual ValueTask SetStatusAsync(TAuthorization authorization, string? status, CancellationToken cancellationToken) { if (authorization == null) { @@ -831,15 +642,8 @@ namespace OpenIddict.MongoDb return default; } - /// - /// Sets the subject associated with an authorization. - /// - /// The authorization. - /// The subject associated with the authorization. - /// The that can be used to abort the operation. - /// A that can be used to monitor the asynchronous operation. - public virtual ValueTask SetSubjectAsync([NotNull] TAuthorization authorization, - [CanBeNull] string subject, CancellationToken cancellationToken) + /// + public virtual ValueTask SetSubjectAsync(TAuthorization authorization, string? subject, CancellationToken cancellationToken) { if (authorization == null) { @@ -851,15 +655,8 @@ namespace OpenIddict.MongoDb return default; } - /// - /// Sets the type associated with an authorization. - /// - /// The authorization. - /// The type associated with the authorization. - /// The that can be used to abort the operation. - /// A that can be used to monitor the asynchronous operation. - public virtual ValueTask SetTypeAsync([NotNull] TAuthorization authorization, - [CanBeNull] string type, CancellationToken cancellationToken) + /// + public virtual ValueTask SetTypeAsync(TAuthorization authorization, string? type, CancellationToken cancellationToken) { if (authorization == null) { @@ -871,13 +668,8 @@ namespace OpenIddict.MongoDb return default; } - /// - /// Updates an existing authorization. - /// - /// The authorization to update. - /// The that can be used to abort the operation. - /// A that can be used to monitor the asynchronous operation. - public virtual async ValueTask UpdateAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken) + /// + public virtual async ValueTask UpdateAsync(TAuthorization authorization, CancellationToken cancellationToken) { if (authorization == null) { diff --git a/src/OpenIddict.MongoDb/Stores/OpenIddictMongoDbScopeStore.cs b/src/OpenIddict.MongoDb/Stores/OpenIddictMongoDbScopeStore.cs index 10436685..762a9fa0 100644 --- a/src/OpenIddict.MongoDb/Stores/OpenIddictMongoDbScopeStore.cs +++ b/src/OpenIddict.MongoDb/Stores/OpenIddictMongoDbScopeStore.cs @@ -14,7 +14,6 @@ using System.Text.Encodings.Web; using System.Text.Json; using System.Threading; using System.Threading.Tasks; -using JetBrains.Annotations; using Microsoft.Extensions.Options; using MongoDB.Bson; using MongoDB.Driver; @@ -33,8 +32,8 @@ namespace OpenIddict.MongoDb where TScope : OpenIddictMongoDbScope { public OpenIddictMongoDbScopeStore( - [NotNull] IOpenIddictMongoDbContext context, - [NotNull] IOptionsMonitor options) + IOpenIddictMongoDbContext context, + IOptionsMonitor options) { Context = context; Options = options; @@ -50,14 +49,7 @@ namespace OpenIddict.MongoDb /// protected IOptionsMonitor Options { get; } - /// - /// Determines the number of scopes that exist in the database. - /// - /// The that can be used to abort the operation. - /// - /// A that can be used to monitor the asynchronous operation, - /// whose result returns the number of scopes in the database. - /// + /// public virtual async ValueTask CountAsync(CancellationToken cancellationToken) { var database = await Context.GetDatabaseAsync(cancellationToken); @@ -66,18 +58,9 @@ namespace OpenIddict.MongoDb return await collection.CountDocumentsAsync(FilterDefinition.Empty, null, cancellationToken); } - /// - /// Determines the number of scopes that match the specified query. - /// - /// The result type. - /// The query to execute. - /// The that can be used to abort the operation. - /// - /// A that can be used to monitor the asynchronous operation, - /// whose result returns the number of scopes that match the specified query. - /// + /// public virtual async ValueTask CountAsync( - [NotNull] Func, IQueryable> query, CancellationToken cancellationToken) + Func, IQueryable> query, CancellationToken cancellationToken) { if (query == null) { @@ -90,13 +73,8 @@ namespace OpenIddict.MongoDb return await ((IMongoQueryable) query(collection.AsQueryable())).LongCountAsync(cancellationToken); } - /// - /// Creates a new scope. - /// - /// The scope to create. - /// The that can be used to abort the operation. - /// A that can be used to monitor the asynchronous operation. - public virtual async ValueTask CreateAsync([NotNull] TScope scope, CancellationToken cancellationToken) + /// + public virtual async ValueTask CreateAsync(TScope scope, CancellationToken cancellationToken) { if (scope == null) { @@ -109,13 +87,8 @@ namespace OpenIddict.MongoDb await collection.InsertOneAsync(scope, null, cancellationToken); } - /// - /// Removes an existing scope. - /// - /// The scope to delete. - /// The that can be used to abort the operation. - /// A that can be used to monitor the asynchronous operation. - public virtual async ValueTask DeleteAsync([NotNull] TScope scope, CancellationToken cancellationToken) + /// + public virtual async ValueTask DeleteAsync(TScope scope, CancellationToken cancellationToken) { if (scope == null) { @@ -133,16 +106,8 @@ namespace OpenIddict.MongoDb } } - /// - /// Retrieves a scope using its unique identifier. - /// - /// The unique identifier associated with the scope. - /// The that can be used to abort the operation. - /// - /// A that can be used to monitor the asynchronous operation, - /// whose result returns the scope corresponding to the identifier. - /// - public virtual async ValueTask FindByIdAsync([NotNull] string identifier, CancellationToken cancellationToken) + /// + public virtual async ValueTask FindByIdAsync(string identifier, CancellationToken cancellationToken) { if (string.IsNullOrEmpty(identifier)) { @@ -155,16 +120,8 @@ namespace OpenIddict.MongoDb return await collection.Find(scope => scope.Id == ObjectId.Parse(identifier)).FirstOrDefaultAsync(cancellationToken); } - /// - /// Retrieves a scope using its name. - /// - /// The name associated with the scope. - /// The that can be used to abort the operation. - /// - /// A that can be used to monitor the asynchronous operation, - /// whose result returns the scope corresponding to the specified name. - /// - public virtual async ValueTask FindByNameAsync([NotNull] string name, CancellationToken cancellationToken) + /// + public virtual async ValueTask FindByNameAsync(string name, CancellationToken cancellationToken) { if (string.IsNullOrEmpty(name)) { @@ -177,14 +134,8 @@ namespace OpenIddict.MongoDb return await collection.Find(scope => scope.Name == name).FirstOrDefaultAsync(cancellationToken); } - /// - /// Retrieves a list of scopes using their name. - /// - /// The names associated with the scopes. - /// The that can be used to abort the operation. - /// The scopes corresponding to the specified names. - public virtual IAsyncEnumerable FindByNamesAsync( - ImmutableArray names, CancellationToken cancellationToken) + /// + public virtual IAsyncEnumerable FindByNamesAsync(ImmutableArray names, CancellationToken cancellationToken) { if (names.Any(name => string.IsNullOrEmpty(name))) { @@ -207,14 +158,8 @@ namespace OpenIddict.MongoDb } } - /// - /// Retrieves all the scopes that contain the specified resource. - /// - /// The resource associated with the scopes. - /// The that can be used to abort the operation. - /// The scopes associated with the specified resource. - public virtual IAsyncEnumerable FindByResourceAsync( - [NotNull] string resource, CancellationToken cancellationToken) + /// + public virtual IAsyncEnumerable FindByResourceAsync(string resource, CancellationToken cancellationToken) { if (string.IsNullOrEmpty(resource)) { @@ -235,21 +180,10 @@ namespace OpenIddict.MongoDb } } - /// - /// Executes the specified query and returns the first element. - /// - /// The state type. - /// The result type. - /// The query to execute. - /// The optional state. - /// The that can be used to abort the operation. - /// - /// A that can be used to monitor the asynchronous operation, - /// whose result returns the first element returned when executing the query. - /// + /// public virtual async ValueTask GetAsync( - [NotNull] Func, TState, IQueryable> query, - [CanBeNull] TState state, CancellationToken cancellationToken) + Func, TState, IQueryable> query, + TState state, CancellationToken cancellationToken) { if (query == null) { @@ -262,35 +196,19 @@ namespace OpenIddict.MongoDb return await ((IMongoQueryable) query(collection.AsQueryable(), state)).FirstOrDefaultAsync(cancellationToken); } - /// - /// Retrieves the description associated with a scope. - /// - /// The scope. - /// The that can be used to abort the operation. - /// - /// A that can be used to monitor the asynchronous operation, - /// whose result returns the description associated with the specified scope. - /// - public virtual ValueTask GetDescriptionAsync([NotNull] TScope scope, CancellationToken cancellationToken) + /// + public virtual ValueTask GetDescriptionAsync(TScope scope, CancellationToken cancellationToken) { if (scope == null) { throw new ArgumentNullException(nameof(scope)); } - return new ValueTask(scope.Description); + return new ValueTask(scope.Description); } - /// - /// Retrieves the localized descriptions associated with a scope. - /// - /// The scope. - /// The that can be used to abort the operation. - /// - /// A that can be used to monitor the asynchronous operation, - /// whose result returns all the localized descriptions associated with the specified scope. - /// - public virtual ValueTask> GetDescriptionsAsync([NotNull] TScope scope, CancellationToken cancellationToken) + /// + public virtual ValueTask> GetDescriptionsAsync(TScope scope, CancellationToken cancellationToken) { if (scope == null) { @@ -305,35 +223,19 @@ namespace OpenIddict.MongoDb return new ValueTask>(scope.Descriptions.ToImmutableDictionary()); } - /// - /// Retrieves the display name associated with a scope. - /// - /// The scope. - /// The that can be used to abort the operation. - /// - /// A that can be used to monitor the asynchronous operation, - /// whose result returns the display name associated with the scope. - /// - public virtual ValueTask GetDisplayNameAsync([NotNull] TScope scope, CancellationToken cancellationToken) + /// + public virtual ValueTask GetDisplayNameAsync(TScope scope, CancellationToken cancellationToken) { if (scope == null) { throw new ArgumentNullException(nameof(scope)); } - return new ValueTask(scope.DisplayName); + return new ValueTask(scope.DisplayName); } - /// - /// Retrieves the localized display names associated with a scope. - /// - /// The scope. - /// The that can be used to abort the operation. - /// - /// A that can be used to monitor the asynchronous operation, - /// whose result returns all the localized display names associated with the scope. - /// - public virtual ValueTask> GetDisplayNamesAsync([NotNull] TScope scope, CancellationToken cancellationToken) + /// + public virtual ValueTask> GetDisplayNamesAsync(TScope scope, CancellationToken cancellationToken) { if (scope == null) { @@ -348,54 +250,30 @@ namespace OpenIddict.MongoDb return new ValueTask>(scope.DisplayNames.ToImmutableDictionary()); } - /// - /// Retrieves the unique identifier associated with a scope. - /// - /// The scope. - /// The that can be used to abort the operation. - /// - /// A that can be used to monitor the asynchronous operation, - /// whose result returns the unique identifier associated with the scope. - /// - public virtual ValueTask GetIdAsync([NotNull] TScope scope, CancellationToken cancellationToken) + /// + public virtual ValueTask GetIdAsync(TScope scope, CancellationToken cancellationToken) { if (scope == null) { throw new ArgumentNullException(nameof(scope)); } - return new ValueTask(scope.Id.ToString()); + return new ValueTask(scope.Id.ToString()); } - /// - /// Retrieves the name associated with a scope. - /// - /// The scope. - /// The that can be used to abort the operation. - /// - /// A that can be used to monitor the asynchronous operation, - /// whose result returns the name associated with the specified scope. - /// - public virtual ValueTask GetNameAsync([NotNull] TScope scope, CancellationToken cancellationToken) + /// + public virtual ValueTask GetNameAsync(TScope scope, CancellationToken cancellationToken) { if (scope == null) { throw new ArgumentNullException(nameof(scope)); } - return new ValueTask(scope.Name); + return new ValueTask(scope.Name); } - /// - /// Retrieves the additional properties associated with a scope. - /// - /// The scope. - /// The that can be used to abort the operation. - /// - /// A that can be used to monitor the asynchronous operation, - /// whose result returns all the additional properties associated with the scope. - /// - public virtual ValueTask> GetPropertiesAsync([NotNull] TScope scope, CancellationToken cancellationToken) + /// + public virtual ValueTask> GetPropertiesAsync(TScope scope, CancellationToken cancellationToken) { if (scope == null) { @@ -411,16 +289,8 @@ namespace OpenIddict.MongoDb JsonSerializer.Deserialize>(scope.Properties.ToJson())); } - /// - /// Retrieves the resources associated with a scope. - /// - /// The scope. - /// The that can be used to abort the operation. - /// - /// A that can be used to monitor the asynchronous operation, - /// whose result returns all the resources associated with the scope. - /// - public virtual ValueTask> GetResourcesAsync([NotNull] TScope scope, CancellationToken cancellationToken) + /// + public virtual ValueTask> GetResourcesAsync(TScope scope, CancellationToken cancellationToken) { if (scope == null) { @@ -435,14 +305,7 @@ namespace OpenIddict.MongoDb return new ValueTask>(scope.Resources.ToImmutableArray()); } - /// - /// Instantiates a new scope. - /// - /// The that can be used to abort the operation. - /// - /// A that can be used to monitor the asynchronous operation, - /// whose result returns the instantiated scope, that can be persisted in the database. - /// + /// public virtual ValueTask InstantiateAsync(CancellationToken cancellationToken) { try @@ -457,15 +320,9 @@ namespace OpenIddict.MongoDb } } - /// - /// Executes the specified query and returns all the corresponding elements. - /// - /// The number of results to return. - /// The number of results to skip. - /// The that can be used to abort the operation. - /// All the elements returned when executing the specified query. + /// public virtual async IAsyncEnumerable ListAsync( - [CanBeNull] int? count, [CanBeNull] int? offset, [EnumeratorCancellation] CancellationToken cancellationToken) + int? count, int? offset, [EnumeratorCancellation] CancellationToken cancellationToken) { var database = await Context.GetDatabaseAsync(cancellationToken); var collection = database.GetCollection(Options.CurrentValue.ScopesCollectionName); @@ -488,18 +345,10 @@ namespace OpenIddict.MongoDb } } - /// - /// Executes the specified query and returns all the corresponding elements. - /// - /// The state type. - /// The result type. - /// The query to execute. - /// The optional state. - /// The that can be used to abort the operation. - /// All the elements returned when executing the specified query. + /// public virtual IAsyncEnumerable ListAsync( - [NotNull] Func, TState, IQueryable> query, - [CanBeNull] TState state, CancellationToken cancellationToken) + Func, TState, IQueryable> query, + TState state, CancellationToken cancellationToken) { if (query == null) { @@ -520,14 +369,8 @@ namespace OpenIddict.MongoDb } } - /// - /// Sets the description associated with a scope. - /// - /// The scope. - /// The description associated with the authorization. - /// The that can be used to abort the operation. - /// A that can be used to monitor the asynchronous operation. - public virtual ValueTask SetDescriptionAsync([NotNull] TScope scope, [CanBeNull] string description, CancellationToken cancellationToken) + /// + public virtual ValueTask SetDescriptionAsync(TScope scope, string? description, CancellationToken cancellationToken) { if (scope == null) { @@ -539,15 +382,9 @@ namespace OpenIddict.MongoDb return default; } - /// - /// Sets the localized descriptions associated with a scope. - /// - /// The scope. - /// The localized descriptions associated with the authorization. - /// The that can be used to abort the operation. - /// A that can be used to monitor the asynchronous operation. - public virtual ValueTask SetDescriptionsAsync([NotNull] TScope scope, - [CanBeNull] ImmutableDictionary descriptions, CancellationToken cancellationToken) + /// + public virtual ValueTask SetDescriptionsAsync(TScope scope, + ImmutableDictionary descriptions, CancellationToken cancellationToken) { if (scope == null) { @@ -559,15 +396,9 @@ namespace OpenIddict.MongoDb return default; } - /// - /// Sets the localized display names associated with a scope. - /// - /// The scope. - /// The localized display names associated with the scope. - /// The that can be used to abort the operation. - /// A that can be used to monitor the asynchronous operation. - public virtual ValueTask SetDisplayNamesAsync([NotNull] TScope scope, - [CanBeNull] ImmutableDictionary names, CancellationToken cancellationToken) + /// + public virtual ValueTask SetDisplayNamesAsync(TScope scope, + ImmutableDictionary names, CancellationToken cancellationToken) { if (scope == null) { @@ -579,14 +410,8 @@ namespace OpenIddict.MongoDb return default; } - /// - /// Sets the display name associated with a scope. - /// - /// The scope. - /// The display name associated with the scope. - /// The that can be used to abort the operation. - /// A that can be used to monitor the asynchronous operation. - public virtual ValueTask SetDisplayNameAsync([NotNull] TScope scope, [CanBeNull] string name, CancellationToken cancellationToken) + /// + public virtual ValueTask SetDisplayNameAsync(TScope scope, string? name, CancellationToken cancellationToken) { if (scope == null) { @@ -598,14 +423,8 @@ namespace OpenIddict.MongoDb return default; } - /// - /// Sets the name associated with a scope. - /// - /// The scope. - /// The name associated with the authorization. - /// The that can be used to abort the operation. - /// A that can be used to monitor the asynchronous operation. - public virtual ValueTask SetNameAsync([NotNull] TScope scope, [CanBeNull] string name, CancellationToken cancellationToken) + /// + public virtual ValueTask SetNameAsync(TScope scope, string? name, CancellationToken cancellationToken) { if (scope == null) { @@ -617,15 +436,9 @@ namespace OpenIddict.MongoDb return default; } - /// - /// Sets the additional properties associated with a scope. - /// - /// The scope. - /// The additional properties associated with the scope. - /// The that can be used to abort the operation. - /// A that can be used to monitor the asynchronous operation. - public virtual ValueTask SetPropertiesAsync([NotNull] TScope scope, - [CanBeNull] ImmutableDictionary properties, CancellationToken cancellationToken) + /// + public virtual ValueTask SetPropertiesAsync(TScope scope, + ImmutableDictionary properties, CancellationToken cancellationToken) { if (scope == null) { @@ -648,14 +461,8 @@ namespace OpenIddict.MongoDb return default; } - /// - /// Sets the resources associated with a scope. - /// - /// The scope. - /// The resources associated with the scope. - /// The that can be used to abort the operation. - /// A that can be used to monitor the asynchronous operation. - public virtual ValueTask SetResourcesAsync([NotNull] TScope scope, ImmutableArray resources, CancellationToken cancellationToken) + /// + public virtual ValueTask SetResourcesAsync(TScope scope, ImmutableArray resources, CancellationToken cancellationToken) { if (scope == null) { @@ -664,7 +471,7 @@ namespace OpenIddict.MongoDb if (resources.IsDefaultOrEmpty) { - scope.Resources = null; + scope.Resources = ImmutableArray.Create(); return default; } @@ -674,13 +481,8 @@ namespace OpenIddict.MongoDb return default; } - /// - /// Updates an existing scope. - /// - /// The scope to update. - /// The that can be used to abort the operation. - /// A that can be used to monitor the asynchronous operation. - public virtual async ValueTask UpdateAsync([NotNull] TScope scope, CancellationToken cancellationToken) + /// + public virtual async ValueTask UpdateAsync(TScope scope, CancellationToken cancellationToken) { if (scope == null) { diff --git a/src/OpenIddict.MongoDb/Stores/OpenIddictMongoDbTokenStore.cs b/src/OpenIddict.MongoDb/Stores/OpenIddictMongoDbTokenStore.cs index fdfb8bbb..4bd7478e 100644 --- a/src/OpenIddict.MongoDb/Stores/OpenIddictMongoDbTokenStore.cs +++ b/src/OpenIddict.MongoDb/Stores/OpenIddictMongoDbTokenStore.cs @@ -13,7 +13,6 @@ using System.Text.Encodings.Web; using System.Text.Json; using System.Threading; using System.Threading.Tasks; -using JetBrains.Annotations; using Microsoft.Extensions.Options; using MongoDB.Bson; using MongoDB.Driver; @@ -32,8 +31,8 @@ namespace OpenIddict.MongoDb where TToken : OpenIddictMongoDbToken { public OpenIddictMongoDbTokenStore( - [NotNull] IOpenIddictMongoDbContext context, - [NotNull] IOptionsMonitor options) + IOpenIddictMongoDbContext context, + IOptionsMonitor options) { Context = context; Options = options; @@ -49,14 +48,7 @@ namespace OpenIddict.MongoDb /// protected IOptionsMonitor Options { get; } - /// - /// Determines the number of tokens that exist in the database. - /// - /// The that can be used to abort the operation. - /// - /// A that can be used to monitor the asynchronous operation, - /// whose result returns the number of applications in the database. - /// + /// public virtual async ValueTask CountAsync(CancellationToken cancellationToken) { var database = await Context.GetDatabaseAsync(cancellationToken); @@ -65,18 +57,9 @@ namespace OpenIddict.MongoDb return await collection.CountDocumentsAsync(FilterDefinition.Empty, null, cancellationToken); } - /// - /// Determines the number of tokens that match the specified query. - /// - /// The result type. - /// The query to execute. - /// The that can be used to abort the operation. - /// - /// A that can be used to monitor the asynchronous operation, - /// whose result returns the number of tokens that match the specified query. - /// + /// public virtual async ValueTask CountAsync( - [NotNull] Func, IQueryable> query, CancellationToken cancellationToken) + Func, IQueryable> query, CancellationToken cancellationToken) { if (query == null) { @@ -89,13 +72,8 @@ namespace OpenIddict.MongoDb return await ((IMongoQueryable) query(collection.AsQueryable())).LongCountAsync(cancellationToken); } - /// - /// Creates a new token. - /// - /// The token to create. - /// The that can be used to abort the operation. - /// A that can be used to monitor the asynchronous operation. - public virtual async ValueTask CreateAsync([NotNull] TToken token, CancellationToken cancellationToken) + /// + public virtual async ValueTask CreateAsync(TToken token, CancellationToken cancellationToken) { if (token == null) { @@ -108,13 +86,8 @@ namespace OpenIddict.MongoDb await collection.InsertOneAsync(token, null, cancellationToken); } - /// - /// Removes a token. - /// - /// The token to delete. - /// The that can be used to abort the operation. - /// A that can be used to monitor the asynchronous operation. - public virtual async ValueTask DeleteAsync([NotNull] TToken token, CancellationToken cancellationToken) + /// + public virtual async ValueTask DeleteAsync(TToken token, CancellationToken cancellationToken) { if (token == null) { @@ -132,16 +105,9 @@ namespace OpenIddict.MongoDb } } - /// - /// Retrieves the tokens corresponding to the specified - /// subject and associated with the application identifier. - /// - /// The subject associated with the token. - /// The client associated with the token. - /// The that can be used to abort the operation. - /// The tokens corresponding to the subject/client. - public virtual IAsyncEnumerable FindAsync([NotNull] string subject, - [NotNull] string client, CancellationToken cancellationToken) + /// + public virtual IAsyncEnumerable FindAsync(string subject, + string client, CancellationToken cancellationToken) { if (string.IsNullOrEmpty(subject)) { @@ -169,17 +135,10 @@ namespace OpenIddict.MongoDb } } - /// - /// Retrieves the tokens matching the specified parameters. - /// - /// The subject associated with the token. - /// The client associated with the token. - /// The token status. - /// The that can be used to abort the operation. - /// The tokens corresponding to the criteria. + /// public virtual IAsyncEnumerable FindAsync( - [NotNull] string subject, [NotNull] string client, - [NotNull] string status, CancellationToken cancellationToken) + string subject, string client, + string status, CancellationToken cancellationToken) { if (string.IsNullOrEmpty(subject)) { @@ -213,18 +172,10 @@ namespace OpenIddict.MongoDb } } - /// - /// Retrieves the tokens matching the specified parameters. - /// - /// The subject associated with the token. - /// The client associated with the token. - /// The token status. - /// The token type. - /// The that can be used to abort the operation. - /// The tokens corresponding to the criteria. + /// public virtual IAsyncEnumerable FindAsync( - [NotNull] string subject, [NotNull] string client, - [NotNull] string status, [NotNull] string type, CancellationToken cancellationToken) + string subject, string client, + string status, string type, CancellationToken cancellationToken) { if (string.IsNullOrEmpty(subject)) { @@ -264,14 +215,8 @@ namespace OpenIddict.MongoDb } } - /// - /// Retrieves the list of tokens corresponding to the specified application identifier. - /// - /// The application identifier associated with the tokens. - /// The that can be used to abort the operation. - /// The tokens corresponding to the specified application. - public virtual IAsyncEnumerable FindByApplicationIdAsync( - [NotNull] string identifier, CancellationToken cancellationToken) + /// + public virtual IAsyncEnumerable FindByApplicationIdAsync(string identifier, CancellationToken cancellationToken) { if (string.IsNullOrEmpty(identifier)) { @@ -293,14 +238,8 @@ namespace OpenIddict.MongoDb } } - /// - /// Retrieves the list of tokens corresponding to the specified authorization identifier. - /// - /// The authorization identifier associated with the tokens. - /// The that can be used to abort the operation. - /// The tokens corresponding to the specified authorization. - public virtual IAsyncEnumerable FindByAuthorizationIdAsync( - [NotNull] string identifier, CancellationToken cancellationToken) + /// + public virtual IAsyncEnumerable FindByAuthorizationIdAsync(string identifier, CancellationToken cancellationToken) { if (string.IsNullOrEmpty(identifier)) { @@ -322,16 +261,8 @@ namespace OpenIddict.MongoDb } } - /// - /// Retrieves a token using its unique identifier. - /// - /// The unique identifier associated with the token. - /// The that can be used to abort the operation. - /// - /// A that can be used to monitor the asynchronous operation, - /// whose result returns the token corresponding to the unique identifier. - /// - public virtual async ValueTask FindByIdAsync([NotNull] string identifier, CancellationToken cancellationToken) + /// + public virtual async ValueTask FindByIdAsync(string identifier, CancellationToken cancellationToken) { if (string.IsNullOrEmpty(identifier)) { @@ -344,17 +275,8 @@ namespace OpenIddict.MongoDb return await collection.Find(token => token.Id == ObjectId.Parse(identifier)).FirstOrDefaultAsync(cancellationToken); } - /// - /// Retrieves the list of tokens corresponding to the specified reference identifier. - /// Note: the reference identifier may be hashed or encrypted for security reasons. - /// - /// The reference identifier associated with the tokens. - /// The that can be used to abort the operation. - /// - /// A that can be used to monitor the asynchronous operation, - /// whose result returns the tokens corresponding to the specified reference identifier. - /// - public virtual async ValueTask FindByReferenceIdAsync([NotNull] string identifier, CancellationToken cancellationToken) + /// + public virtual async ValueTask FindByReferenceIdAsync(string identifier, CancellationToken cancellationToken) { if (string.IsNullOrEmpty(identifier)) { @@ -367,13 +289,8 @@ namespace OpenIddict.MongoDb return await collection.Find(token => token.ReferenceId == identifier).FirstOrDefaultAsync(cancellationToken); } - /// - /// Retrieves the list of tokens corresponding to the specified subject. - /// - /// The subject associated with the tokens. - /// The that can be used to abort the operation. - /// The tokens corresponding to the specified subject. - public virtual IAsyncEnumerable FindBySubjectAsync([NotNull] string subject, CancellationToken cancellationToken) + /// + public virtual IAsyncEnumerable FindBySubjectAsync(string subject, CancellationToken cancellationToken) { if (string.IsNullOrEmpty(subject)) { @@ -394,40 +311,26 @@ namespace OpenIddict.MongoDb } } - /// - /// Retrieves the optional application identifier associated with a token. - /// - /// The token. - /// The that can be used to abort the operation. - /// - /// A that can be used to monitor the asynchronous operation, - /// whose result returns the application identifier associated with the token. - /// - public virtual ValueTask GetApplicationIdAsync([NotNull] TToken token, CancellationToken cancellationToken) + /// + public virtual ValueTask GetApplicationIdAsync(TToken token, CancellationToken cancellationToken) { if (token == null) { throw new ArgumentNullException(nameof(token)); } - return new ValueTask(token.ApplicationId.ToString()); + if (token.ApplicationId == ObjectId.Empty) + { + return new ValueTask(result: null); + } + + return new ValueTask(token.ApplicationId.ToString()); } - /// - /// Executes the specified query and returns the first element. - /// - /// The state type. - /// The result type. - /// The query to execute. - /// The optional state. - /// The that can be used to abort the operation. - /// - /// A that can be used to monitor the asynchronous operation, - /// whose result returns the first element returned when executing the query. - /// + /// public virtual async ValueTask GetAsync( - [NotNull] Func, TState, IQueryable> query, - [CanBeNull] TState state, CancellationToken cancellationToken) + Func, TState, IQueryable> query, + TState state, CancellationToken cancellationToken) { if (query == null) { @@ -440,35 +343,24 @@ namespace OpenIddict.MongoDb return await ((IMongoQueryable) query(collection.AsQueryable(), state)).FirstOrDefaultAsync(cancellationToken); } - /// - /// Retrieves the optional authorization identifier associated with a token. - /// - /// The token. - /// The that can be used to abort the operation. - /// - /// A that can be used to monitor the asynchronous operation, - /// whose result returns the authorization identifier associated with the token. - /// - public virtual ValueTask GetAuthorizationIdAsync([NotNull] TToken token, CancellationToken cancellationToken) + /// + public virtual ValueTask GetAuthorizationIdAsync(TToken token, CancellationToken cancellationToken) { if (token == null) { throw new ArgumentNullException(nameof(token)); } - return new ValueTask(token.AuthorizationId.ToString()); + if (token.AuthorizationId == ObjectId.Empty) + { + return new ValueTask(result: null); + } + + return new ValueTask(token.AuthorizationId.ToString()); } - /// - /// Retrieves the creation date associated with a token. - /// - /// The token. - /// The that can be used to abort the operation. - /// - /// A that can be used to monitor the asynchronous operation, - /// whose result returns the creation date associated with the specified token. - /// - public virtual ValueTask GetCreationDateAsync([NotNull] TToken token, CancellationToken cancellationToken) + /// + public virtual ValueTask GetCreationDateAsync(TToken token, CancellationToken cancellationToken) { if (token == null) { @@ -478,16 +370,8 @@ namespace OpenIddict.MongoDb return new ValueTask(token.CreationDate); } - /// - /// Retrieves the expiration date associated with a token. - /// - /// The token. - /// The that can be used to abort the operation. - /// - /// A that can be used to monitor the asynchronous operation, - /// whose result returns the expiration date associated with the specified token. - /// - public virtual ValueTask GetExpirationDateAsync([NotNull] TToken token, CancellationToken cancellationToken) + /// + public virtual ValueTask GetExpirationDateAsync(TToken token, CancellationToken cancellationToken) { if (token == null) { @@ -497,54 +381,30 @@ namespace OpenIddict.MongoDb return new ValueTask(token.ExpirationDate); } - /// - /// Retrieves the unique identifier associated with a token. - /// - /// The token. - /// The that can be used to abort the operation. - /// - /// A that can be used to monitor the asynchronous operation, - /// whose result returns the unique identifier associated with the token. - /// - public virtual ValueTask GetIdAsync([NotNull] TToken token, CancellationToken cancellationToken) + /// + public virtual ValueTask GetIdAsync(TToken token, CancellationToken cancellationToken) { if (token == null) { throw new ArgumentNullException(nameof(token)); } - return new ValueTask(token.Id.ToString()); + return new ValueTask(token.Id.ToString()); } - /// - /// Retrieves the payload associated with a token. - /// - /// The token. - /// The that can be used to abort the operation. - /// - /// A that can be used to monitor the asynchronous operation, - /// whose result returns the payload associated with the specified token. - /// - public virtual ValueTask GetPayloadAsync([NotNull] TToken token, CancellationToken cancellationToken) + /// + public virtual ValueTask GetPayloadAsync(TToken token, CancellationToken cancellationToken) { if (token == null) { throw new ArgumentNullException(nameof(token)); } - return new ValueTask(token.Payload); + return new ValueTask(token.Payload); } - /// - /// Retrieves the additional properties associated with a token. - /// - /// The token. - /// The that can be used to abort the operation. - /// - /// A that can be used to monitor the asynchronous operation, - /// whose result returns all the additional properties associated with the token. - /// - public virtual ValueTask> GetPropertiesAsync([NotNull] TToken token, CancellationToken cancellationToken) + /// + public virtual ValueTask> GetPropertiesAsync(TToken token, CancellationToken cancellationToken) { if (token == null) { @@ -560,92 +420,51 @@ namespace OpenIddict.MongoDb JsonSerializer.Deserialize>(token.Properties.ToJson())); } - /// - /// Retrieves the reference identifier associated with a token. - /// Note: depending on the manager used to create the token, - /// the reference identifier may be hashed for security reasons. - /// - /// The token. - /// The that can be used to abort the operation. - /// - /// A that can be used to monitor the asynchronous operation, - /// whose result returns the reference identifier associated with the specified token. - /// - public virtual ValueTask GetReferenceIdAsync([NotNull] TToken token, CancellationToken cancellationToken) + /// + public virtual ValueTask GetReferenceIdAsync(TToken token, CancellationToken cancellationToken) { if (token == null) { throw new ArgumentNullException(nameof(token)); } - return new ValueTask(token.ReferenceId); + return new ValueTask(token.ReferenceId); } - /// - /// Retrieves the status associated with a token. - /// - /// The token. - /// The that can be used to abort the operation. - /// - /// A that can be used to monitor the asynchronous operation, - /// whose result returns the status associated with the specified token. - /// - public virtual ValueTask GetStatusAsync([NotNull] TToken token, CancellationToken cancellationToken) + /// + public virtual ValueTask GetStatusAsync(TToken token, CancellationToken cancellationToken) { if (token == null) { throw new ArgumentNullException(nameof(token)); } - return new ValueTask(token.Status); + return new ValueTask(token.Status); } - /// - /// Retrieves the subject associated with a token. - /// - /// The token. - /// The that can be used to abort the operation. - /// - /// A that can be used to monitor the asynchronous operation, - /// whose result returns the subject associated with the specified token. - /// - public virtual ValueTask GetSubjectAsync([NotNull] TToken token, CancellationToken cancellationToken) + /// + public virtual ValueTask GetSubjectAsync(TToken token, CancellationToken cancellationToken) { if (token == null) { throw new ArgumentNullException(nameof(token)); } - return new ValueTask(token.Subject); + return new ValueTask(token.Subject); } - /// - /// Retrieves the token type associated with a token. - /// - /// The token. - /// The that can be used to abort the operation. - /// - /// A that can be used to monitor the asynchronous operation, - /// whose result returns the token type associated with the specified token. - /// - public virtual ValueTask GetTypeAsync([NotNull] TToken token, CancellationToken cancellationToken) + /// + public virtual ValueTask GetTypeAsync(TToken token, CancellationToken cancellationToken) { if (token == null) { throw new ArgumentNullException(nameof(token)); } - return new ValueTask(token.Type); + return new ValueTask(token.Type); } - /// - /// Instantiates a new token. - /// - /// The that can be used to abort the operation. - /// - /// A that can be used to monitor the asynchronous operation, - /// whose result returns the instantiated token, that can be persisted in the database. - /// + /// public virtual ValueTask InstantiateAsync(CancellationToken cancellationToken) { try @@ -660,15 +479,9 @@ namespace OpenIddict.MongoDb } } - /// - /// Executes the specified query and returns all the corresponding elements. - /// - /// The number of results to return. - /// The number of results to skip. - /// The that can be used to abort the operation. - /// All the elements returned when executing the specified query. + /// public virtual async IAsyncEnumerable ListAsync( - [CanBeNull] int? count, [CanBeNull] int? offset, [EnumeratorCancellation] CancellationToken cancellationToken) + int? count, int? offset, [EnumeratorCancellation] CancellationToken cancellationToken) { var database = await Context.GetDatabaseAsync(cancellationToken); var collection = database.GetCollection(Options.CurrentValue.TokensCollectionName); @@ -691,18 +504,10 @@ namespace OpenIddict.MongoDb } } - /// - /// Executes the specified query and returns all the corresponding elements. - /// - /// The state type. - /// The result type. - /// The query to execute. - /// The optional state. - /// The that can be used to abort the operation. - /// All the elements returned when executing the specified query. + /// public virtual IAsyncEnumerable ListAsync( - [NotNull] Func, TState, IQueryable> query, - [CanBeNull] TState state, CancellationToken cancellationToken) + Func, TState, IQueryable> query, + TState state, CancellationToken cancellationToken) { if (query == null) { @@ -723,11 +528,7 @@ namespace OpenIddict.MongoDb } } - /// - /// Removes the tokens that are marked as expired or invalid. - /// - /// The that can be used to abort the operation. - /// A that can be used to monitor the asynchronous operation. + /// public virtual async ValueTask PruneAsync(CancellationToken cancellationToken) { var database = await Context.GetDatabaseAsync(cancellationToken); @@ -737,15 +538,8 @@ namespace OpenIddict.MongoDb token.ExpirationDate < DateTime.UtcNow, cancellationToken); } - /// - /// Sets the application identifier associated with a token. - /// - /// The token. - /// The unique identifier associated with the client application. - /// The that can be used to abort the operation. - /// A that can be used to monitor the asynchronous operation. - public virtual ValueTask SetApplicationIdAsync([NotNull] TToken token, - [CanBeNull] string identifier, CancellationToken cancellationToken) + /// + public virtual ValueTask SetApplicationIdAsync(TToken token, string? identifier, CancellationToken cancellationToken) { if (token == null) { @@ -765,15 +559,8 @@ namespace OpenIddict.MongoDb return default; } - /// - /// Sets the authorization identifier associated with a token. - /// - /// The token. - /// The unique identifier associated with the authorization. - /// The that can be used to abort the operation. - /// A that can be used to monitor the asynchronous operation. - public virtual ValueTask SetAuthorizationIdAsync([NotNull] TToken token, - [CanBeNull] string identifier, CancellationToken cancellationToken) + /// + public virtual ValueTask SetAuthorizationIdAsync(TToken token, string? identifier, CancellationToken cancellationToken) { if (token == null) { @@ -793,15 +580,8 @@ namespace OpenIddict.MongoDb return default; } - /// - /// Sets the creation date associated with a token. - /// - /// The token. - /// The creation date. - /// The that can be used to abort the operation. - /// A that can be used to monitor the asynchronous operation. - public virtual ValueTask SetCreationDateAsync([NotNull] TToken token, - [CanBeNull] DateTimeOffset? date, CancellationToken cancellationToken) + /// + public virtual ValueTask SetCreationDateAsync(TToken token, DateTimeOffset? date, CancellationToken cancellationToken) { if (token == null) { @@ -813,15 +593,8 @@ namespace OpenIddict.MongoDb return default; } - /// - /// Sets the expiration date associated with a token. - /// - /// The token. - /// The expiration date. - /// The that can be used to abort the operation. - /// A that can be used to monitor the asynchronous operation. - public virtual ValueTask SetExpirationDateAsync([NotNull] TToken token, - [CanBeNull] DateTimeOffset? date, CancellationToken cancellationToken) + /// + public virtual ValueTask SetExpirationDateAsync(TToken token, DateTimeOffset? date, CancellationToken cancellationToken) { if (token == null) { @@ -833,14 +606,8 @@ namespace OpenIddict.MongoDb return default; } - /// - /// Sets the payload associated with a token. - /// - /// The token. - /// The payload associated with the token. - /// The that can be used to abort the operation. - /// A that can be used to monitor the asynchronous operation. - public virtual ValueTask SetPayloadAsync([NotNull] TToken token, [CanBeNull] string payload, CancellationToken cancellationToken) + /// + public virtual ValueTask SetPayloadAsync(TToken token, string? payload, CancellationToken cancellationToken) { if (token == null) { @@ -852,15 +619,9 @@ namespace OpenIddict.MongoDb return default; } - /// - /// Sets the additional properties associated with a token. - /// - /// The token. - /// The additional properties associated with the token. - /// The that can be used to abort the operation. - /// A that can be used to monitor the asynchronous operation. - public virtual ValueTask SetPropertiesAsync([NotNull] TToken token, - [CanBeNull] ImmutableDictionary properties, CancellationToken cancellationToken) + /// + public virtual ValueTask SetPropertiesAsync(TToken token, + ImmutableDictionary properties, CancellationToken cancellationToken) { if (token == null) { @@ -883,16 +644,8 @@ namespace OpenIddict.MongoDb return default; } - /// - /// Sets the reference identifier associated with a token. - /// Note: depending on the manager used to create the token, - /// the reference identifier may be hashed for security reasons. - /// - /// The token. - /// The reference identifier associated with the token. - /// The that can be used to abort the operation. - /// A that can be used to monitor the asynchronous operation. - public virtual ValueTask SetReferenceIdAsync([NotNull] TToken token, [CanBeNull] string identifier, CancellationToken cancellationToken) + /// + public virtual ValueTask SetReferenceIdAsync(TToken token, string? identifier, CancellationToken cancellationToken) { if (token == null) { @@ -904,14 +657,8 @@ namespace OpenIddict.MongoDb return default; } - /// - /// Sets the status associated with a token. - /// - /// The token. - /// The status associated with the authorization. - /// The that can be used to abort the operation. - /// A that can be used to monitor the asynchronous operation. - public virtual ValueTask SetStatusAsync([NotNull] TToken token, [CanBeNull] string status, CancellationToken cancellationToken) + /// + public virtual ValueTask SetStatusAsync(TToken token, string? status, CancellationToken cancellationToken) { if (token == null) { @@ -923,14 +670,8 @@ namespace OpenIddict.MongoDb return default; } - /// - /// Sets the subject associated with a token. - /// - /// The token. - /// The subject associated with the token. - /// The that can be used to abort the operation. - /// A that can be used to monitor the asynchronous operation. - public virtual ValueTask SetSubjectAsync([NotNull] TToken token, [CanBeNull] string subject, CancellationToken cancellationToken) + /// + public virtual ValueTask SetSubjectAsync(TToken token, string? subject, CancellationToken cancellationToken) { if (token == null) { @@ -942,14 +683,8 @@ namespace OpenIddict.MongoDb return default; } - /// - /// Sets the token type associated with a token. - /// - /// The token. - /// The token type associated with the token. - /// The that can be used to abort the operation. - /// A that can be used to monitor the asynchronous operation. - public virtual ValueTask SetTypeAsync([NotNull] TToken token, [CanBeNull] string type, CancellationToken cancellationToken) + /// + public virtual ValueTask SetTypeAsync(TToken token, string? type, CancellationToken cancellationToken) { if (token == null) { @@ -961,13 +696,8 @@ namespace OpenIddict.MongoDb return default; } - /// - /// Updates an existing token. - /// - /// The token to update. - /// The that can be used to abort the operation. - /// A that can be used to monitor the asynchronous operation. - public virtual async ValueTask UpdateAsync([NotNull] TToken token, CancellationToken cancellationToken) + /// + public virtual async ValueTask UpdateAsync(TToken token, CancellationToken cancellationToken) { if (token == null) {