From 7b65cccb7a17f8476abd9e8dcfa62ced591d589f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Chalet?= Date: Wed, 10 Jan 2018 02:52:21 +0100 Subject: [PATCH 1/2] Introduce a new FindAsync method allowing to retrieve all the authorizations satisfying the specified client/subject/scopes requirements --- .../OpenIddictAuthorizationManager.cs | 29 +++++++++++++ .../Stores/IOpenIddictAuthorizationStore.cs | 16 ++++++++ .../Stores/OpenIddictAuthorizationStore.cs | 41 +++++++++++++++++++ 3 files changed, 86 insertions(+) diff --git a/src/OpenIddict.Core/Managers/OpenIddictAuthorizationManager.cs b/src/OpenIddict.Core/Managers/OpenIddictAuthorizationManager.cs index 60b0765d..bbd62009 100644 --- a/src/OpenIddict.Core/Managers/OpenIddictAuthorizationManager.cs +++ b/src/OpenIddict.Core/Managers/OpenIddictAuthorizationManager.cs @@ -190,6 +190,35 @@ namespace OpenIddict.Core return Store.FindAsync(subject, client, cancellationToken); } + /// + /// Retrieves the authorizations corresponding to the specified subject, associated with + /// the application identifier and for which the specified scopes have been granted. + /// + /// The subject associated with the authorization. + /// The client associated with the authorization. + /// The minimal scopes 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 authorizations corresponding to the specified subject/client/scopes. + /// + public virtual Task> FindAsync( + [NotNull] string subject, [NotNull] string client, + ImmutableArray scopes, CancellationToken cancellationToken) + { + if (string.IsNullOrEmpty(subject)) + { + throw new ArgumentException("The subject cannot be null or empty.", nameof(subject)); + } + + if (string.IsNullOrEmpty(client)) + { + throw new ArgumentException("The client identifier cannot be null or empty.", nameof(client)); + } + + return Store.FindAsync(subject, client, scopes, cancellationToken); + } + /// /// Retrieves an authorization using its unique identifier. /// diff --git a/src/OpenIddict.Core/Stores/IOpenIddictAuthorizationStore.cs b/src/OpenIddict.Core/Stores/IOpenIddictAuthorizationStore.cs index 639b62c1..94e0146b 100644 --- a/src/OpenIddict.Core/Stores/IOpenIddictAuthorizationStore.cs +++ b/src/OpenIddict.Core/Stores/IOpenIddictAuthorizationStore.cs @@ -75,6 +75,22 @@ namespace OpenIddict.Core /// Task> FindAsync([NotNull] string subject, [NotNull] string client, CancellationToken cancellationToken); + /// + /// Retrieves the authorizations corresponding to the specified subject, associated with + /// the application identifier and for which the specified scopes have been granted. + /// + /// The subject associated with the authorization. + /// The client associated with the authorization. + /// The minimal scopes 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 authorizations corresponding to the specified subject/client/scopes. + /// + Task> FindAsync( + [NotNull] string subject, [NotNull] string client, + ImmutableArray scopes, CancellationToken cancellationToken); + /// /// Retrieves an authorization using its unique identifier. /// diff --git a/src/OpenIddict.Core/Stores/OpenIddictAuthorizationStore.cs b/src/OpenIddict.Core/Stores/OpenIddictAuthorizationStore.cs index 520053ba..acdd7e25 100644 --- a/src/OpenIddict.Core/Stores/OpenIddictAuthorizationStore.cs +++ b/src/OpenIddict.Core/Stores/OpenIddictAuthorizationStore.cs @@ -5,6 +5,7 @@ */ using System; +using System.Collections.Generic; using System.Collections.Immutable; using System.ComponentModel; using System.Linq; @@ -111,6 +112,46 @@ namespace OpenIddict.Core (key: ConvertIdentifierFromString(client), principal: subject), cancellationToken); } + /// + /// Retrieves the authorizations corresponding to the specified subject, associated with + /// the application identifier and for which the specified scopes have been granted. + /// + /// The subject associated with the authorization. + /// The client associated with the authorization. + /// The minimal scopes 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 authorizations corresponding to the specified subject/client/scopes. + /// + public virtual async Task> FindAsync( + [NotNull] string subject, [NotNull] string client, + ImmutableArray scopes, CancellationToken cancellationToken) + { + if (string.IsNullOrEmpty(subject)) + { + throw new ArgumentException("The subject cannot be null or empty.", nameof(subject)); + } + + if (string.IsNullOrEmpty(client)) + { + throw new ArgumentException("The client cannot be null or empty.", nameof(client)); + } + + var builder = ImmutableArray.CreateBuilder(); + + foreach (var authorization in await FindAsync(subject, client, cancellationToken)) + { + var set = new HashSet(await GetScopesAsync(authorization, cancellationToken), StringComparer.Ordinal); + if (set.IsSupersetOf(scopes)) + { + builder.Add(authorization); + } + } + + return builder.ToImmutable(); + } + /// /// Retrieves an authorization using its unique identifier. /// From 173c89231fdc7abed835b9ff45e715cfc924852d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Chalet?= Date: Sat, 3 Feb 2018 21:27:00 +0100 Subject: [PATCH 2/2] Make the CreateAsync() API consistent with DeleteAsync()/UpdateAsync() --- .../Managers/OpenIddictApplicationManager.cs | 24 +++++++++---------- .../OpenIddictAuthorizationManager.cs | 11 +++++---- .../Managers/OpenIddictScopeManager.cs | 10 ++++---- .../Managers/OpenIddictTokenManager.cs | 10 ++++---- .../Stores/IOpenIddictApplicationStore.cs | 4 ++-- .../Stores/IOpenIddictAuthorizationStore.cs | 4 ++-- .../Stores/IOpenIddictScopeStore.cs | 4 ++-- .../Stores/IOpenIddictTokenStore.cs | 4 ++-- .../Stores/OpenIddictApplicationStore.cs | 4 ++-- .../Stores/OpenIddictAuthorizationStore.cs | 4 ++-- .../Stores/OpenIddictScopeStore.cs | 4 ++-- .../Stores/OpenIddictTokenStore.cs | 4 ++-- .../Stores/OpenIddictApplicationStore.cs | 8 +++---- .../Stores/OpenIddictAuthorizationStore.cs | 8 +++---- .../Stores/OpenIddictScopeStore.cs | 8 +++---- .../Stores/OpenIddictTokenStore.cs | 8 +++---- .../Stores/OpenIddictApplicationStore.cs | 8 +++---- .../Stores/OpenIddictAuthorizationStore.cs | 8 +++---- .../Stores/OpenIddictScopeStore.cs | 8 +++---- .../Stores/OpenIddictTokenStore.cs | 8 +++---- 20 files changed, 70 insertions(+), 81 deletions(-) diff --git a/src/OpenIddict.Core/Managers/OpenIddictApplicationManager.cs b/src/OpenIddict.Core/Managers/OpenIddictApplicationManager.cs index 0a00902a..e1ce0030 100644 --- a/src/OpenIddict.Core/Managers/OpenIddictApplicationManager.cs +++ b/src/OpenIddict.Core/Managers/OpenIddictApplicationManager.cs @@ -79,13 +79,10 @@ namespace OpenIddict.Core /// The application to create. /// 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. + /// A that can be used to monitor the asynchronous operation. /// - public virtual Task CreateAsync([NotNull] TApplication application, CancellationToken cancellationToken = default) - { - return CreateAsync(application, /* secret: */ null, cancellationToken); - } + public virtual Task CreateAsync([NotNull] TApplication application, CancellationToken cancellationToken = default) + => CreateAsync(application, /* secret: */ null, cancellationToken); /// /// Creates a new application. @@ -96,10 +93,9 @@ namespace OpenIddict.Core /// The client secret associated with the application, if applicable. /// 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. + /// A that can be used to monitor the asynchronous operation. /// - public virtual async Task CreateAsync( + public virtual async Task CreateAsync( [NotNull] TApplication application, [CanBeNull] string secret, CancellationToken cancellationToken = default) { @@ -141,7 +137,7 @@ namespace OpenIddict.Core try { - return await Store.CreateAsync(application, cancellationToken); + await Store.CreateAsync(application, cancellationToken); } catch (Exception exception) @@ -183,10 +179,14 @@ namespace OpenIddict.Core if (!string.IsNullOrEmpty(secret)) { await Store.SetClientSecretAsync(application, /* secret: */ null, cancellationToken); - return await CreateAsync(application, secret, cancellationToken); + await CreateAsync(application, secret, cancellationToken); + } + else + { + await CreateAsync(application, cancellationToken); } - return await CreateAsync(application, cancellationToken); + return application; } /// diff --git a/src/OpenIddict.Core/Managers/OpenIddictAuthorizationManager.cs b/src/OpenIddict.Core/Managers/OpenIddictAuthorizationManager.cs index bbd62009..8e1bc2cb 100644 --- a/src/OpenIddict.Core/Managers/OpenIddictAuthorizationManager.cs +++ b/src/OpenIddict.Core/Managers/OpenIddictAuthorizationManager.cs @@ -78,10 +78,9 @@ namespace OpenIddict.Core /// The application to create. /// The that can be used to abort the operation. /// - /// A that can be used to monitor the asynchronous operation, whose result returns the authorization. + /// A that can be used to monitor the asynchronous operation. /// - public virtual async Task CreateAsync( - [NotNull] TAuthorization authorization, CancellationToken cancellationToken = default) + public virtual async Task CreateAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken = default) { if (authorization == null) { @@ -98,7 +97,7 @@ namespace OpenIddict.Core try { - return await Store.CreateAsync(authorization, cancellationToken); + await Store.CreateAsync(authorization, cancellationToken); } catch (Exception exception) @@ -132,7 +131,9 @@ namespace OpenIddict.Core } await PopulateAsync(authorization, descriptor, cancellationToken); - return await CreateAsync(authorization, cancellationToken); + await CreateAsync(authorization, cancellationToken); + + return authorization; } /// diff --git a/src/OpenIddict.Core/Managers/OpenIddictScopeManager.cs b/src/OpenIddict.Core/Managers/OpenIddictScopeManager.cs index a6c00a7d..1319f759 100644 --- a/src/OpenIddict.Core/Managers/OpenIddictScopeManager.cs +++ b/src/OpenIddict.Core/Managers/OpenIddictScopeManager.cs @@ -78,9 +78,9 @@ namespace OpenIddict.Core /// The scope to create. /// The that can be used to abort the operation. /// - /// A that can be used to monitor the asynchronous operation, whose result returns the scope. + /// A that can be used to monitor the asynchronous operation. /// - public virtual async Task CreateAsync([NotNull] TScope scope, CancellationToken cancellationToken = default) + public virtual async Task CreateAsync([NotNull] TScope scope, CancellationToken cancellationToken = default) { if (scope == null) { @@ -89,7 +89,7 @@ namespace OpenIddict.Core try { - return await Store.CreateAsync(scope, cancellationToken); + await Store.CreateAsync(scope, cancellationToken); } catch (Exception exception) @@ -123,7 +123,9 @@ namespace OpenIddict.Core } await PopulateAsync(scope, descriptor, cancellationToken); - return await CreateAsync(scope, cancellationToken); + await CreateAsync(scope, cancellationToken); + + return scope; } /// diff --git a/src/OpenIddict.Core/Managers/OpenIddictTokenManager.cs b/src/OpenIddict.Core/Managers/OpenIddictTokenManager.cs index fbea0336..9db48cbb 100644 --- a/src/OpenIddict.Core/Managers/OpenIddictTokenManager.cs +++ b/src/OpenIddict.Core/Managers/OpenIddictTokenManager.cs @@ -80,9 +80,9 @@ namespace OpenIddict.Core /// 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. + /// A that can be used to monitor the asynchronous operation. /// - public virtual async Task CreateAsync([NotNull] TToken token, CancellationToken cancellationToken = default) + public virtual async Task CreateAsync([NotNull] TToken token, CancellationToken cancellationToken = default) { if (token == null) { @@ -93,7 +93,7 @@ namespace OpenIddict.Core try { - return await Store.CreateAsync(token, cancellationToken); + await Store.CreateAsync(token, cancellationToken); } catch (Exception exception) @@ -127,7 +127,9 @@ namespace OpenIddict.Core } await PopulateAsync(token, descriptor, cancellationToken); - return await CreateAsync(token, cancellationToken); + await CreateAsync(token, cancellationToken); + + return token; } /// diff --git a/src/OpenIddict.Core/Stores/IOpenIddictApplicationStore.cs b/src/OpenIddict.Core/Stores/IOpenIddictApplicationStore.cs index 8c87415c..7d44a177 100644 --- a/src/OpenIddict.Core/Stores/IOpenIddictApplicationStore.cs +++ b/src/OpenIddict.Core/Stores/IOpenIddictApplicationStore.cs @@ -48,9 +48,9 @@ namespace OpenIddict.Core /// The application to create. /// The that can be used to abort the operation. /// - /// A that can be used to monitor the asynchronous operation, whose result returns the application. + /// A that can be used to monitor the asynchronous operation. /// - Task CreateAsync([NotNull] TApplication application, CancellationToken cancellationToken); + Task CreateAsync([NotNull] TApplication application, CancellationToken cancellationToken); /// /// Removes an existing application. diff --git a/src/OpenIddict.Core/Stores/IOpenIddictAuthorizationStore.cs b/src/OpenIddict.Core/Stores/IOpenIddictAuthorizationStore.cs index 94e0146b..2f792847 100644 --- a/src/OpenIddict.Core/Stores/IOpenIddictAuthorizationStore.cs +++ b/src/OpenIddict.Core/Stores/IOpenIddictAuthorizationStore.cs @@ -48,9 +48,9 @@ namespace OpenIddict.Core /// The authorization to create. /// The that can be used to abort the operation. /// - /// A that can be used to monitor the asynchronous operation, whose result returns the authorization. + /// A that can be used to monitor the asynchronous operation. /// - Task CreateAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken); + Task CreateAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken); /// /// Removes an existing authorization. diff --git a/src/OpenIddict.Core/Stores/IOpenIddictScopeStore.cs b/src/OpenIddict.Core/Stores/IOpenIddictScopeStore.cs index e061433d..8c0a48d7 100644 --- a/src/OpenIddict.Core/Stores/IOpenIddictScopeStore.cs +++ b/src/OpenIddict.Core/Stores/IOpenIddictScopeStore.cs @@ -48,9 +48,9 @@ namespace OpenIddict.Core /// The scope to create. /// The that can be used to abort the operation. /// - /// A that can be used to monitor the asynchronous operation, whose result returns the scope. + /// A that can be used to monitor the asynchronous operation. /// - Task CreateAsync([NotNull] TScope scope, CancellationToken cancellationToken); + Task CreateAsync([NotNull] TScope scope, CancellationToken cancellationToken); /// /// Removes an existing scope. diff --git a/src/OpenIddict.Core/Stores/IOpenIddictTokenStore.cs b/src/OpenIddict.Core/Stores/IOpenIddictTokenStore.cs index 4c1581bd..11ca3528 100644 --- a/src/OpenIddict.Core/Stores/IOpenIddictTokenStore.cs +++ b/src/OpenIddict.Core/Stores/IOpenIddictTokenStore.cs @@ -48,9 +48,9 @@ namespace OpenIddict.Core /// The token to create. /// The that can be used to abort the operation. /// - /// A that can be used to monitor the asynchronous operation, whose result returns the token. + /// A that can be used to monitor the asynchronous operation. /// - Task CreateAsync([NotNull] TToken token, CancellationToken cancellationToken); + Task CreateAsync([NotNull] TToken token, CancellationToken cancellationToken); /// /// Removes a token. diff --git a/src/OpenIddict.Core/Stores/OpenIddictApplicationStore.cs b/src/OpenIddict.Core/Stores/OpenIddictApplicationStore.cs index 7596af58..a42ea82d 100644 --- a/src/OpenIddict.Core/Stores/OpenIddictApplicationStore.cs +++ b/src/OpenIddict.Core/Stores/OpenIddictApplicationStore.cs @@ -62,9 +62,9 @@ namespace OpenIddict.Core /// The application to create. /// The that can be used to abort the operation. /// - /// A that can be used to monitor the asynchronous operation, whose result returns the application. + /// A that can be used to monitor the asynchronous operation. /// - public abstract Task CreateAsync([NotNull] TApplication application, CancellationToken cancellationToken); + public abstract Task CreateAsync([NotNull] TApplication application, CancellationToken cancellationToken); /// /// Removes an existing application. diff --git a/src/OpenIddict.Core/Stores/OpenIddictAuthorizationStore.cs b/src/OpenIddict.Core/Stores/OpenIddictAuthorizationStore.cs index acdd7e25..be3934c5 100644 --- a/src/OpenIddict.Core/Stores/OpenIddictAuthorizationStore.cs +++ b/src/OpenIddict.Core/Stores/OpenIddictAuthorizationStore.cs @@ -63,9 +63,9 @@ namespace OpenIddict.Core /// The authorization to create. /// The that can be used to abort the operation. /// - /// A that can be used to monitor the asynchronous operation, whose result returns the authorization. + /// A that can be used to monitor the asynchronous operation. /// - public abstract Task CreateAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken); + public abstract Task CreateAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken); /// /// Removes an existing authorization. diff --git a/src/OpenIddict.Core/Stores/OpenIddictScopeStore.cs b/src/OpenIddict.Core/Stores/OpenIddictScopeStore.cs index a9aa4652..902d707b 100644 --- a/src/OpenIddict.Core/Stores/OpenIddictScopeStore.cs +++ b/src/OpenIddict.Core/Stores/OpenIddictScopeStore.cs @@ -58,9 +58,9 @@ namespace OpenIddict.Core /// The scope to create. /// The that can be used to abort the operation. /// - /// A that can be used to monitor the asynchronous operation, whose result returns the scope. + /// A that can be used to monitor the asynchronous operation. /// - public abstract Task CreateAsync([NotNull] TScope scope, CancellationToken cancellationToken); + public abstract Task CreateAsync([NotNull] TScope scope, CancellationToken cancellationToken); /// /// Removes an existing scope. diff --git a/src/OpenIddict.Core/Stores/OpenIddictTokenStore.cs b/src/OpenIddict.Core/Stores/OpenIddictTokenStore.cs index 39419e13..aaa782df 100644 --- a/src/OpenIddict.Core/Stores/OpenIddictTokenStore.cs +++ b/src/OpenIddict.Core/Stores/OpenIddictTokenStore.cs @@ -62,9 +62,9 @@ namespace OpenIddict.Core /// The token to create. /// The that can be used to abort the operation. /// - /// A that can be used to monitor the asynchronous operation, whose result returns the token. + /// A that can be used to monitor the asynchronous operation. /// - public abstract Task CreateAsync([NotNull] TToken token, CancellationToken cancellationToken); + public abstract Task CreateAsync([NotNull] TToken token, CancellationToken cancellationToken); /// /// Removes a token. diff --git a/src/OpenIddict.EntityFramework/Stores/OpenIddictApplicationStore.cs b/src/OpenIddict.EntityFramework/Stores/OpenIddictApplicationStore.cs index adaaeb7b..057b8592 100644 --- a/src/OpenIddict.EntityFramework/Stores/OpenIddictApplicationStore.cs +++ b/src/OpenIddict.EntityFramework/Stores/OpenIddictApplicationStore.cs @@ -118,9 +118,9 @@ namespace OpenIddict.EntityFramework /// The application to create. /// The that can be used to abort the operation. /// - /// A that can be used to monitor the asynchronous operation, whose result returns the application. + /// A that can be used to monitor the asynchronous operation. /// - public override async Task CreateAsync([NotNull] TApplication application, CancellationToken cancellationToken) + public override Task CreateAsync([NotNull] TApplication application, CancellationToken cancellationToken) { if (application == null) { @@ -129,9 +129,7 @@ namespace OpenIddict.EntityFramework Applications.Add(application); - await Context.SaveChangesAsync(cancellationToken); - - return application; + return Context.SaveChangesAsync(cancellationToken); } /// diff --git a/src/OpenIddict.EntityFramework/Stores/OpenIddictAuthorizationStore.cs b/src/OpenIddict.EntityFramework/Stores/OpenIddictAuthorizationStore.cs index 00ca7ba5..bf6fe2ed 100644 --- a/src/OpenIddict.EntityFramework/Stores/OpenIddictAuthorizationStore.cs +++ b/src/OpenIddict.EntityFramework/Stores/OpenIddictAuthorizationStore.cs @@ -118,9 +118,9 @@ namespace OpenIddict.EntityFramework /// The authorization to create. /// The that can be used to abort the operation. /// - /// A that can be used to monitor the asynchronous operation, whose result returns the authorization. + /// A that can be used to monitor the asynchronous operation. /// - public override async Task CreateAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken) + public override Task CreateAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken) { if (authorization == null) { @@ -129,9 +129,7 @@ namespace OpenIddict.EntityFramework Authorizations.Add(authorization); - await Context.SaveChangesAsync(cancellationToken); - - return authorization; + return Context.SaveChangesAsync(cancellationToken); } /// diff --git a/src/OpenIddict.EntityFramework/Stores/OpenIddictScopeStore.cs b/src/OpenIddict.EntityFramework/Stores/OpenIddictScopeStore.cs index e85f866a..f1c6bb14 100644 --- a/src/OpenIddict.EntityFramework/Stores/OpenIddictScopeStore.cs +++ b/src/OpenIddict.EntityFramework/Stores/OpenIddictScopeStore.cs @@ -98,9 +98,9 @@ namespace OpenIddict.EntityFramework /// The scope to create. /// The that can be used to abort the operation. /// - /// A that can be used to monitor the asynchronous operation, whose result returns the scope. + /// A that can be used to monitor the asynchronous operation. /// - public override async Task CreateAsync([NotNull] TScope scope, CancellationToken cancellationToken) + public override Task CreateAsync([NotNull] TScope scope, CancellationToken cancellationToken) { if (scope == null) { @@ -109,9 +109,7 @@ namespace OpenIddict.EntityFramework Scopes.Add(scope); - await Context.SaveChangesAsync(cancellationToken); - - return scope; + return Context.SaveChangesAsync(cancellationToken); } /// diff --git a/src/OpenIddict.EntityFramework/Stores/OpenIddictTokenStore.cs b/src/OpenIddict.EntityFramework/Stores/OpenIddictTokenStore.cs index 93404579..e140c420 100644 --- a/src/OpenIddict.EntityFramework/Stores/OpenIddictTokenStore.cs +++ b/src/OpenIddict.EntityFramework/Stores/OpenIddictTokenStore.cs @@ -117,9 +117,9 @@ namespace OpenIddict.EntityFramework /// The token to create. /// The that can be used to abort the operation. /// - /// A that can be used to monitor the asynchronous operation, whose result returns the token. + /// A that can be used to monitor the asynchronous operation. /// - public override async Task CreateAsync([NotNull] TToken token, CancellationToken cancellationToken) + public override Task CreateAsync([NotNull] TToken token, CancellationToken cancellationToken) { if (token == null) { @@ -128,9 +128,7 @@ namespace OpenIddict.EntityFramework Tokens.Add(token); - await Context.SaveChangesAsync(cancellationToken); - - return token; + return Context.SaveChangesAsync(cancellationToken); } /// diff --git a/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictApplicationStore.cs b/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictApplicationStore.cs index 82734798..52f03a75 100644 --- a/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictApplicationStore.cs +++ b/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictApplicationStore.cs @@ -118,9 +118,9 @@ namespace OpenIddict.EntityFrameworkCore /// The application to create. /// The that can be used to abort the operation. /// - /// A that can be used to monitor the asynchronous operation, whose result returns the application. + /// A that can be used to monitor the asynchronous operation. /// - public override async Task CreateAsync([NotNull] TApplication application, CancellationToken cancellationToken) + public override Task CreateAsync([NotNull] TApplication application, CancellationToken cancellationToken) { if (application == null) { @@ -129,9 +129,7 @@ namespace OpenIddict.EntityFrameworkCore Context.Add(application); - await Context.SaveChangesAsync(cancellationToken); - - return application; + return Context.SaveChangesAsync(cancellationToken); } /// diff --git a/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictAuthorizationStore.cs b/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictAuthorizationStore.cs index d683d90c..3e9b2bed 100644 --- a/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictAuthorizationStore.cs +++ b/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictAuthorizationStore.cs @@ -118,9 +118,9 @@ namespace OpenIddict.EntityFrameworkCore /// The authorization to create. /// The that can be used to abort the operation. /// - /// A that can be used to monitor the asynchronous operation, whose result returns the authorization. + /// A that can be used to monitor the asynchronous operation. /// - public override async Task CreateAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken) + public override Task CreateAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken) { if (authorization == null) { @@ -129,9 +129,7 @@ namespace OpenIddict.EntityFrameworkCore Context.Add(authorization); - await Context.SaveChangesAsync(cancellationToken); - - return authorization; + return Context.SaveChangesAsync(cancellationToken); } /// diff --git a/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictScopeStore.cs b/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictScopeStore.cs index 24f857d6..e206da52 100644 --- a/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictScopeStore.cs +++ b/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictScopeStore.cs @@ -98,9 +98,9 @@ namespace OpenIddict.EntityFrameworkCore /// The scope to create. /// The that can be used to abort the operation. /// - /// A that can be used to monitor the asynchronous operation, whose result returns the scope. + /// A that can be used to monitor the asynchronous operation. /// - public override async Task CreateAsync([NotNull] TScope scope, CancellationToken cancellationToken) + public override Task CreateAsync([NotNull] TScope scope, CancellationToken cancellationToken) { if (scope == null) { @@ -109,9 +109,7 @@ namespace OpenIddict.EntityFrameworkCore Scopes.Add(scope); - await Context.SaveChangesAsync(cancellationToken); - - return scope; + return Context.SaveChangesAsync(cancellationToken); } /// diff --git a/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictTokenStore.cs b/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictTokenStore.cs index 3aa667ae..4fc1ed2b 100644 --- a/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictTokenStore.cs +++ b/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictTokenStore.cs @@ -117,9 +117,9 @@ namespace OpenIddict.EntityFrameworkCore /// The token to create. /// The that can be used to abort the operation. /// - /// A that can be used to monitor the asynchronous operation, whose result returns the token. + /// A that can be used to monitor the asynchronous operation. /// - public override async Task CreateAsync([NotNull] TToken token, CancellationToken cancellationToken) + public override Task CreateAsync([NotNull] TToken token, CancellationToken cancellationToken) { if (token == null) { @@ -128,9 +128,7 @@ namespace OpenIddict.EntityFrameworkCore Context.Add(token); - await Context.SaveChangesAsync(cancellationToken); - - return token; + return Context.SaveChangesAsync(cancellationToken); } ///