Browse Source

Move the token providers into the Volo.Abp.Identity namespace

- One namespace no longer spans two assemblies now that they live in the domain layer
- The Data Protection purpose keeps its old string, so outstanding 2FA codes stay valid
pull/26113/head
maliming 3 days ago
parent
commit
27c8f8d4c7
No known key found for this signature in database GPG Key ID: A646B9CB645ECEA4
  1. 3
      docs/en/release-info/migration-guides/abp-10-7.md
  2. 1
      modules/identity/src/Volo.Abp.Identity.Domain/Microsoft/Extensions/DependencyInjection/AbpIdentityBuilderExtensions.cs
  3. 2
      modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AbpChangeEmailTokenProvider.cs
  4. 2
      modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AbpChangeEmailTokenProviderOptions.cs
  5. 2
      modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AbpDataProtectionTokenProviderOptions.cs
  6. 2
      modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AbpDefaultTokenProvider.cs
  7. 2
      modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AbpDefaultTokenProviderOptions.cs
  8. 2
      modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AbpEmailConfirmationTokenProvider.cs
  9. 2
      modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AbpEmailConfirmationTokenProviderOptions.cs
  10. 2
      modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AbpEmailTwoFactorTokenProvider.cs
  11. 2
      modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AbpEmailTwoFactorTokenProviderOptions.cs
  12. 2
      modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AbpLinkUserTokenProviderOptions.cs
  13. 2
      modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AbpPasswordResetTokenProvider.cs
  14. 2
      modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AbpPasswordResetTokenProviderOptions.cs
  15. 2
      modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AbpPhoneNumberTwoFactorTokenProvider.cs
  16. 2
      modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AbpPhoneNumberTwoFactorTokenProviderOptions.cs
  17. 2
      modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AbpSingleActiveTokenProvider.cs
  18. 5
      modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AbpTwoFactorTokenProvider.cs
  19. 2
      modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AbpTwoFactorTokenProviderOptions.cs
  20. 2
      modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityUserManagerSingleActiveTokenExtensions.cs
  21. 2
      modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/LinkUserTokenProvider.cs
  22. 1
      modules/identity/test/Volo.Abp.Identity.TestBase/Volo/Abp/Identity/CrossHostTokenProvider_Tests.cs

3
docs/en/release-info/migration-guides/abp-10-7.md

@ -145,7 +145,7 @@ Add a navigation property to the principal entity if you rely on the previous be
**What changed**
- The ABP token providers and their options moved from the `Volo.Abp.Identity.AspNetCore` assembly to `Volo.Abp.Identity.Domain`, and are now registered by `AbpIdentityDomainModule` instead of `AbpIdentityAspNetCoreModule`. An assembly compiled against an earlier version and not rebuilt cannot resolve them.
- The ABP token providers and their options moved from the `Volo.Abp.Identity.AspNetCore` assembly to `Volo.Abp.Identity.Domain`, out of the `Volo.Abp.Identity.AspNetCore` namespace and into `Volo.Abp.Identity`, and are now registered by `AbpIdentityDomainModule` instead of `AbpIdentityAspNetCoreModule`. An assembly compiled against an earlier version and not rebuilt cannot resolve them. The types that stay in the ASP.NET Core layer, such as `AbpSignInManager` and `AbpIdentityAspNetCoreOptions`, keep their namespace.
- Every host that loads `AbpIdentityDomainModule` therefore resolves the same providers, unless it registers something else itself. Previously the providers were only registered on hosts loading `AbpIdentityAspNetCoreModule`, so a host that generated a token could end up on a different provider than the host that validated it, and the link was rejected as an invalid token.
- `AbpSingleActiveTokenProvider` no longer derives from ASP.NET Core's `DataProtectorTokenProvider<IdentityUser>`; it implements `IUserTwoFactorTokenProvider<IdentityUser>` and re-implements the same protected payload, so the token format is unchanged. Code that casts a provider to `DataProtectorTokenProvider<IdentityUser>` or uses it as a generic constraint no longer compiles, and the `Logger` property the old base class exposed publicly is now protected.
- The provider options classes derive from `AbpDataProtectionTokenProviderOptions` instead of `DataProtectionTokenProviderOptions`. The `Name` and `TokenLifespan` properties are unchanged, but code that assigns one of them to `DataProtectionTokenProviderOptions`, passes it to a method taking that type, returns it, or uses it as a generic constraint no longer compiles.
@ -155,6 +155,7 @@ Add a navigation property to the principal entity if you rely on the previous be
**What to do**
- Replace `using Volo.Abp.Identity.AspNetCore;` with `using Volo.Abp.Identity;` where you use one of the moved types, or add the second one when the file also uses a type that stayed behind.
- Rebuild the solution. No further action is required for the common case: configuring the options and the provider names works exactly as before, and the compiler points at the source level changes below. The assembly move is not one of them, so a package you depend on that was built against the old assembly has to be rebuilt and republished against v10.7 as well.
- If you derive from one of the five DataProtector-based providers, change the logger parameter to `ILogger<AbpSingleActiveTokenProvider>`.
- If you derive from `AbpSingleActiveTokenProvider` directly, give your provider its own options class deriving from `AbpDataProtectionTokenProviderOptions` and inject `IOptions<YourTokenProviderOptions>`, the way the built-in providers do. `IOptions<T>` is covariant, so it satisfies the base constructor. Do not inject `IOptions<AbpDataProtectionTokenProviderOptions>`: the base options class is abstract and the options system cannot create it.

