From 4d8914bbe63e487abe3e5b1fe049fbdd592be70b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Chalet?= Date: Fri, 16 Feb 2018 14:27:53 +0100 Subject: [PATCH] Update the OpenIddictAuthorizationManager.CreateAsync() method to require the authorization type --- .../OpenIddictAuthorizationManager.cs | 19 ++++++++----------- .../Stores/IOpenIddictAuthorizationStore.cs | 6 +++--- .../Stores/OpenIddictAuthorizationStore.cs | 6 +++--- .../Stores/OpenIddictAuthorizationStore.cs | 6 +++--- 4 files changed, 17 insertions(+), 20 deletions(-) diff --git a/src/OpenIddict.Core/Managers/OpenIddictAuthorizationManager.cs b/src/OpenIddict.Core/Managers/OpenIddictAuthorizationManager.cs index 8c17deea..bec647c6 100644 --- a/src/OpenIddict.Core/Managers/OpenIddictAuthorizationManager.cs +++ b/src/OpenIddict.Core/Managers/OpenIddictAuthorizationManager.cs @@ -96,12 +96,6 @@ namespace OpenIddict.Core await Store.SetStatusAsync(authorization, OpenIddictConstants.Statuses.Valid, cancellationToken); } - // If no type was explicitly specified, assume that the authorization is a permanent authorization. - if (string.IsNullOrEmpty(await Store.GetTypeAsync(authorization, cancellationToken))) - { - await Store.SetTypeAsync(authorization, OpenIddictConstants.AuthorizationTypes.Permanent, cancellationToken); - } - var results = await ValidateAsync(authorization, cancellationToken); if (results.Any(result => result != ValidationResult.Success)) { @@ -145,6 +139,7 @@ namespace OpenIddict.Core /// The principal associated with the authorization. /// The subject associated with the authorization. /// The client associated with the authorization. + /// The authorization type. /// The minimal scopes associated with the authorization. /// The authentication properties associated with the authorization. /// The that can be used to abort the operation. @@ -153,7 +148,7 @@ namespace OpenIddict.Core /// public virtual Task CreateAsync( [NotNull] ClaimsPrincipal principal, [NotNull] string subject, - [NotNull] string client, ImmutableArray scopes, + [NotNull] string client, [NotNull] string type, ImmutableArray scopes, [CanBeNull] ImmutableDictionary properties, CancellationToken cancellationToken = default) { if (principal == null) @@ -175,7 +170,9 @@ namespace OpenIddict.Core { ApplicationId = client, Principal = principal, - Subject = subject + Status = OpenIddictConstants.Statuses.Valid, + Subject = subject, + Type = type }; descriptor.Scopes.UnionWith(scopes); @@ -241,13 +238,13 @@ namespace OpenIddict.Core /// /// The subject associated with the authorization. /// The client associated with the authorization. - /// The status associated with the authorization. - /// The type 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. /// /// A that can be used to monitor the asynchronous operation, - /// whose result returns the authorizations corresponding to the subject/client. + /// whose result returns the authorizations corresponding to the criteria. /// public virtual async Task> FindAsync( [NotNull] string subject, [NotNull] string client, diff --git a/src/OpenIddict.Core/Stores/IOpenIddictAuthorizationStore.cs b/src/OpenIddict.Core/Stores/IOpenIddictAuthorizationStore.cs index 43f0552a..847371ea 100644 --- a/src/OpenIddict.Core/Stores/IOpenIddictAuthorizationStore.cs +++ b/src/OpenIddict.Core/Stores/IOpenIddictAuthorizationStore.cs @@ -80,12 +80,12 @@ namespace OpenIddict.Core /// /// The subject associated with the authorization. /// The client associated with the authorization. - /// The status associated with the authorization. - /// The type associated with the authorization. + /// The authorization status. + /// The authorization type. /// 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 subject/client. + /// whose result returns the authorizations corresponding to the criteria. /// Task> FindAsync( [NotNull] string subject, [NotNull] string client, diff --git a/src/OpenIddict.Core/Stores/OpenIddictAuthorizationStore.cs b/src/OpenIddict.Core/Stores/OpenIddictAuthorizationStore.cs index e33fe5e0..f7dcf14c 100644 --- a/src/OpenIddict.Core/Stores/OpenIddictAuthorizationStore.cs +++ b/src/OpenIddict.Core/Stores/OpenIddictAuthorizationStore.cs @@ -134,12 +134,12 @@ namespace OpenIddict.Core /// /// The subject associated with the authorization. /// The client associated with the authorization. - /// The status associated with the authorization. - /// The type associated with the authorization. + /// The authorization status. + /// The authorization type. /// 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 subject/client. + /// whose result returns the authorizations corresponding to the criteria. /// public virtual Task> FindAsync( [NotNull] string subject, [NotNull] string client, diff --git a/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictAuthorizationStore.cs b/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictAuthorizationStore.cs index 519314b4..20f6fa86 100644 --- a/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictAuthorizationStore.cs +++ b/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictAuthorizationStore.cs @@ -223,12 +223,12 @@ namespace OpenIddict.EntityFrameworkCore /// /// The subject associated with the authorization. /// The client associated with the authorization. - /// The status associated with the authorization. - /// The type associated with the authorization. + /// The authorization status. + /// The authorization type. /// 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 subject/client. + /// whose result returns the authorizations corresponding to the criteria. /// public override async Task> FindAsync( [NotNull] string subject, [NotNull] string client,