mirror of https://github.com/abpframework/abp.git
48 changed files with 1468 additions and 617 deletions
@ -0,0 +1,27 @@ |
|||
using Microsoft.Extensions.Logging; |
|||
using Microsoft.Extensions.Logging.Abstractions; |
|||
using Volo.Abp.Caching; |
|||
|
|||
namespace Volo.Abp.OpenIddict; |
|||
|
|||
public class AbpOpenIddictCacheBase<TEntity, TModel, TStore> |
|||
where TModel : class |
|||
where TEntity : class |
|||
{ |
|||
public ILogger<AbpOpenIddictCacheBase<TEntity, TModel, TStore>> Logger { get; set; } |
|||
|
|||
protected IDistributedCache<TModel> Cache { get; } |
|||
|
|||
protected IDistributedCache<TModel[]> ArrayCache { get; } |
|||
|
|||
protected TStore Store { get; } |
|||
|
|||
protected AbpOpenIddictCacheBase(IDistributedCache<TModel> cache, IDistributedCache<TModel[]> arrayCache, TStore store) |
|||
{ |
|||
Cache = cache; |
|||
ArrayCache = arrayCache; |
|||
Store = store; |
|||
|
|||
Logger = NullLogger<AbpOpenIddictCacheBase<TEntity, TModel, TStore>>.Instance; |
|||
} |
|||
} |
|||
@ -0,0 +1,124 @@ |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Runtime.CompilerServices; |
|||
using System.Threading; |
|||
using System.Threading.Tasks; |
|||
using OpenIddict.Abstractions; |
|||
using Volo.Abp.Caching; |
|||
using Volo.Abp.DependencyInjection; |
|||
|
|||
namespace Volo.Abp.OpenIddict.Applications; |
|||
|
|||
public class AbpOpenIddictApplicationCache : AbpOpenIddictCacheBase<OpenIddictApplication, OpenIddictApplicationModel, IOpenIddictApplicationStore<OpenIddictApplicationModel>>, |
|||
IOpenIddictApplicationCache<OpenIddictApplicationModel>, |
|||
ITransientDependency |
|||
{ |
|||
public AbpOpenIddictApplicationCache( |
|||
IDistributedCache<OpenIddictApplicationModel> cache, |
|||
IDistributedCache<OpenIddictApplicationModel[]> arrayCache, |
|||
IOpenIddictApplicationStore<OpenIddictApplicationModel> store) |
|||
: base(cache, arrayCache, store) |
|||
{ |
|||
} |
|||
|
|||
public virtual async ValueTask AddAsync(OpenIddictApplicationModel application, CancellationToken cancellationToken) |
|||
{ |
|||
Check.NotNull(application, nameof(application)); |
|||
|
|||
await RemoveAsync(application, cancellationToken); |
|||
|
|||
await Cache.SetManyAsync(new List<KeyValuePair<string, OpenIddictApplicationModel>> |
|||
{ |
|||
new KeyValuePair<string, OpenIddictApplicationModel>($"{nameof(FindByClientIdAsync)}_{await Store.GetClientIdAsync(application, cancellationToken)}", application), |
|||
new KeyValuePair<string, OpenIddictApplicationModel>($"{nameof(FindByIdAsync)}_{await Store.GetIdAsync(application, cancellationToken)}", application) |
|||
}, token: cancellationToken); |
|||
} |
|||
|
|||
public virtual async ValueTask<OpenIddictApplicationModel> FindByClientIdAsync(string identifier, CancellationToken cancellationToken) |
|||
{ |
|||
Check.NotNullOrEmpty(identifier, nameof(identifier)); |
|||
|
|||
return await Cache.GetOrAddAsync($"{nameof(FindByClientIdAsync)}_{identifier}", async () => |
|||
{ |
|||
var application = await Store.FindByClientIdAsync(identifier, cancellationToken); |
|||
if (application != null) |
|||
{ |
|||
await AddAsync(application, cancellationToken); |
|||
} |
|||
return application; |
|||
}, token: cancellationToken); |
|||
} |
|||
|
|||
public virtual async ValueTask<OpenIddictApplicationModel> FindByIdAsync(string identifier, CancellationToken cancellationToken) |
|||
{ |
|||
Check.NotNullOrEmpty(identifier, nameof(identifier)); |
|||
|
|||
return await Cache.GetOrAddAsync($"{nameof(FindByIdAsync)}_{identifier}", async () => |
|||
{ |
|||
var application = await Store.FindByIdAsync(identifier, cancellationToken); |
|||
if (application != null) |
|||
{ |
|||
await AddAsync(application, cancellationToken); |
|||
} |
|||
return application; |
|||
}, token: cancellationToken); |
|||
} |
|||
|
|||
public virtual async IAsyncEnumerable<OpenIddictApplicationModel> FindByPostLogoutRedirectUriAsync(string address, [EnumeratorCancellation] CancellationToken cancellationToken) |
|||
{ |
|||
Check.NotNullOrEmpty(address, nameof(address)); |
|||
|
|||
var applications = await ArrayCache.GetOrAddAsync($"{nameof(FindByPostLogoutRedirectUriAsync)}_{address}", async () => |
|||
{ |
|||
var applications = new List<OpenIddictApplicationModel>(); |
|||
await foreach (var application in Store.FindByPostLogoutRedirectUriAsync(address, cancellationToken)) |
|||
{ |
|||
applications.Add(application); |
|||
await AddAsync(application, cancellationToken); |
|||
} |
|||
return applications.ToArray(); |
|||
|
|||
}, token: cancellationToken); |
|||
|
|||
foreach (var application in applications) |
|||
{ |
|||
yield return application; |
|||
} |
|||
} |
|||
|
|||
public virtual async IAsyncEnumerable<OpenIddictApplicationModel> FindByRedirectUriAsync(string address, [EnumeratorCancellation] CancellationToken cancellationToken) |
|||
{ |
|||
Check.NotNullOrEmpty(address, nameof(address)); |
|||
|
|||
var applications = await ArrayCache.GetOrAddAsync($"{nameof(FindByRedirectUriAsync)}_{address}", async () => |
|||
{ |
|||
var applications = new List<OpenIddictApplicationModel>(); |
|||
await foreach (var application in Store.FindByRedirectUriAsync(address, cancellationToken)) |
|||
{ |
|||
applications.Add(application); |
|||
await AddAsync(application, cancellationToken); |
|||
} |
|||
return applications.ToArray(); |
|||
|
|||
}, token: cancellationToken); |
|||
|
|||
foreach (var application in applications) |
|||
{ |
|||
yield return application; |
|||
} |
|||
} |
|||
|
|||
public virtual async ValueTask RemoveAsync(OpenIddictApplicationModel application, CancellationToken cancellationToken) |
|||
{ |
|||
Check.NotNull(application, nameof(application)); |
|||
|
|||
await Cache.RemoveAsync($"{nameof(FindByClientIdAsync)}_{await Store.GetClientIdAsync(application, cancellationToken)}", token: cancellationToken); |
|||
await Cache.RemoveAsync($"{nameof(FindByIdAsync)}_{await Store.GetIdAsync(application, cancellationToken)}", token: cancellationToken); |
|||
|
|||
var redirectUris = await Store.GetRedirectUrisAsync(application, cancellationToken); |
|||
await ArrayCache.RemoveManyAsync(redirectUris.Select(address => $"{nameof(FindByRedirectUriAsync)}_{address}").ToArray(), token: cancellationToken); |
|||
|
|||
var postLogoutRedirectUris = await Store.GetPostLogoutRedirectUrisAsync(application, cancellationToken); |
|||
await ArrayCache.RemoveManyAsync(postLogoutRedirectUris.Select(address => $"{nameof(FindByPostLogoutRedirectUriAsync)}_{address}").ToArray(), token: cancellationToken); |
|||
} |
|||
} |
|||
@ -0,0 +1,68 @@ |
|||
namespace Volo.Abp.OpenIddict.Applications; |
|||
|
|||
public static class OpenIddictApplicationExtensions |
|||
{ |
|||
public static OpenIddictApplication ToEntity(this OpenIddictApplicationModel model) |
|||
{ |
|||
Check.NotNull(model, nameof(model)); |
|||
|
|||
return new OpenIddictApplication(model.Id) |
|||
{ |
|||
ClientId = model.ClientId, |
|||
ClientSecret = model.ClientSecret, |
|||
ConsentType = model.ConsentType, |
|||
DisplayName = model.DisplayName, |
|||
DisplayNames = model.DisplayNames, |
|||
Permissions = model.Permissions, |
|||
PostLogoutRedirectUris = model.PostLogoutRedirectUris, |
|||
Properties = model.Properties, |
|||
RedirectUris = model.RedirectUris, |
|||
Requirements = model.Requirements, |
|||
Type = model.Type |
|||
}; |
|||
} |
|||
|
|||
public static OpenIddictApplication ToEntity(this OpenIddictApplicationModel model, OpenIddictApplication entity) |
|||
{ |
|||
Check.NotNull(model, nameof(model)); |
|||
Check.NotNull(entity, nameof(entity)); |
|||
|
|||
entity.ClientId = model.ClientId; |
|||
entity.ClientSecret = model.ClientSecret; |
|||
entity.ConsentType = model.ConsentType; |
|||
entity.DisplayName = model.DisplayName; |
|||
entity.DisplayNames = model.DisplayNames; |
|||
entity.Permissions = model.Permissions; |
|||
entity.PostLogoutRedirectUris = model.PostLogoutRedirectUris; |
|||
entity.Properties = model.Properties; |
|||
entity.RedirectUris = model.RedirectUris; |
|||
entity.Requirements = model.Requirements; |
|||
entity.Type = model.Type; |
|||
|
|||
return entity; |
|||
} |
|||
|
|||
public static OpenIddictApplicationModel ToModel(this OpenIddictApplication model) |
|||
{ |
|||
if(model == null) |
|||
{ |
|||
return null; |
|||
} |
|||
|
|||
return new OpenIddictApplicationModel |
|||
{ |
|||
Id = model.Id, |
|||
ClientId = model.ClientId, |
|||
ClientSecret = model.ClientSecret, |
|||
ConsentType = model.ConsentType, |
|||
DisplayName = model.DisplayName, |
|||
DisplayNames = model.DisplayNames, |
|||
Permissions = model.Permissions, |
|||
PostLogoutRedirectUris = model.PostLogoutRedirectUris, |
|||
Properties = model.Properties, |
|||
RedirectUris = model.RedirectUris, |
|||
Requirements = model.Requirements, |
|||
Type = model.Type |
|||
}; |
|||
} |
|||
} |
|||
@ -0,0 +1,74 @@ |
|||
using System; |
|||
using Volo.Abp.MultiTenancy; |
|||
|
|||
namespace Volo.Abp.OpenIddict.Applications; |
|||
|
|||
[Serializable, IgnoreMultiTenancy] |
|||
public class OpenIddictApplicationModel |
|||
{ |
|||
public Guid Id { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Gets or sets the client identifier associated with the current application.
|
|||
/// </summary>
|
|||
public virtual string ClientId { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Gets or sets the client secret associated with the current application.
|
|||
/// Note: depending on the application manager used to create this instance,
|
|||
/// this property may be hashed or encrypted for security reasons.
|
|||
/// </summary>
|
|||
public virtual string ClientSecret { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Gets or sets the consent type associated with the current application.
|
|||
/// </summary>
|
|||
public virtual string ConsentType { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Gets or sets the display name associated with the current application.
|
|||
/// </summary>
|
|||
public virtual string DisplayName { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Gets or sets the localized display names
|
|||
/// associated with the current application,
|
|||
/// serialized as a JSON object.
|
|||
/// </summary>
|
|||
public virtual string DisplayNames { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Gets or sets the permissions associated with the
|
|||
/// current application, serialized as a JSON array.
|
|||
/// </summary>
|
|||
public virtual string Permissions { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Gets or sets the logout callback URLs associated with
|
|||
/// the current application, serialized as a JSON array.
|
|||
/// </summary>
|
|||
public virtual string PostLogoutRedirectUris { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Gets or sets the additional properties serialized as a JSON object,
|
|||
/// or <c>null</c> if no bag was associated with the current application.
|
|||
/// </summary>
|
|||
public virtual string Properties { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Gets or sets the callback URLs associated with the
|
|||
/// current application, serialized as a JSON array.
|
|||
/// </summary>
|
|||
public virtual string RedirectUris { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Gets or sets the requirements associated with the
|
|||
/// current application, serialized as a JSON array.
|
|||
/// </summary>
|
|||
public virtual string Requirements { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Gets or sets the application type associated with the current application.
|
|||
/// </summary>
|
|||
public virtual string Type { get; set; } |
|||
} |
|||
@ -0,0 +1,182 @@ |
|||
using System.Collections.Generic; |
|||
using System.Collections.Immutable; |
|||
using System.Runtime.CompilerServices; |
|||
using System.Threading; |
|||
using System.Threading.Tasks; |
|||
using OpenIddict.Abstractions; |
|||
using Volo.Abp.Caching; |
|||
using Volo.Abp.DependencyInjection; |
|||
|
|||
namespace Volo.Abp.OpenIddict.Authorizations; |
|||
|
|||
public class AbpOpenIddictAuthorizationCache : AbpOpenIddictCacheBase<OpenIddictAuthorization, OpenIddictAuthorizationModel, IOpenIddictAuthorizationStore<OpenIddictAuthorizationModel>>, |
|||
IOpenIddictAuthorizationCache<OpenIddictAuthorizationModel>, |
|||
ITransientDependency |
|||
{ |
|||
public AbpOpenIddictAuthorizationCache( |
|||
IDistributedCache<OpenIddictAuthorizationModel> cache, |
|||
IDistributedCache<OpenIddictAuthorizationModel[]> arrayCache, |
|||
IOpenIddictAuthorizationStore<OpenIddictAuthorizationModel> store) |
|||
: base(cache, arrayCache, store) |
|||
{ |
|||
} |
|||
|
|||
public async ValueTask AddAsync(OpenIddictAuthorizationModel authorization, CancellationToken cancellationToken) |
|||
{ |
|||
Check.NotNull(authorization, nameof(authorization)); |
|||
|
|||
await RemoveAsync(authorization, cancellationToken); |
|||
|
|||
await Cache.SetAsync($"{nameof(FindByIdAsync)}_{await Store.GetIdAsync(authorization, cancellationToken)}", authorization, token: cancellationToken); |
|||
} |
|||
|
|||
public async IAsyncEnumerable<OpenIddictAuthorizationModel> FindAsync(string subject, string client, [EnumeratorCancellation] CancellationToken cancellationToken) |
|||
{ |
|||
Check.NotNullOrEmpty(subject, nameof(subject)); |
|||
Check.NotNullOrEmpty(client, nameof(client)); |
|||
|
|||
var authorizations = await ArrayCache.GetOrAddAsync($"{nameof(FindAsync)}_{subject}_{client}", async () => |
|||
{ |
|||
var applications = new List<OpenIddictAuthorizationModel>(); |
|||
await foreach (var authorization in Store.FindAsync(subject, client, cancellationToken)) |
|||
{ |
|||
applications.Add(authorization); |
|||
await AddAsync(authorization, cancellationToken); |
|||
} |
|||
return applications.ToArray(); |
|||
}, token: cancellationToken); |
|||
|
|||
foreach (var authorization in authorizations) |
|||
{ |
|||
yield return authorization; |
|||
} |
|||
} |
|||
|
|||
public async IAsyncEnumerable<OpenIddictAuthorizationModel> FindAsync(string subject, string client, string status, [EnumeratorCancellation] CancellationToken cancellationToken) |
|||
{ |
|||
Check.NotNullOrEmpty(subject, nameof(subject)); |
|||
Check.NotNullOrEmpty(client, nameof(client)); |
|||
Check.NotNullOrEmpty(status, nameof(status)); |
|||
|
|||
var authorizations = await ArrayCache.GetOrAddAsync($"{nameof(FindAsync)}_{subject}_{client}_{status}", async () => |
|||
{ |
|||
var applications = new List<OpenIddictAuthorizationModel>(); |
|||
await foreach (var authorization in Store.FindAsync(subject, client, status, cancellationToken)) |
|||
{ |
|||
applications.Add(authorization); |
|||
await AddAsync(authorization, cancellationToken); |
|||
} |
|||
return applications.ToArray(); |
|||
}, token: cancellationToken); |
|||
|
|||
foreach (var authorization in authorizations) |
|||
{ |
|||
yield return authorization; |
|||
} |
|||
} |
|||
|
|||
public async IAsyncEnumerable<OpenIddictAuthorizationModel> FindAsync(string subject, string client, string status, string type, [EnumeratorCancellation] CancellationToken cancellationToken) |
|||
{ |
|||
Check.NotNullOrEmpty(subject, nameof(subject)); |
|||
Check.NotNullOrEmpty(client, nameof(client)); |
|||
Check.NotNullOrEmpty(status, nameof(status)); |
|||
Check.NotNullOrEmpty(type, nameof(type)); |
|||
|
|||
var authorizations = await ArrayCache.GetOrAddAsync($"{nameof(FindAsync)}_{subject}_{client}_{status}_{type}", async () => |
|||
{ |
|||
var applications = new List<OpenIddictAuthorizationModel>(); |
|||
await foreach (var authorization in Store.FindAsync(subject, client, status, type, cancellationToken)) |
|||
{ |
|||
applications.Add(authorization); |
|||
await AddAsync(authorization, cancellationToken); |
|||
} |
|||
return applications.ToArray(); |
|||
}, token: cancellationToken); |
|||
|
|||
foreach (var authorization in authorizations) |
|||
{ |
|||
yield return authorization; |
|||
} |
|||
} |
|||
|
|||
public async IAsyncEnumerable<OpenIddictAuthorizationModel> FindAsync(string subject, string client, string status, string type, ImmutableArray<string> scopes, [EnumeratorCancellation] CancellationToken cancellationToken) |
|||
{ |
|||
Check.NotNullOrEmpty(subject, nameof(subject)); |
|||
Check.NotNullOrEmpty(client, nameof(client)); |
|||
Check.NotNullOrEmpty(status, nameof(status)); |
|||
Check.NotNullOrEmpty(type, nameof(type)); |
|||
|
|||
// Note: this method is only partially cached.
|
|||
await foreach (var authorization in Store.FindAsync(subject, client, status, type, scopes, cancellationToken)) |
|||
{ |
|||
await AddAsync(authorization, cancellationToken); |
|||
yield return authorization; |
|||
} |
|||
} |
|||
|
|||
public async IAsyncEnumerable<OpenIddictAuthorizationModel> FindByApplicationIdAsync(string identifier, [EnumeratorCancellation] CancellationToken cancellationToken) |
|||
{ |
|||
Check.NotNullOrEmpty(identifier, nameof(identifier)); |
|||
|
|||
var authorizations = await ArrayCache.GetOrAddAsync($"{nameof(FindByApplicationIdAsync)}_{identifier}", async () => |
|||
{ |
|||
var applications = new List<OpenIddictAuthorizationModel>(); |
|||
await foreach (var authorization in Store.FindByApplicationIdAsync(identifier, cancellationToken)) |
|||
{ |
|||
applications.Add(authorization); |
|||
await AddAsync(authorization, cancellationToken); |
|||
} |
|||
return applications.ToArray(); |
|||
}, token: cancellationToken); |
|||
|
|||
foreach (var authorization in authorizations) |
|||
{ |
|||
yield return authorization; |
|||
} |
|||
} |
|||
|
|||
public async ValueTask<OpenIddictAuthorizationModel> FindByIdAsync(string identifier, CancellationToken cancellationToken) |
|||
{ |
|||
Check.NotNullOrEmpty(identifier, nameof(identifier)); |
|||
|
|||
return await Cache.GetOrAddAsync($"{nameof(FindByIdAsync)}_{identifier}", |
|||
async () => await Store.FindByIdAsync(identifier, cancellationToken), token: cancellationToken); |
|||
} |
|||
|
|||
public async IAsyncEnumerable<OpenIddictAuthorizationModel> FindBySubjectAsync(string subject, [EnumeratorCancellation] CancellationToken cancellationToken) |
|||
{ |
|||
Check.NotNullOrEmpty(subject, nameof(subject)); |
|||
|
|||
var authorizations = await ArrayCache.GetOrAddAsync($"{nameof(FindBySubjectAsync)}_{subject}", async () => |
|||
{ |
|||
var applications = new List<OpenIddictAuthorizationModel>(); |
|||
await foreach (var authorization in Store.FindBySubjectAsync(subject, cancellationToken)) |
|||
{ |
|||
applications.Add(authorization); |
|||
await AddAsync(authorization, cancellationToken); |
|||
} |
|||
return applications.ToArray(); |
|||
}, token: cancellationToken); |
|||
|
|||
foreach (var authorization in authorizations) |
|||
{ |
|||
yield return authorization; |
|||
} |
|||
} |
|||
|
|||
public virtual async ValueTask RemoveAsync(OpenIddictAuthorizationModel authorization, CancellationToken cancellationToken) |
|||
{ |
|||
Check.NotNull(authorization, nameof(authorization)); |
|||
|
|||
await ArrayCache.RemoveManyAsync(new[] |
|||
{ |
|||
$"{nameof(FindAsync)}_{await Store.GetSubjectAsync(authorization, cancellationToken)}_{await Store.GetApplicationIdAsync(authorization, cancellationToken)}", |
|||
$"{nameof(FindAsync)}_{await Store.GetSubjectAsync(authorization, cancellationToken)}_{await Store.GetApplicationIdAsync(authorization, cancellationToken)}_{await Store.GetStatusAsync(authorization, cancellationToken)}", |
|||
$"{nameof(FindAsync)}_{await Store.GetSubjectAsync(authorization, cancellationToken)}_{await Store.GetApplicationIdAsync(authorization, cancellationToken)}_{await Store.GetStatusAsync(authorization, cancellationToken)}_{await Store.GetTypeAsync(authorization, cancellationToken)}", |
|||
$"{nameof(FindByApplicationIdAsync)}_{await Store.GetApplicationIdAsync(authorization, cancellationToken)}", |
|||
$"{nameof(FindBySubjectAsync)}_{await Store.GetSubjectAsync(authorization, cancellationToken)}" |
|||
}, token: cancellationToken); |
|||
|
|||
await Cache.RemoveAsync($"{nameof(FindByIdAsync)}_{await Store.GetIdAsync(authorization, cancellationToken)}", token: cancellationToken); |
|||
} |
|||
} |
|||
@ -0,0 +1,56 @@ |
|||
namespace Volo.Abp.OpenIddict.Authorizations; |
|||
|
|||
public static class OpenIddictAuthorizationExtensions |
|||
{ |
|||
public static OpenIddictAuthorization ToEntity(this OpenIddictAuthorizationModel model) |
|||
{ |
|||
Check.NotNull(model, nameof(model)); |
|||
|
|||
return new OpenIddictAuthorization(model.Id) |
|||
{ |
|||
ApplicationId = model.ApplicationId, |
|||
CreationDate = model.CreationDate, |
|||
Properties = model.Properties, |
|||
Scopes = model.Scopes, |
|||
Status = model.Status, |
|||
Subject = model.Subject, |
|||
Type = model.Type |
|||
}; |
|||
} |
|||
|
|||
public static OpenIddictAuthorization ToEntity(this OpenIddictAuthorizationModel model, OpenIddictAuthorization entity) |
|||
{ |
|||
Check.NotNull(model, nameof(model)); |
|||
Check.NotNull(entity, nameof(entity)); |
|||
|
|||
entity.ApplicationId = model.ApplicationId; |
|||
entity.CreationDate = model.CreationDate; |
|||
entity.Properties = model.Properties; |
|||
entity.Scopes = model.Scopes; |
|||
entity.Status = model.Status; |
|||
entity.Subject = model.Subject; |
|||
entity.Type = model.Type; |
|||
|
|||
return entity; |
|||
} |
|||
|
|||
public static OpenIddictAuthorizationModel ToModel(this OpenIddictAuthorization model) |
|||
{ |
|||
if(model == null) |
|||
{ |
|||
return null; |
|||
} |
|||
|
|||
return new OpenIddictAuthorizationModel |
|||
{ |
|||
Id = model.Id, |
|||
ApplicationId = model.ApplicationId, |
|||
CreationDate = model.CreationDate, |
|||
Properties = model.Properties, |
|||
Scopes = model.Scopes, |
|||
Status = model.Status, |
|||
Subject = model.Subject, |
|||
Type = model.Type |
|||
}; |
|||
} |
|||
} |
|||
@ -0,0 +1,47 @@ |
|||
using System; |
|||
using Volo.Abp.MultiTenancy; |
|||
|
|||
namespace Volo.Abp.OpenIddict.Authorizations; |
|||
|
|||
[Serializable, IgnoreMultiTenancy] |
|||
public class OpenIddictAuthorizationModel |
|||
{ |
|||
public Guid Id { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Gets or sets the application associated with the current authorization.
|
|||
/// </summary>
|
|||
public virtual Guid? ApplicationId { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Gets or sets the UTC creation date of the current authorization.
|
|||
/// </summary>
|
|||
public virtual DateTime? CreationDate { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Gets or sets the additional properties serialized as a JSON object,
|
|||
/// or <c>null</c> if no bag was associated with the current authorization.
|
|||
/// </summary>
|
|||
public virtual string Properties { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Gets or sets the scopes associated with the current
|
|||
/// authorization, serialized as a JSON array.
|
|||
/// </summary>
|
|||
public virtual string Scopes { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Gets or sets the status of the current authorization.
|
|||
/// </summary>
|
|||
public virtual string Status { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Gets or sets the subject associated with the current authorization.
|
|||
/// </summary>
|
|||
public virtual string Subject { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Gets or sets the type of the current authorization.
|
|||
/// </summary>
|
|||
public virtual string Type { get; set; } |
|||
} |
|||
@ -0,0 +1,111 @@ |
|||
using System.Collections.Generic; |
|||
using System.Collections.Immutable; |
|||
using System.Runtime.CompilerServices; |
|||
using System.Threading; |
|||
using System.Threading.Tasks; |
|||
using OpenIddict.Abstractions; |
|||
using Volo.Abp.Caching; |
|||
using Volo.Abp.DependencyInjection; |
|||
|
|||
namespace Volo.Abp.OpenIddict.Scopes; |
|||
|
|||
public class AbpOpenIddictScopeCacheAbpOpenIddictAuthorizationCache : AbpOpenIddictCacheBase<OpenIddictScope, OpenIddictScopeModel, IOpenIddictScopeStore<OpenIddictScopeModel>>, |
|||
IOpenIddictScopeCache<OpenIddictScopeModel>, |
|||
ITransientDependency |
|||
{ |
|||
public AbpOpenIddictScopeCacheAbpOpenIddictAuthorizationCache( |
|||
IDistributedCache<OpenIddictScopeModel> cache, |
|||
IDistributedCache<OpenIddictScopeModel[]> arrayCache, |
|||
IOpenIddictScopeStore<OpenIddictScopeModel> store) |
|||
: base(cache, arrayCache, store) |
|||
{ |
|||
} |
|||
|
|||
public virtual async ValueTask AddAsync(OpenIddictScopeModel scope, CancellationToken cancellationToken) |
|||
{ |
|||
Check.NotNull(scope, nameof(scope)); |
|||
|
|||
await RemoveAsync(scope, cancellationToken); |
|||
|
|||
await Cache.SetAsync($"{nameof(FindByIdAsync)}_{await Store.GetIdAsync(scope, cancellationToken)}", scope, token: cancellationToken); |
|||
await Cache.SetAsync($"{nameof(FindByNameAsync)}_{await Store.GetNameAsync(scope, cancellationToken)}", scope, token: cancellationToken); |
|||
} |
|||
|
|||
public virtual async ValueTask<OpenIddictScopeModel> FindByIdAsync(string identifier, CancellationToken cancellationToken) |
|||
{ |
|||
Check.NotNullOrEmpty(identifier, nameof(identifier)); |
|||
|
|||
return await Cache.GetOrAddAsync($"{nameof(FindByIdAsync)}_{identifier}", async () => |
|||
{ |
|||
var scope = await Store.FindByIdAsync(identifier, cancellationToken); |
|||
if (scope != null) |
|||
{ |
|||
await AddAsync(scope, cancellationToken); |
|||
} |
|||
return scope; |
|||
}, token: cancellationToken); |
|||
} |
|||
|
|||
public virtual async ValueTask<OpenIddictScopeModel> FindByNameAsync(string name, CancellationToken cancellationToken) |
|||
{ |
|||
Check.NotNullOrEmpty(name, nameof(name)); |
|||
|
|||
return await Cache.GetOrAddAsync($"{nameof(FindByNameAsync)}_{name}", async () => |
|||
{ |
|||
var scope = await Store.FindByNameAsync(name, cancellationToken); |
|||
if (scope != null) |
|||
{ |
|||
await AddAsync(scope, cancellationToken); |
|||
} |
|||
return scope; |
|||
}, token: cancellationToken); |
|||
} |
|||
|
|||
public virtual async IAsyncEnumerable<OpenIddictScopeModel> FindByNamesAsync(ImmutableArray<string> names, [EnumeratorCancellation] CancellationToken cancellationToken) |
|||
{ |
|||
Check.NotNullOrEmpty(names, nameof(names)); |
|||
|
|||
// Note: this method is only partially cached.
|
|||
await foreach (var scope in Store.FindByNamesAsync(names, cancellationToken)) |
|||
{ |
|||
await AddAsync(scope, cancellationToken); |
|||
yield return scope; |
|||
} |
|||
} |
|||
|
|||
public virtual async IAsyncEnumerable<OpenIddictScopeModel> FindByResourceAsync(string resource, [EnumeratorCancellation] CancellationToken cancellationToken) |
|||
{ |
|||
Check.NotNullOrEmpty(resource, nameof(resource)); |
|||
|
|||
var scopes = await ArrayCache.GetOrAddAsync($"{nameof(FindByResourceAsync)}_{resource}", async () => |
|||
{ |
|||
var scopes = new List<OpenIddictScopeModel>(); |
|||
await foreach (var scope in Store.FindByResourceAsync(resource, cancellationToken)) |
|||
{ |
|||
scopes.Add(scope); |
|||
await AddAsync(scope, cancellationToken); |
|||
} |
|||
return scopes.ToArray(); |
|||
}, token: cancellationToken); |
|||
|
|||
foreach (var scope in scopes) |
|||
{ |
|||
yield return scope; |
|||
} |
|||
} |
|||
|
|||
public virtual async ValueTask RemoveAsync(OpenIddictScopeModel scope, CancellationToken cancellationToken) |
|||
{ |
|||
Check.NotNull(scope, nameof(scope)); |
|||
|
|||
var resources = new List<string>(); |
|||
foreach (var resource in await Store.GetResourcesAsync(scope, cancellationToken)) |
|||
{ |
|||
resources.Add($"{nameof(FindByResourceAsync)}_{resource}"); |
|||
} |
|||
await ArrayCache.RemoveManyAsync(resources.ToArray(), token: cancellationToken); |
|||
|
|||
await Cache.RemoveAsync($"{nameof(FindByIdAsync)}_{await Store.GetIdAsync(scope, cancellationToken)}", token: cancellationToken); |
|||
await Cache.RemoveAsync($"{nameof(FindByNameAsync)}_{await Store.GetNameAsync(scope, cancellationToken)}", token: cancellationToken); |
|||
} |
|||
} |
|||
@ -0,0 +1,56 @@ |
|||
namespace Volo.Abp.OpenIddict.Scopes; |
|||
|
|||
public static class OpenIddictScopeExtensions |
|||
{ |
|||
public static OpenIddictScope ToEntity(this OpenIddictScopeModel model) |
|||
{ |
|||
Check.NotNull(model, nameof(model)); |
|||
|
|||
return new OpenIddictScope(model.Id) |
|||
{ |
|||
Description = model.Description, |
|||
Descriptions = model.Descriptions, |
|||
DisplayName = model.DisplayName, |
|||
DisplayNames = model.DisplayNames, |
|||
Name = model.Name, |
|||
Properties = model.Properties, |
|||
Resources = model.Resources |
|||
}; |
|||
} |
|||
|
|||
public static OpenIddictScope ToEntity(this OpenIddictScopeModel model, OpenIddictScope entity) |
|||
{ |
|||
Check.NotNull(model, nameof(model)); |
|||
Check.NotNull(entity, nameof(entity)); |
|||
|
|||
entity.Description = model.Description; |
|||
entity.Descriptions = model.Descriptions; |
|||
entity.DisplayName = model.DisplayName; |
|||
entity.DisplayNames = model.DisplayNames; |
|||
entity.Name = model.Name; |
|||
entity.Properties = model.Properties; |
|||
entity.Resources = model.Resources; |
|||
|
|||
return entity; |
|||
} |
|||
|
|||
public static OpenIddictScopeModel ToModel(this OpenIddictScope model) |
|||
{ |
|||
if(model == null) |
|||
{ |
|||
return null; |
|||
} |
|||
|
|||
return new OpenIddictScopeModel |
|||
{ |
|||
Id = model.Id, |
|||
Description = model.Description, |
|||
Descriptions = model.Descriptions, |
|||
DisplayName = model.DisplayName, |
|||
DisplayNames = model.DisplayNames, |
|||
Name = model.Name, |
|||
Properties = model.Properties, |
|||
Resources = model.Resources |
|||
}; |
|||
} |
|||
} |
|||
@ -0,0 +1,50 @@ |
|||
using System; |
|||
using Volo.Abp.MultiTenancy; |
|||
|
|||
namespace Volo.Abp.OpenIddict.Scopes; |
|||
|
|||
[Serializable, IgnoreMultiTenancy] |
|||
public class OpenIddictScopeModel |
|||
{ |
|||
public Guid Id { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Gets or sets the public description associated with the current scope.
|
|||
/// </summary>
|
|||
public virtual string Description { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Gets or sets the localized public descriptions associated
|
|||
/// with the current scope, serialized as a JSON object.
|
|||
/// </summary>
|
|||
public virtual string Descriptions { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Gets or sets the display name associated with the current scope.
|
|||
/// </summary>
|
|||
public virtual string DisplayName { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Gets or sets the localized display names
|
|||
/// associated with the current application,
|
|||
/// serialized as a JSON object.
|
|||
/// </summary>
|
|||
public virtual string DisplayNames { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Gets or sets the unique name associated with the current scope.
|
|||
/// </summary>
|
|||
public virtual string Name { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Gets or sets the additional properties serialized as a JSON object,
|
|||
/// or <c>null</c> if no bag was associated with the current scope.
|
|||
/// </summary>
|
|||
public virtual string Properties { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Gets or sets the resources associated with the
|
|||
/// current scope, serialized as a JSON array.
|
|||
/// </summary>
|
|||
public virtual string Resources { get; set; } |
|||
} |
|||
@ -0,0 +1,210 @@ |
|||
using System.Collections.Generic; |
|||
using System.Runtime.CompilerServices; |
|||
using System.Threading; |
|||
using System.Threading.Tasks; |
|||
using OpenIddict.Abstractions; |
|||
using Volo.Abp.Caching; |
|||
using Volo.Abp.DependencyInjection; |
|||
|
|||
namespace Volo.Abp.OpenIddict.Tokens; |
|||
|
|||
public class AbpOpenIddictTokenCache : AbpOpenIddictCacheBase<OpenIddictToken, OpenIddictTokenModel, IOpenIddictTokenStore<OpenIddictTokenModel>>, |
|||
IOpenIddictTokenCache<OpenIddictTokenModel>, |
|||
ITransientDependency |
|||
{ |
|||
public AbpOpenIddictTokenCache( |
|||
IDistributedCache<OpenIddictTokenModel> cache, |
|||
IDistributedCache<OpenIddictTokenModel[]> arrayCache, |
|||
IOpenIddictTokenStore<OpenIddictTokenModel> store) |
|||
: base(cache, arrayCache, store) |
|||
{ |
|||
} |
|||
|
|||
public virtual async ValueTask AddAsync(OpenIddictTokenModel token, CancellationToken cancellationToken) |
|||
{ |
|||
Check.NotNull(token, nameof(token)); |
|||
|
|||
await RemoveAsync(token, cancellationToken); |
|||
|
|||
await Cache.SetAsync($"{nameof(FindByIdAsync)}_{await Store.GetIdAsync(token, cancellationToken)}", token, token: cancellationToken); |
|||
await Cache.SetAsync($"{nameof(FindByReferenceIdAsync)}_{await Store.GetReferenceIdAsync(token, cancellationToken)}", token, token: cancellationToken); |
|||
} |
|||
|
|||
public virtual async IAsyncEnumerable<OpenIddictTokenModel> FindAsync(string subject, string client, [EnumeratorCancellation] CancellationToken cancellationToken) |
|||
{ |
|||
Check.NotNullOrEmpty(subject, nameof(subject)); |
|||
Check.NotNullOrEmpty(client, nameof(client)); |
|||
|
|||
var tokens = await ArrayCache.GetOrAddAsync($"{nameof(FindAsync)}_{subject}_{client}", async () => |
|||
{ |
|||
var tokens = new List<OpenIddictTokenModel>(); |
|||
await foreach (var token in Store.FindAsync(subject, client, cancellationToken)) |
|||
{ |
|||
tokens.Add(token); |
|||
await AddAsync(token, cancellationToken); |
|||
} |
|||
return tokens.ToArray(); |
|||
}, token: cancellationToken); |
|||
|
|||
foreach (var token in tokens) |
|||
{ |
|||
yield return token; |
|||
} |
|||
} |
|||
|
|||
public virtual async IAsyncEnumerable<OpenIddictTokenModel> FindAsync(string subject, string client, string status, [EnumeratorCancellation] CancellationToken cancellationToken) |
|||
{ |
|||
Check.NotNullOrEmpty(subject, nameof(subject)); |
|||
Check.NotNullOrEmpty(client, nameof(client)); |
|||
Check.NotNullOrEmpty(status, nameof(status)); |
|||
|
|||
var tokens = await ArrayCache.GetOrAddAsync($"{nameof(FindAsync)}_{subject}_{client}_{status}", async () => |
|||
{ |
|||
var tokens = new List<OpenIddictTokenModel>(); |
|||
await foreach (var token in Store.FindAsync(subject, client, status, cancellationToken)) |
|||
{ |
|||
tokens.Add(token); |
|||
await AddAsync(token, cancellationToken); |
|||
} |
|||
return tokens.ToArray(); |
|||
}, token: cancellationToken); |
|||
|
|||
foreach (var token in tokens) |
|||
{ |
|||
yield return token; |
|||
} |
|||
} |
|||
|
|||
public virtual async IAsyncEnumerable<OpenIddictTokenModel> FindAsync(string subject, string client, string status, string type, [EnumeratorCancellation] CancellationToken cancellationToken) |
|||
{ |
|||
Check.NotNullOrEmpty(subject, nameof(subject)); |
|||
Check.NotNullOrEmpty(client, nameof(client)); |
|||
Check.NotNullOrEmpty(status, nameof(status)); |
|||
Check.NotNullOrEmpty(type, nameof(type)); |
|||
|
|||
var tokens = await ArrayCache.GetOrAddAsync($"{nameof(FindAsync)}_{subject}_{client}_{status}_{type}", async () => |
|||
{ |
|||
var tokens = new List<OpenIddictTokenModel>(); |
|||
await foreach (var token in Store.FindAsync(subject, client, status, type, cancellationToken)) |
|||
{ |
|||
tokens.Add(token); |
|||
await AddAsync(token, cancellationToken); |
|||
} |
|||
return tokens.ToArray(); |
|||
}, token: cancellationToken); |
|||
|
|||
foreach (var token in tokens) |
|||
{ |
|||
yield return token; |
|||
} |
|||
} |
|||
|
|||
public virtual async IAsyncEnumerable<OpenIddictTokenModel> FindByApplicationIdAsync(string identifier, [EnumeratorCancellation] CancellationToken cancellationToken) |
|||
{ |
|||
Check.NotNullOrEmpty(identifier, nameof(identifier)); |
|||
|
|||
var tokens = await ArrayCache.GetOrAddAsync($"{nameof(FindByApplicationIdAsync)}_{identifier}", async () => |
|||
{ |
|||
var tokens = new List<OpenIddictTokenModel>(); |
|||
await foreach (var token in Store.FindByApplicationIdAsync(identifier, cancellationToken)) |
|||
{ |
|||
tokens.Add(token); |
|||
await AddAsync(token, cancellationToken); |
|||
} |
|||
return tokens.ToArray(); |
|||
}, token: cancellationToken); |
|||
|
|||
foreach (var token in tokens) |
|||
{ |
|||
yield return token; |
|||
} |
|||
} |
|||
|
|||
public virtual async IAsyncEnumerable<OpenIddictTokenModel> FindByAuthorizationIdAsync(string identifier, [EnumeratorCancellation] CancellationToken cancellationToken) |
|||
{ |
|||
Check.NotNullOrEmpty(identifier, nameof(identifier)); |
|||
|
|||
var tokens = await ArrayCache.GetOrAddAsync($"{nameof(FindByAuthorizationIdAsync)}_{identifier}", async () => |
|||
{ |
|||
var tokens = new List<OpenIddictTokenModel>(); |
|||
await foreach (var token in Store.FindByAuthorizationIdAsync(identifier, cancellationToken)) |
|||
{ |
|||
tokens.Add(token); |
|||
await AddAsync(token, cancellationToken); |
|||
} |
|||
return tokens.ToArray(); |
|||
}, token: cancellationToken); |
|||
|
|||
foreach (var token in tokens) |
|||
{ |
|||
yield return token; |
|||
} |
|||
} |
|||
|
|||
public virtual async ValueTask<OpenIddictTokenModel> FindByIdAsync(string identifier, CancellationToken cancellationToken) |
|||
{ |
|||
Check.NotNullOrEmpty(identifier, nameof(identifier)); |
|||
|
|||
return await Cache.GetOrAddAsync($"{nameof(FindByIdAsync)}_{identifier}", async () => |
|||
{ |
|||
var token = await Store.FindByIdAsync(identifier, cancellationToken); |
|||
if (token != null) |
|||
{ |
|||
await AddAsync(token, cancellationToken); |
|||
} |
|||
return token; |
|||
}, token: cancellationToken); |
|||
} |
|||
|
|||
public virtual async ValueTask<OpenIddictTokenModel> FindByReferenceIdAsync(string identifier, CancellationToken cancellationToken) |
|||
{ |
|||
Check.NotNullOrEmpty(identifier, nameof(identifier)); |
|||
|
|||
return await Cache.GetOrAddAsync($"{nameof(FindByReferenceIdAsync)}_{identifier}", async () => |
|||
{ |
|||
var token = await Store.FindByReferenceIdAsync(identifier, cancellationToken); |
|||
if (token != null) |
|||
{ |
|||
await AddAsync(token, cancellationToken); |
|||
} |
|||
return token; |
|||
}, token: cancellationToken); |
|||
} |
|||
|
|||
public virtual async IAsyncEnumerable<OpenIddictTokenModel> FindBySubjectAsync(string subject, [EnumeratorCancellation] CancellationToken cancellationToken) |
|||
{ |
|||
Check.NotNullOrEmpty(subject, nameof(subject)); |
|||
|
|||
var tokens = await ArrayCache.GetOrAddAsync($"{nameof(FindBySubjectAsync)}_{subject}", async () => |
|||
{ |
|||
var tokens = new List<OpenIddictTokenModel>(); |
|||
await foreach (var token in Store.FindBySubjectAsync(subject, cancellationToken)) |
|||
{ |
|||
tokens.Add(token); |
|||
await AddAsync(token, cancellationToken); |
|||
} |
|||
return tokens.ToArray(); |
|||
}, token: cancellationToken); |
|||
|
|||
foreach (var token in tokens) |
|||
{ |
|||
yield return token; |
|||
} |
|||
} |
|||
|
|||
public virtual async ValueTask RemoveAsync(OpenIddictTokenModel token, CancellationToken cancellationToken) |
|||
{ |
|||
await ArrayCache.RemoveManyAsync(new[] |
|||
{ |
|||
$"{nameof(FindAsync)}_{await Store.GetSubjectAsync(token, cancellationToken)}_{await Store.GetApplicationIdAsync(token, cancellationToken)}", |
|||
$"{nameof(FindAsync)}_{await Store.GetSubjectAsync(token, cancellationToken)}_{await Store.GetApplicationIdAsync(token, cancellationToken)}_{Store.GetStatusAsync(token, cancellationToken)}", |
|||
$"{nameof(FindAsync)}_{await Store.GetSubjectAsync(token, cancellationToken)}_{await Store.GetApplicationIdAsync(token, cancellationToken)}_{Store.GetStatusAsync(token, cancellationToken)}_{Store.GetTypeAsync(token, cancellationToken)}", |
|||
$"{nameof(FindByApplicationIdAsync)}_{await Store.GetApplicationIdAsync(token, cancellationToken)}", |
|||
$"{nameof(FindByAuthorizationIdAsync)}_{await Store.GetAuthorizationIdAsync(token, cancellationToken)}", |
|||
$"{nameof(FindBySubjectAsync)}_{await Store.GetSubjectAsync(token, cancellationToken)}" |
|||
}, token: cancellationToken); |
|||
|
|||
await Cache.RemoveAsync($"{nameof(FindByIdAsync)}_{await Store.GetIdAsync(token, cancellationToken)}", token: cancellationToken); |
|||
await Cache.RemoveAsync($"{nameof(FindByReferenceIdAsync)}_{await Store.GetReferenceIdAsync(token, cancellationToken)}", token: cancellationToken); |
|||
} |
|||
} |
|||
@ -0,0 +1,68 @@ |
|||
namespace Volo.Abp.OpenIddict.Tokens; |
|||
|
|||
public static class OpenIddictTokenExtensions |
|||
{ |
|||
public static OpenIddictToken ToEntity(this OpenIddictTokenModel model) |
|||
{ |
|||
Check.NotNull(model, nameof(model)); |
|||
|
|||
return new OpenIddictToken(model.Id) |
|||
{ |
|||
ApplicationId = model.ApplicationId, |
|||
AuthorizationId = model.AuthorizationId, |
|||
CreationDate = model.CreationDate, |
|||
ExpirationDate = model.ExpirationDate, |
|||
Payload = model.Payload, |
|||
Properties = model.Properties, |
|||
RedemptionDate = model.RedemptionDate, |
|||
ReferenceId = model.ReferenceId, |
|||
Status = model.Status, |
|||
Subject = model.Subject, |
|||
Type = model.Type |
|||
}; |
|||
} |
|||
|
|||
public static OpenIddictToken ToEntity(this OpenIddictTokenModel model, OpenIddictToken entity) |
|||
{ |
|||
Check.NotNull(model, nameof(model)); |
|||
Check.NotNull(entity, nameof(entity)); |
|||
|
|||
entity.ApplicationId = model.ApplicationId; |
|||
entity.AuthorizationId = model.AuthorizationId; |
|||
entity.CreationDate = model.CreationDate; |
|||
entity.ExpirationDate = model.ExpirationDate; |
|||
entity.Payload = model.Payload; |
|||
entity.Properties = model.Properties; |
|||
entity.RedemptionDate = model.RedemptionDate; |
|||
entity.ReferenceId = model.ReferenceId; |
|||
entity.Status = model.Status; |
|||
entity.Subject = model.Subject; |
|||
entity.Type = model.Type; |
|||
|
|||
return entity; |
|||
} |
|||
|
|||
public static OpenIddictTokenModel ToModel(this OpenIddictToken model) |
|||
{ |
|||
if(model == null) |
|||
{ |
|||
return null; |
|||
} |
|||
|
|||
return new OpenIddictTokenModel |
|||
{ |
|||
Id = model.Id, |
|||
ApplicationId = model.ApplicationId, |
|||
AuthorizationId = model.AuthorizationId, |
|||
CreationDate = model.CreationDate, |
|||
ExpirationDate = model.ExpirationDate, |
|||
Payload = model.Payload, |
|||
Properties = model.Properties, |
|||
RedemptionDate = model.RedemptionDate, |
|||
ReferenceId = model.ReferenceId, |
|||
Status = model.Status, |
|||
Subject = model.Subject, |
|||
Type = model.Type |
|||
}; |
|||
} |
|||
} |
|||
@ -0,0 +1,71 @@ |
|||
using System; |
|||
using Volo.Abp.MultiTenancy; |
|||
|
|||
namespace Volo.Abp.OpenIddict.Tokens; |
|||
|
|||
[Serializable, IgnoreMultiTenancy] |
|||
public class OpenIddictTokenModel |
|||
{ |
|||
public Guid Id { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Gets or sets the application associated with the current token.
|
|||
/// </summary>
|
|||
public virtual Guid? ApplicationId { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Gets or sets the authorization associated with the current token.
|
|||
/// </summary>
|
|||
public virtual Guid? AuthorizationId { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Gets or sets the UTC creation date of the current token.
|
|||
/// </summary>
|
|||
public virtual DateTime? CreationDate { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Gets or sets the UTC expiration date of the current token.
|
|||
/// </summary>
|
|||
public virtual DateTime? ExpirationDate { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Gets or sets the payload of the current token, if applicable.
|
|||
/// Note: this property is only used for reference tokens
|
|||
/// and may be encrypted for security reasons.
|
|||
/// </summary>
|
|||
public virtual string Payload { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Gets or sets the additional properties serialized as a JSON object,
|
|||
/// or <c>null</c> if no bag was associated with the current token.
|
|||
/// </summary>
|
|||
public virtual string Properties { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Gets or sets the UTC redemption date of the current token.
|
|||
/// </summary>
|
|||
public virtual DateTime? RedemptionDate { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Gets or sets the reference identifier associated
|
|||
/// with the current token, if applicable.
|
|||
/// Note: this property is only used for reference tokens
|
|||
/// and may be hashed or encrypted for security reasons.
|
|||
/// </summary>
|
|||
public virtual string ReferenceId { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Gets or sets the status of the current token.
|
|||
/// </summary>
|
|||
public virtual string Status { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Gets or sets the subject associated with the current token.
|
|||
/// </summary>
|
|||
public virtual string Subject { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Gets or sets the type of the current token.
|
|||
/// </summary>
|
|||
public virtual string Type { get; set; } |
|||
} |
|||
Loading…
Reference in new issue