Browse Source

Add `AbpOpenIddictStoreOptions` to configure the `IsolationLevel`.

The following isolation levels are supported by Oracle: `IsolationLevel.ReadCommitted and IsolationLevel.Serializable.`
pull/19133/head
maliming 3 years ago
parent
commit
733ff1d813
No known key found for this signature in database GPG Key ID: A646B9CB645ECEA4
  1. 5
      modules/openiddict/src/Volo.Abp.OpenIddict.Domain/Volo/Abp/OpenIddict/AbpOpenIddictStoreBase.cs
  2. 13
      modules/openiddict/src/Volo.Abp.OpenIddict.Domain/Volo/Abp/OpenIddict/AbpOpenIddictStoreOptions.cs
  3. 8
      modules/openiddict/src/Volo.Abp.OpenIddict.Domain/Volo/Abp/OpenIddict/Applications/AbpOpenIddictApplicationStore.cs
  4. 10
      modules/openiddict/src/Volo.Abp.OpenIddict.Domain/Volo/Abp/OpenIddict/Authorizations/AbpOpenIddictAuthorizationStore.cs
  5. 6
      modules/openiddict/src/Volo.Abp.OpenIddict.Domain/Volo/Abp/OpenIddict/Scopes/AbpOpenIddictScopeStore.cs
  6. 8
      modules/openiddict/src/Volo.Abp.OpenIddict.Domain/Volo/Abp/OpenIddict/Tokens/AbpOpenIddictTokenStore.cs

5
modules/openiddict/src/Volo.Abp.OpenIddict.Domain/Volo/Abp/OpenIddict/AbpOpenIddictStoreBase.cs

@ -6,6 +6,7 @@ using System.Text.Json;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using Microsoft.Extensions.Options;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.Guids;
using Volo.Abp.Uow;
@ -22,14 +23,16 @@ public abstract class AbpOpenIddictStoreBase<TRepository>
protected IGuidGenerator GuidGenerator { get; }
protected AbpOpenIddictIdentifierConverter IdentifierConverter { get; }
protected IOpenIddictDbConcurrencyExceptionHandler ConcurrencyExceptionHandler { get; }
protected IOptions<AbpOpenIddictStoreOptions> StoreOptions { get; }
protected AbpOpenIddictStoreBase(TRepository repository, IUnitOfWorkManager unitOfWorkManager, IGuidGenerator guidGenerator, AbpOpenIddictIdentifierConverter identifierConverter, IOpenIddictDbConcurrencyExceptionHandler concurrencyExceptionHandler)
protected AbpOpenIddictStoreBase(TRepository repository, IUnitOfWorkManager unitOfWorkManager, IGuidGenerator guidGenerator, AbpOpenIddictIdentifierConverter identifierConverter, IOpenIddictDbConcurrencyExceptionHandler concurrencyExceptionHandler, IOptions<AbpOpenIddictStoreOptions> storeOptions)
{
Repository = repository;
UnitOfWorkManager = unitOfWorkManager;
GuidGenerator = guidGenerator;
IdentifierConverter = identifierConverter;
ConcurrencyExceptionHandler = concurrencyExceptionHandler;
StoreOptions = storeOptions;
Logger = NullLogger<AbpOpenIddictStoreBase<TRepository>>.Instance;
}

13
modules/openiddict/src/Volo.Abp.OpenIddict.Domain/Volo/Abp/OpenIddict/AbpOpenIddictStoreOptions.cs

@ -0,0 +1,13 @@
using System.Data;
namespace Volo.Abp.OpenIddict;
public class AbpOpenIddictStoreOptions
{
public IsolationLevel DefaultIsolationLevel { get; set; }
public AbpOpenIddictStoreOptions()
{
DefaultIsolationLevel = IsolationLevel.RepeatableRead;
}
}

8
modules/openiddict/src/Volo.Abp.OpenIddict.Domain/Volo/Abp/OpenIddict/Applications/AbpOpenIddictApplicationStore.cs