1
modules/identity/src/Volo.Abp.Identity.Domain/Microsoft/Extensions/DependencyInjection/AbpIdentityBuilderExtensions.cs

@ -1,6 +1,5 @@
using Microsoft.AspNetCore.Identity;
using Volo.Abp.Identity;
using Volo.Abp.Identity.AspNetCore;
namespace Microsoft.Extensions.DependencyInjection;

2
modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AspNetCore/AbpChangeEmailTokenProvider.cs → modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AbpChangeEmailTokenProvider.cs

@ -5,7 +5,7 @@ using Microsoft.Extensions.Options;
using Volo.Abp.Identity;
using Volo.Abp.Threading;
namespace Volo.Abp.Identity.AspNetCore;
namespace Volo.Abp.Identity;
/// <summary>
/// Change email token provider that enforces only the most recently issued

2
modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AspNetCore/AbpChangeEmailTokenProviderOptions.cs → modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AbpChangeEmailTokenProviderOptions.cs

@ -1,6 +1,6 @@
using System;
namespace Volo.Abp.Identity.AspNetCore;
namespace Volo.Abp.Identity;
public class AbpChangeEmailTokenProviderOptions : AbpDataProtectionTokenProviderOptions
{

2
modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AspNetCore/AbpDataProtectionTokenProviderOptions.cs → modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AbpDataProtectionTokenProviderOptions.cs

@ -1,6 +1,6 @@
using System;
namespace Volo.Abp.Identity.AspNetCore;
namespace Volo.Abp.Identity;
/// <summary>
/// Stands in for ASP.NET Core's <c>DataProtectionTokenProviderOptions</c>, which is only available

2
modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AspNetCore/AbpDefaultTokenProvider.cs → modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AbpDefaultTokenProvider.cs

@ -5,7 +5,7 @@ using Microsoft.Extensions.Options;
using Volo.Abp.Identity;
using Volo.Abp.Threading;
namespace Volo.Abp.Identity.AspNetCore;
namespace Volo.Abp.Identity;
/// <summary>
/// Replaces ASP.NET Core Identity's default <c>DataProtectorTokenProvider&lt;IdentityUser&gt;</c>

2
modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AspNetCore/AbpDefaultTokenProviderOptions.cs → modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AbpDefaultTokenProviderOptions.cs

@ -1,7 +1,7 @@
using System;
using Microsoft.AspNetCore.Identity;
namespace Volo.Abp.Identity.AspNetCore;
namespace Volo.Abp.Identity;
public class AbpDefaultTokenProviderOptions : AbpDataProtectionTokenProviderOptions
{

2
modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AspNetCore/AbpEmailConfirmationTokenProvider.cs → modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AbpEmailConfirmationTokenProvider.cs

@ -5,7 +5,7 @@ using Microsoft.Extensions.Options;
using Volo.Abp.Identity;
using Volo.Abp.Threading;
namespace Volo.Abp.Identity.AspNetCore;
namespace Volo.Abp.Identity;
/// <summary>
/// Email confirmation token provider that enforces only the most recently issued

2
modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AspNetCore/AbpEmailConfirmationTokenProviderOptions.cs → modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AbpEmailConfirmationTokenProviderOptions.cs

@ -1,6 +1,6 @@
using System;
namespace Volo.Abp.Identity.AspNetCore;
namespace Volo.Abp.Identity;
public class AbpEmailConfirmationTokenProviderOptions : AbpDataProtectionTokenProviderOptions
{

2
modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AspNetCore/AbpEmailTwoFactorTokenProvider.cs → modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AbpEmailTwoFactorTokenProvider.cs

@ -6,7 +6,7 @@ using Volo.Abp.Identity;
using Volo.Abp.Threading;
using Volo.Abp.Timing;
namespace Volo.Abp.Identity.AspNetCore;
namespace Volo.Abp.Identity;
/// <summary>
/// Single-use email 2FA code provider; replaces the ASP.NET Core Identity TOTP-based

2
modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AspNetCore/AbpEmailTwoFactorTokenProviderOptions.cs → modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AbpEmailTwoFactorTokenProviderOptions.cs

@ -1,4 +1,4 @@
namespace Volo.Abp.Identity.AspNetCore;
namespace Volo.Abp.Identity;
public class AbpEmailTwoFactorTokenProviderOptions : AbpTwoFactorTokenProviderOptions
{

2
modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AspNetCore/AbpLinkUserTokenProviderOptions.cs → modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AbpLinkUserTokenProviderOptions.cs

@ -1,6 +1,6 @@
using System;
namespace Volo.Abp.Identity.AspNetCore;
namespace Volo.Abp.Identity;
public class AbpLinkUserTokenProviderOptions : AbpDataProtectionTokenProviderOptions
{

2
modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AspNetCore/AbpPasswordResetTokenProvider.cs → modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AbpPasswordResetTokenProvider.cs

@ -5,7 +5,7 @@ using Microsoft.Extensions.Options;
using Volo.Abp.Identity;
using Volo.Abp.Threading;
namespace Volo.Abp.Identity.AspNetCore;
namespace Volo.Abp.Identity;
/// <summary>
/// Password reset token provider that enforces only the most recently issued

2
modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AspNetCore/AbpPasswordResetTokenProviderOptions.cs → modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AbpPasswordResetTokenProviderOptions.cs

@ -1,6 +1,6 @@
using System;
namespace Volo.Abp.Identity.AspNetCore;
namespace Volo.Abp.Identity;
public class AbpPasswordResetTokenProviderOptions : AbpDataProtectionTokenProviderOptions
{

2
modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AspNetCore/AbpPhoneNumberTwoFactorTokenProvider.cs → modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AbpPhoneNumberTwoFactorTokenProvider.cs

@ -6,7 +6,7 @@ using Volo.Abp.Identity;
using Volo.Abp.Threading;
using Volo.Abp.Timing;
namespace Volo.Abp.Identity.AspNetCore;
namespace Volo.Abp.Identity;
/// <summary>
/// Single-use phone 2FA code provider; replaces the ASP.NET Core Identity TOTP-based

2
modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AspNetCore/AbpPhoneNumberTwoFactorTokenProviderOptions.cs → modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AbpPhoneNumberTwoFactorTokenProviderOptions.cs

@ -1,4 +1,4 @@
namespace Volo.Abp.Identity.AspNetCore;
namespace Volo.Abp.Identity;
public class AbpPhoneNumberTwoFactorTokenProviderOptions : AbpTwoFactorTokenProviderOptions
{

2
modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AspNetCore/AbpSingleActiveTokenProvider.cs → modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AbpSingleActiveTokenProvider.cs

@ -11,7 +11,7 @@ using Microsoft.Extensions.Options;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.Threading;
namespace Volo.Abp.Identity.AspNetCore;
namespace Volo.Abp.Identity;
/// <summary>
/// Base class for ABP token providers that enforce a "single active token" policy: generating a token

5
modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AspNetCore/AbpTwoFactorTokenProvider.cs → modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AbpTwoFactorTokenProvider.cs

@ -10,7 +10,7 @@ using Volo.Abp.Identity;
using Volo.Abp.Threading;
using Volo.Abp.Timing;
namespace Volo.Abp.Identity.AspNetCore;
namespace Volo.Abp.Identity;
/// <summary>
/// Base class for ABP two-factor verification code providers (e.g. Email, Phone).
@ -25,6 +25,9 @@ public abstract class AbpTwoFactorTokenProvider : IUserTwoFactorTokenProvider<Id
protected const char StoredValueSeparator = '|';
/// <summary>
/// A Data Protection purpose, not a type name. Changing it invalidates every outstanding code.
/// </summary>
protected const string DataProtectionPurposeRoot = "Volo.Abp.Identity.AspNetCore.AbpTwoFactorTokenProvider";
protected AbpTwoFactorTokenProviderOptions Options { get; }

2
modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AspNetCore/AbpTwoFactorTokenProviderOptions.cs → modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AbpTwoFactorTokenProviderOptions.cs

@ -1,6 +1,6 @@
using System;
namespace Volo.Abp.Identity.AspNetCore;
namespace Volo.Abp.Identity;
public abstract class AbpTwoFactorTokenProviderOptions
{

2
modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AspNetCore/IdentityUserManagerSingleActiveTokenExtensions.cs → modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityUserManagerSingleActiveTokenExtensions.cs

@ -1,7 +1,7 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Identity;
namespace Volo.Abp.Identity.AspNetCore;
namespace Volo.Abp.Identity;
/// <summary>
/// Provides extension methods on <see cref="IdentityUserManager"/> for invalidating

2
modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AspNetCore/LinkUserTokenProvider.cs → modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/LinkUserTokenProvider.cs

@ -5,7 +5,7 @@ using Microsoft.Extensions.Options;
using Volo.Abp.Identity;
using Volo.Abp.Threading;
namespace Volo.Abp.Identity.AspNetCore;
namespace Volo.Abp.Identity;
/// <summary>
/// Link-user token provider that enforces, per purpose, only the most recently issued

1
modules/identity/test/Volo.Abp.Identity.TestBase/Volo/Abp/Identity/CrossHostTokenProvider_Tests.cs

@ -13,7 +13,6 @@ using Shouldly;
using Volo.Abp.Autofac;
using Volo.Abp.Data;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.Identity.AspNetCore;
using Volo.Abp.Modularity;
using Volo.Abp.MultiTenancy;
using Volo.Abp.Uow;

Loading…
Cancel
Save