Merge pull request #7719 from abpframework/maliming/identity-pro-features-settings

Remove TwoFactor's settings and feature.
pull/8128/head
Halil İbrahim Kalkan 5 years ago committed by GitHub
commit e0c1f7dc5e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,9 +0,0 @@
namespace Volo.Abp.Identity.Features
{
public class IdentityFeature
{
public const string GroupName = "Identity";
public const string TwoFactor = GroupName + ".TwoFactor";
}
}

@ -1,51 +0,0 @@
using System;
using Volo.Abp.Features;
using Volo.Abp.Identity.Localization;
using Volo.Abp.Localization;
using Volo.Abp.Validation.StringValues;
namespace Volo.Abp.Identity.Features
{
public class IdentityFeatureDefinitionProvider : FeatureDefinitionProvider
{
public override void Define(IFeatureDefinitionContext context)
{
var group = context.AddGroup(IdentityFeature.GroupName, L("Feature:IdentityGroup"));
group.AddFeature(IdentityFeature.TwoFactor,
IdentityTwoFactorBehaviour.Optional.ToString(),
L("Feature:TwoFactor"),
L("Feature:TwoFactorDescription"),
new SelectionStringValueType
{
ItemSource = new StaticSelectionStringValueItemSource(
new LocalizableSelectionStringValueItem
{
Value = IdentityTwoFactorBehaviour.Optional.ToString(),
DisplayText = GetTwoFactorBehaviourLocalizableStringInfo("Feature:TwoFactor.Optional")
},
new LocalizableSelectionStringValueItem
{
Value = IdentityTwoFactorBehaviour.Disabled.ToString(),
DisplayText = GetTwoFactorBehaviourLocalizableStringInfo("Feature:TwoFactor.Disabled")
},
new LocalizableSelectionStringValueItem
{
Value = IdentityTwoFactorBehaviour.Forced.ToString(),
DisplayText = GetTwoFactorBehaviourLocalizableStringInfo("Feature:TwoFactor.Forced")
}
)
});
}
private static LocalizableString L(string name)
{
return LocalizableString.Create<IdentityResource>(name);
}
private static LocalizableStringInfo GetTwoFactorBehaviourLocalizableStringInfo(string key)
{
return new LocalizableStringInfo(LocalizationResourceNameAttribute.GetName(typeof(IdentityResource)), key);
}
}
}

@ -1,11 +0,0 @@
namespace Volo.Abp.Identity.Features
{
public enum IdentityTwoFactorBehaviour
{
Optional,
Disabled,
Forced
}
}

@ -1,23 +0,0 @@
using System;
using System.Threading.Tasks;
using JetBrains.Annotations;
using Volo.Abp.Features;
namespace Volo.Abp.Identity.Features
{
public static class IdentityTwoFactorBehaviourFeatureHelper
{
public static async Task<IdentityTwoFactorBehaviour> Get([NotNull] IFeatureChecker featureChecker)
{
Check.NotNull(featureChecker, nameof(featureChecker));
var value = await featureChecker.GetOrNullAsync(IdentityFeature.TwoFactor);
if (value.IsNullOrWhiteSpace() || !Enum.TryParse<IdentityTwoFactorBehaviour>(value, out var behaviour))
{
throw new AbpException($"{IdentityFeature.TwoFactor} feature value is invalid");
}
return behaviour;
}
}
}

@ -78,12 +78,6 @@
"Permission:ChangePermissions": "Change permissions",
"Permission:UserManagement": "User management",
"Permission:UserLookup": "User lookup",
"Feature:IdentityGroup": "Identity",
"Feature:TwoFactor": "Two factor behaviour",
"Feature:TwoFactorDescription": "Set two factor behaviour. Optional values: Optional,Disabled,Forced",
"Feature:TwoFactor.Optional": "Optional",
"Feature:TwoFactor.Disabled": "Disabled",
"Feature:TwoFactor.Forced": "Forced",
"DisplayName:Abp.Identity.Password.RequiredLength": "Required length",
"DisplayName:Abp.Identity.Password.RequiredUniqueChars": "Required unique characters number",
"DisplayName:Abp.Identity.Password.RequireNonAlphanumeric": "Required non-alphanumeric character",
@ -111,10 +105,6 @@
"Description:Abp.Identity.SignIn.EnablePhoneNumberConfirmation": "Whether the phoneNumber can be confirmed by the user.",
"Description:Abp.Identity.SignIn.RequireConfirmedPhoneNumber": "Whether a confirmed telephone number is required to sign in.",
"Description:Abp.Identity.User.IsUserNameUpdateEnabled": "Whether the username can be updated by the user.",
"Description:Abp.Identity.User.IsEmailUpdateEnabled": "Whether the email can be updated by the user.",
"DisplayName:Abp.Identity.TwoFactorBehaviour": "Two Factor behaviour",
"Description:Abp.Identity.TwoFactorBehaviour": "Two Factor behaviour",
"DisplayName:Abp.Identity.UsersCanChange": "Allow users to change their Two Factor.",
"Description:Abp.Identity.UsersCanChange": "Allow users to change their Two Factor."
"Description:Abp.Identity.User.IsEmailUpdateEnabled": "Whether the email can be updated by the user."
}
}