@ -9,6 +9,7 @@ using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Microsoft.IdentityModel.Tokens;
using OpenIddict.Abstractions;
using Volo.Abp.Data;
@ -28,8 +29,9 @@ public class AbpOpenIddictApplicationStore : AbpOpenIddictStoreBase<IOpenIddictA
IOpenIddictTokenRepository tokenRepository,
IGuidGenerator guidGenerator,
AbpOpenIddictIdentifierConverter identifierConverter,
IOpenIddictDbConcurrencyExceptionHandler concurrencyExceptionHandler)
: base(repository, unitOfWorkManager, guidGenerator, identifierConverter, concurrencyExceptionHandler)
IOpenIddictDbConcurrencyExceptionHandler concurrencyExceptionHandler,
IOptions<AbpOpenIddictStoreOptions> storeOptions)
: base(repository, unitOfWorkManager, guidGenerator, identifierConverter, concurrencyExceptionHandler, storeOptions)
{
TokenRepository = tokenRepository;
}
@ -59,7 +61,7 @@ public class AbpOpenIddictApplicationStore : AbpOpenIddictStoreBase<IOpenIddictA
try
{
using (var uow = UnitOfWorkManager.Begin(requiresNew: true, isTransactional: true, isolationLevel: IsolationLevel.RepeatableRead))
using (var uow = UnitOfWorkManager.Begin(requiresNew: true, isTransactional: true, isolationLevel: StoreOptions.Value.DefaultIsolationLevel))
{
await TokenRepository.DeleteManyByApplicationIdAsync(application.Id, cancellationToken: cancellationToken);

10
modules/openiddict/src/Volo.Abp.OpenIddict.Domain/Volo/Abp/OpenIddict/Authorizations/AbpOpenIddictAuthorizationStore.cs

@ -8,6 +8,7 @@ using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using OpenIddict.Abstractions;
using Volo.Abp.Data;
using Volo.Abp.Guids;
@ -29,8 +30,9 @@ public class AbpOpenIddictAuthorizationStore : AbpOpenIddictStoreBase<IOpenIddic
IOpenIddictApplicationRepository applicationRepository,
IOpenIddictTokenRepository tokenRepository,
AbpOpenIddictIdentifierConverter identifierConverter,
IOpenIddictDbConcurrencyExceptionHandler concurrencyExceptionHandler)
: base(repository, unitOfWorkManager, guidGenerator, identifierConverter, concurrencyExceptionHandler)
IOpenIddictDbConcurrencyExceptionHandler concurrencyExceptionHandler,
IOptions<AbpOpenIddictStoreOptions> storeOptions)
: base(repository, unitOfWorkManager, guidGenerator, identifierConverter, concurrencyExceptionHandler, storeOptions)
{
ApplicationRepository = applicationRepository;
TokenRepository = tokenRepository;
@ -61,7 +63,7 @@ public class AbpOpenIddictAuthorizationStore : AbpOpenIddictStoreBase<IOpenIddic
try
{
using (var uow = UnitOfWorkManager.Begin(requiresNew: true, isTransactional: true, isolationLevel: IsolationLevel.RepeatableRead))
using (var uow = UnitOfWorkManager.Begin(requiresNew: true, isTransactional: true, isolationLevel: StoreOptions.Value.DefaultIsolationLevel))
{
await TokenRepository.DeleteManyByAuthorizationIdAsync(authorization.Id, cancellationToken: cancellationToken);
@ -289,7 +291,7 @@ public class AbpOpenIddictAuthorizationStore : AbpOpenIddictStoreBase<IOpenIddic
public virtual async ValueTask<long> PruneAsync(DateTimeOffset threshold, CancellationToken cancellationToken)
{
using (var uow = UnitOfWorkManager.Begin(requiresNew: true, isTransactional: true, isolationLevel: IsolationLevel.RepeatableRead))
using (var uow = UnitOfWorkManager.Begin(requiresNew: true, isTransactional: true, isolationLevel: StoreOptions.Value.DefaultIsolationLevel))
{
var date = threshold.UtcDateTime;
var count = await Repository.PruneAsync(date, cancellationToken: cancellationToken);

6
modules/openiddict/src/Volo.Abp.OpenIddict.Domain/Volo/Abp/OpenIddict/Scopes/AbpOpenIddictScopeStore.cs

@ -8,6 +8,7 @@ using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using OpenIddict.Abstractions;
using Volo.Abp.Data;
using Volo.Abp.Guids;
@ -22,8 +23,9 @@ public class AbpOpenIddictScopeStore : AbpOpenIddictStoreBase<IOpenIddictScopeRe
IUnitOfWorkManager unitOfWorkManager,
IGuidGenerator guidGenerator,
AbpOpenIddictIdentifierConverter identifierConverter,
IOpenIddictDbConcurrencyExceptionHandler concurrencyExceptionHandler)
: base(repository, unitOfWorkManager, guidGenerator, identifierConverter, concurrencyExceptionHandler)
IOpenIddictDbConcurrencyExceptionHandler concurrencyExceptionHandler,
IOptions<AbpOpenIddictStoreOptions> storeOptions)
: base(repository, unitOfWorkManager, guidGenerator, identifierConverter, concurrencyExceptionHandler, storeOptions)
{
}

8
modules/openiddict/src/Volo.Abp.OpenIddict.Domain/Volo/Abp/OpenIddict/Tokens/AbpOpenIddictTokenStore.cs

@ -8,6 +8,7 @@ using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using OpenIddict.Abstractions;
using Volo.Abp.Data;
using Volo.Abp.Guids;
@ -29,8 +30,9 @@ public class AbpOpenIddictTokenStore : AbpOpenIddictStoreBase<IOpenIddictTokenRe
IOpenIddictApplicationRepository applicationRepository,
IOpenIddictAuthorizationRepository authorizationRepository,
AbpOpenIddictIdentifierConverter identifierConverter,
IOpenIddictDbConcurrencyExceptionHandler concurrencyExceptionHandler)
: base(repository, unitOfWorkManager, guidGenerator, identifierConverter, concurrencyExceptionHandler)
IOpenIddictDbConcurrencyExceptionHandler concurrencyExceptionHandler,
IOptions<AbpOpenIddictStoreOptions> storeOptions)
: base(repository, unitOfWorkManager, guidGenerator, identifierConverter, concurrencyExceptionHandler, storeOptions)
{
ApplicationRepository = applicationRepository;
AuthorizationRepository = authorizationRepository;
@ -309,7 +311,7 @@ public class AbpOpenIddictTokenStore : AbpOpenIddictStoreBase<IOpenIddictTokenRe
public virtual async ValueTask<long> PruneAsync(DateTimeOffset threshold, CancellationToken cancellationToken)
{
using (var uow = UnitOfWorkManager.Begin(requiresNew: true, isTransactional: true, isolationLevel: IsolationLevel.RepeatableRead))
using (var uow = UnitOfWorkManager.Begin(requiresNew: true, isTransactional: true, isolationLevel: StoreOptions.Value.DefaultIsolationLevel))
{
var date = threshold.UtcDateTime;
var count = await Repository.PruneAsync(date, cancellationToken: cancellationToken);

Loading…
Cancel
Save