@ -76,12 +76,6 @@
"Permission:ChangePermissions": "İzinleri değiştirme",
"Permission:UserManagement": "Kullanıcı yönetimi",
"Permission:UserLookup": "Kullanıcı sorgulama",
"Feature:IdentityGroup": "Kimlik",
"Feature:TwoFactor": "İki faktörlü kimlik doğrulama",
"Feature:TwoFactorDescription": "İki faktörlü kimlik doğrulamanın talep edileceği durumu seçin",
"Feature:TwoFactor.Optional": "İsteğe bağlı",
"Feature:TwoFactor.Disabled": "Asla",
"Feature:TwoFactor.Forced": "Her zaman",
"DisplayName:Abp.Identity.Password.RequiredLength": "Uzunluk gerekli",
"DisplayName:Abp.Identity.Password.RequiredUniqueChars": "Tekil karakter gerekli",
"DisplayName:Abp.Identity.Password.RequireNonAlphanumeric": "Alfasayısal olmayan karakter gerekli",
@ -109,10 +103,6 @@
"Description:Abp.Identity.SignIn.EnablePhoneNumberConfirmation": "Oturum açmak için telefon numarası gerekli",
"Description:Abp.Identity.SignIn.RequireConfirmedPhoneNumber": "Oturum açmak için onaylanmış bir telefon numarasının gerekli olup olmadığı.",
"Description:Abp.Identity.User.IsUserNameUpdateEnabled": "Kullanıcı adının, kullanıcının kendisi tarafından güncellenebilirliği.",
"Description:Abp.Identity.User.IsEmailUpdateEnabled": "E-posta alanının, kullanıcının kendisi tarafından güncellenebilirliği",
"DisplayName:Abp.Identity.TwoFactorBehaviour": "İki faktörlü kimlik doğrulama davranışı",
"Description:Abp.Identity.TwoFactorBehaviour": "İki faktörlü kimlik doğrulama davranışı",
"DisplayName:Abp.Identity.UsersCanChange": "Kullanıcıların iki faktörlü kimlik doğrulama davranışını değiştirmelerine izin verin.",
"Description:Abp.Identity.UsersCanChange": "Kullanıcıların iki faktörlü kimlik doğrulama davranışını değiştirmelerine izin verin"
"Description:Abp.Identity.User.IsEmailUpdateEnabled": "E-posta alanının, kullanıcının kendisi tarafından güncellenebilirliği"
}
}

@ -78,12 +78,6 @@
"Permission:ChangePermissions": "更改权限",
"Permission:UserManagement": "用户管理",
"Permission:UserLookup": "用户查询",
"Feature:IdentityGroup": "身份标识",
"Feature:TwoFactor": "双因素身份验证行为",
"Feature:TwoFactorDescription": "设置双因素身份验证行为. 可选值:可选,禁用,强制启用",
"Feature:TwoFactor.Optional": "可选",
"Feature:TwoFactor.Disabled": "禁用",
"Feature:TwoFactor.Forced": "强制启用",
"DisplayName:Abp.Identity.Password.RequiredLength": "要求长度",
"DisplayName:Abp.Identity.Password.RequiredUniqueChars": "要求唯一字符数量",
"DisplayName:Abp.Identity.Password.RequireNonAlphanumeric": "要求非字母数字",
@ -111,10 +105,6 @@
"Description:Abp.Identity.SignIn.EnablePhoneNumberConfirmation": "用户是否可以确认电话号码",
"Description:Abp.Identity.SignIn.RequireConfirmedPhoneNumber": "登录时是否需要验证的手机号码.",
"Description:Abp.Identity.User.IsUserNameUpdateEnabled": "是否允许用户更新用户名.",
"Description:Abp.Identity.User.IsEmailUpdateEnabled": "是否允许用户更新电子邮箱.",
"DisplayName:Abp.Identity.TwoFactorBehaviour": "双因素身份验证行为",
"Description:Abp.Identity.TwoFactorBehaviour": "双因素身份验证行为",
"DisplayName:Abp.Identity.UsersCanChange": "允许用户更改其因素身份验证.",
"Description:Abp.Identity.UsersCanChange": "允许用户更改其因素身份验证."
"Description:Abp.Identity.User.IsEmailUpdateEnabled": "是否允许用户更新电子邮箱."
}
}
}

@ -78,12 +78,6 @@
"Permission:ChangePermissions": "更改權限",
"Permission:UserManagement": "使用者管理",
"Permission:UserLookup": "使用者查詢",
"Feature:IdentityGroup": "身份識別",
"Feature:TwoFactor": "雙因素身份驗證行為",
"Feature:TwoFactorDescription": "設置雙因素身份驗證行為. 可選值:可選,禁用,強制啟用",
"Feature:TwoFactor.Optional": "選用",
"Feature:TwoFactor.Disabled": "關閉",
"Feature:TwoFactor.Forced": "強制啟用",
"DisplayName:Abp.Identity.Password.RequiredLength": "長度需符合",
"DisplayName:Abp.Identity.Password.RequiredUniqueChars": "需最小特殊字元數",
"DisplayName:Abp.Identity.Password.RequireNonAlphanumeric": "需包含非數字字母",
@ -111,10 +105,6 @@
"Description:Abp.Identity.SignIn.EnablePhoneNumberConfirmation": "是否啟用電話認證.",
"Description:Abp.Identity.SignIn.RequireConfirmedPhoneNumber": "決定使用者是否需電話認證後才能登入.",
"Description:Abp.Identity.User.IsUserNameUpdateEnabled": "決定使用者是否能更新帳號.",
"Description:Abp.Identity.User.IsEmailUpdateEnabled": "決定使用者是否能更新信箱.",
"DisplayName:Abp.Identity.TwoFactorBehaviour": "雙因素認證行為",
"Description:Abp.Identity.TwoFactorBehaviour": "雙因素認證行為",
"DisplayName:Abp.Identity.UsersCanChange": "允許使用者變更雙因素認證.",
"Description:Abp.Identity.UsersCanChange": "允許使用者變更雙因素認證."
"Description:Abp.Identity.User.IsEmailUpdateEnabled": "決定使用者是否能更新信箱."
}
}

@ -48,14 +48,5 @@
public const string MaxUserMembershipCount = OrganizationUnitPrefix + ".MaxUserMembershipCount";
}
public static class TwoFactor
{
private const string TwoFactorPrefix = Prefix + ".TwoFactor";
public const string Behaviour = TwoFactorPrefix + ".Behaviour";
public const string UsersCanChange = TwoFactorPrefix + ".UsersCanChange";
}
}
}

@ -1,24 +0,0 @@
using System;
using System.Threading.Tasks;
using JetBrains.Annotations;
using Volo.Abp.Identity.Features;
using Volo.Abp.Settings;
namespace Volo.Abp.Identity.Settings
{
public static class IdentityTwoFactorBehaviourSettingHelper
{
public static async Task<IdentityTwoFactorBehaviour> Get([NotNull] ISettingProvider settingProvider)
{
Check.NotNull(settingProvider, nameof(settingProvider));
var value = await settingProvider.GetOrNullAsync(IdentitySettingNames.TwoFactor.Behaviour);
if (value.IsNullOrWhiteSpace() || !Enum.TryParse<IdentityTwoFactorBehaviour>(value, out var behaviour))
{
throw new AbpException($"{IdentitySettingNames.TwoFactor.Behaviour} setting value is invalid");
}
return behaviour;
}
}
}

@ -22,9 +22,7 @@
<ItemGroup>
<ProjectReference Include="..\Volo.Abp.Identity.Domain.Shared\Volo.Abp.Identity.Domain.Shared.csproj" />
<ProjectReference Include="..\..\..\users\src\Volo.Abp.Users.Domain\Volo.Abp.Users.Domain.csproj" />
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.AutoMapper\Volo.Abp.AutoMapper.csproj" />
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.Ddd.Domain\Volo.Abp.Ddd.Domain.csproj" />
</ItemGroup>

@ -1,5 +1,4 @@
using Volo.Abp.Identity.Features;
using Volo.Abp.Identity.Localization;
using Volo.Abp.Identity.Localization;
using Volo.Abp.Identity.Settings;
using Volo.Abp.Localization;
using Volo.Abp.Settings;
@ -112,19 +111,7 @@ namespace Volo.Abp.Identity
int.MaxValue.ToString(),
L("Identity.OrganizationUnit.MaxUserMembershipCount"),
L("Identity.OrganizationUnit.MaxUserMembershipCount"),
true),
new SettingDefinition(IdentitySettingNames.TwoFactor.Behaviour,
IdentityTwoFactorBehaviour.Optional.ToString(),
L("DisplayName:Abp.Identity.TwoFactorBehaviour"),
L("Description:Abp.Identity.TwoFactorBehaviour"),
isVisibleToClients: true),
new SettingDefinition(IdentitySettingNames.TwoFactor.UsersCanChange,
true.ToString(),
L("DisplayName:Abp.Identity.UsersCanChange"),
L("Description:Abp.Identity.UsersCanChange"),
isVisibleToClients: true)
true)
);
}

@ -1,70 +0,0 @@
using System.Threading.Tasks;
using Volo.Abp.Domain.Services;
using Volo.Abp.Features;
using Volo.Abp.Identity.Features;
using Volo.Abp.Identity.Settings;
using Volo.Abp.Settings;
namespace Volo.Abp.Identity
{
public class IdentityTwoFactorManager : IDomainService
{
protected IFeatureChecker FeatureChecker { get; }
protected ISettingProvider SettingProvider { get; }
public IdentityTwoFactorManager(IFeatureChecker featureChecker, ISettingProvider settingProvider)
{
FeatureChecker = featureChecker;
SettingProvider = settingProvider;
}
public virtual async Task<bool> IsOptionalAsync()
{
var feature = await IdentityTwoFactorBehaviourFeatureHelper.Get(FeatureChecker);
if (feature == IdentityTwoFactorBehaviour.Optional)
{
var setting = await IdentityTwoFactorBehaviourSettingHelper.Get(SettingProvider);
if (setting == IdentityTwoFactorBehaviour.Optional)
{
return true;
}
}
return false;
}
public virtual async Task<bool> IsForcedEnableAsync()
{
var feature = await IdentityTwoFactorBehaviourFeatureHelper.Get(FeatureChecker);
if (feature == IdentityTwoFactorBehaviour.Forced)
{
return true;
}
var setting = await IdentityTwoFactorBehaviourSettingHelper.Get(SettingProvider);
if (setting == IdentityTwoFactorBehaviour.Forced)
{
return true;
}
return false;
}
public virtual async Task<bool> IsForcedDisableAsync()
{
var feature = await IdentityTwoFactorBehaviourFeatureHelper.Get(FeatureChecker);
if (feature == IdentityTwoFactorBehaviour.Disabled)
{
return true;
}
var setting = await IdentityTwoFactorBehaviourSettingHelper.Get(SettingProvider);
if (setting == IdentityTwoFactorBehaviour.Disabled)
{
return true;
}
return false;
}
}
}

@ -11,11 +11,7 @@ using Microsoft.Extensions.Logging;
using Volo.Abp.Data;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.Features;
using Volo.Abp.Guids;
using Volo.Abp.Identity.Features;
using Volo.Abp.Identity.Settings;
using Volo.Abp.Settings;
namespace Volo.Abp.Identity
{
@ -60,17 +56,12 @@ namespace Volo.Abp.Identity
protected ILookupNormalizer LookupNormalizer { get; }
protected IIdentityUserRepository UserRepository { get; }
protected IFeatureChecker FeatureChecker { get; }
protected ISettingProvider SettingProvider { get; }
public IdentityUserStore(
IIdentityUserRepository userRepository,
IIdentityRoleRepository roleRepository,
IGuidGenerator guidGenerator,
ILogger<IdentityRoleStore> logger,
ILookupNormalizer lookupNormalizer,
IFeatureChecker featureChecker,
ISettingProvider settingProvider,
IdentityErrorDescriber describer = null)
{
UserRepository = userRepository;
@ -78,8 +69,6 @@ namespace Volo.Abp.Identity
GuidGenerator = guidGenerator;
Logger = logger;
LookupNormalizer = lookupNormalizer;
FeatureChecker = featureChecker;
SettingProvider = settingProvider;
ErrorDescriber = describer ?? new IdentityErrorDescriber();
}
@ -942,33 +931,13 @@ namespace Volo.Abp.Identity
/// The <see cref="Task"/> that represents the asynchronous operation, containing a flag indicating whether the specified
/// <paramref name="user"/> has two factor authentication enabled or not.
/// </returns>
public virtual async Task<bool> GetTwoFactorEnabledAsync([NotNull] IdentityUser user, CancellationToken cancellationToken = default)
public virtual Task<bool> GetTwoFactorEnabledAsync([NotNull] IdentityUser user, CancellationToken cancellationToken = default)
{
cancellationToken.ThrowIfCancellationRequested();
Check.NotNull(user, nameof(user));
var feature = await IdentityTwoFactorBehaviourFeatureHelper.Get(FeatureChecker);
if (feature == IdentityTwoFactorBehaviour.Disabled)
{
return false;
}
if (feature == IdentityTwoFactorBehaviour.Forced)
{
return true;
}
var setting = await IdentityTwoFactorBehaviourSettingHelper.Get(SettingProvider);
if (setting == IdentityTwoFactorBehaviour.Disabled)
{
return false;
}
if (setting == IdentityTwoFactorBehaviour.Forced)
{
return true;
}
return user.TwoFactorEnabled;
return Task.FromResult(user.TwoFactorEnabled);
}
/// <summary>

Loading…
Cancel
Save