mirror of https://github.com/abpframework/abp.git
657 changed files with 2388 additions and 98590 deletions
@ -1,3 +1,3 @@ |
|||
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd"> |
|||
<ConfigureAwait /> |
|||
<ConfigureAwait ContinueOnCapturedContext="false" /> |
|||
</Weavers> |
|||
@ -0,0 +1,15 @@ |
|||
using System.Collections.Generic; |
|||
|
|||
namespace Volo.Abp.AspNetCore.Auditing |
|||
{ |
|||
public class AbpAspNetCoreAuditingOptions |
|||
{ |
|||
/// <summary>
|
|||
/// This is used to disable the <see cref="AbpAuditingMiddleware"/>,
|
|||
/// app.UseAuditing(), for the specified URLs.
|
|||
/// <see cref="AbpAuditingMiddleware"/> will be disabled for URLs
|
|||
/// starting with an ignored URL.
|
|||
/// </summary>
|
|||
public List<string> IgnoredUrls { get; } = new List<string>(); |
|||
} |
|||
} |
|||
@ -0,0 +1,15 @@ |
|||
using System.Collections.Generic; |
|||
|
|||
namespace Volo.Abp.AspNetCore.Uow |
|||
{ |
|||
public class AbpAspNetCoreUnitOfWorkOptions |
|||
{ |
|||
/// <summary>
|
|||
/// This is used to disable the <see cref="AbpUnitOfWorkMiddleware"/>,
|
|||
/// app.UseUnitOfWork(), for the specified URLs.
|
|||
/// <see cref="AbpUnitOfWorkMiddleware"/> will be disabled for URLs
|
|||
/// starting with an ignored URL.
|
|||
/// </summary>
|
|||
public List<string> IgnoredUrls { get; } = new List<string>(); |
|||
} |
|||
} |
|||
@ -0,0 +1,7 @@ |
|||
namespace Volo.Abp.GlobalFeatures |
|||
{ |
|||
public class AbpGlobalFeatureErrorCodes |
|||
{ |
|||
public const string GlobalFeatureIsNotEnabled = "Volo.GlobalFeature:010001"; |
|||
} |
|||
} |
|||
@ -0,0 +1,23 @@ |
|||
using System; |
|||
using Volo.Abp.ExceptionHandling; |
|||
|
|||
namespace Volo.Abp.GlobalFeatures |
|||
{ |
|||
[Serializable] |
|||
public class AbpGlobalFeatureNotEnabledException : AbpException, IHasErrorCode |
|||
{ |
|||
public string Code { get; } |
|||
|
|||
public AbpGlobalFeatureNotEnabledException(string message = null, string code = null, Exception innerException = null) |
|||
: base(message, innerException) |
|||
{ |
|||
Code = code; |
|||
} |
|||
|
|||
public AbpGlobalFeatureNotEnabledException WithData(string name, object value) |
|||
{ |
|||
Data[name] = value; |
|||
return this; |
|||
} |
|||
} |
|||
} |
|||
@ -1,9 +1,42 @@ |
|||
using Volo.Abp.Modularity; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Volo.Abp.GlobalFeatures.Localization; |
|||
using Volo.Abp.Localization; |
|||
using Volo.Abp.Localization.ExceptionHandling; |
|||
using Volo.Abp.Modularity; |
|||
using Volo.Abp.VirtualFileSystem; |
|||
|
|||
namespace Volo.Abp.GlobalFeatures |
|||
{ |
|||
[DependsOn( |
|||
typeof(AbpLocalizationModule), |
|||
typeof(AbpVirtualFileSystemModule) |
|||
)] |
|||
public class AbpGlobalFeaturesModule : AbpModule |
|||
{ |
|||
public override void PreConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
context.Services.OnRegistred(GlobalFeatureInterceptorRegistrar.RegisterIfNeeded); |
|||
} |
|||
|
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
|
|||
Configure<AbpVirtualFileSystemOptions>(options => |
|||
{ |
|||
options.FileSets.AddEmbedded<AbpGlobalFeatureResource>(); |
|||
}); |
|||
|
|||
Configure<AbpLocalizationOptions>(options => |
|||
{ |
|||
options.Resources |
|||
.Add<AbpGlobalFeatureResource>("en") |
|||
.AddVirtualJson("/Volo/Abp/GlobalFeatures/Localization"); |
|||
}); |
|||
|
|||
Configure<AbpExceptionLocalizationOptions>(options => |
|||
{ |
|||
options.MapCodeNamespace("Volo.GlobalFeature", typeof(AbpGlobalFeatureResource)); |
|||
}); |
|||
} |
|||
} |
|||
} |
|||
|
|||
@ -0,0 +1,14 @@ |
|||
using System; |
|||
using Volo.Abp.Reflection; |
|||
|
|||
namespace Volo.Abp.GlobalFeatures |
|||
{ |
|||
public static class GlobalFeatureHelper |
|||
{ |
|||
public static bool IsGlobalFeatureEnabled(Type type, out RequiresGlobalFeatureAttribute attribute) |
|||
{ |
|||
attribute = ReflectionHelper.GetSingleAttributeOrDefault<RequiresGlobalFeatureAttribute>(type); |
|||
return attribute == null || GlobalFeatureManager.Instance.IsEnabled(attribute.GetFeatureName()); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,28 @@ |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Aspects; |
|||
using Volo.Abp.DependencyInjection; |
|||
using Volo.Abp.DynamicProxy; |
|||
|
|||
namespace Volo.Abp.GlobalFeatures |
|||
{ |
|||
public class GlobalFeatureInterceptor : AbpInterceptor, ITransientDependency |
|||
{ |
|||
public override async Task InterceptAsync(IAbpMethodInvocation invocation) |
|||
{ |
|||
if (AbpCrossCuttingConcerns.IsApplied(invocation.TargetObject, AbpCrossCuttingConcerns.GlobalFeatureChecking)) |
|||
{ |
|||
await invocation.ProceedAsync(); |
|||
return; |
|||
} |
|||
|
|||
if (!GlobalFeatureHelper.IsGlobalFeatureEnabled(invocation.TargetObject.GetType(), out var attribute)) |
|||
{ |
|||
throw new AbpGlobalFeatureNotEnabledException(code: AbpGlobalFeatureErrorCodes.GlobalFeatureIsNotEnabled) |
|||
.WithData("ServiceName", invocation.TargetObject.GetType().FullName) |
|||
.WithData("GlobalFeatureName", attribute.Name); |
|||
} |
|||
|
|||
await invocation.ProceedAsync(); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,22 @@ |
|||
using System; |
|||
using Volo.Abp.DependencyInjection; |
|||
using Volo.Abp.DynamicProxy; |
|||
|
|||
namespace Volo.Abp.GlobalFeatures |
|||
{ |
|||
public static class GlobalFeatureInterceptorRegistrar |
|||
{ |
|||
public static void RegisterIfNeeded(IOnServiceRegistredContext context) |
|||
{ |
|||
if (ShouldIntercept(context.ImplementationType)) |
|||
{ |
|||
context.Interceptors.TryAdd<GlobalFeatureInterceptor>(); |
|||
} |
|||
} |
|||
|
|||
private static bool ShouldIntercept(Type type) |
|||
{ |
|||
return !DynamicProxyIgnoreTypes.Contains(type) && typeof(IGlobalFeatureCheckingEnabled).IsAssignableFrom(type); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,7 @@ |
|||
namespace Volo.Abp.GlobalFeatures |
|||
{ |
|||
public interface IGlobalFeatureCheckingEnabled |
|||
{ |
|||
|
|||
} |
|||
} |
|||
@ -0,0 +1,10 @@ |
|||
using Volo.Abp.Localization; |
|||
|
|||
namespace Volo.Abp.GlobalFeatures.Localization |
|||
{ |
|||
[LocalizationResourceName("AbpGlobalFeature")] |
|||
public class AbpGlobalFeatureResource |
|||
{ |
|||
|
|||
} |
|||
} |
|||
@ -0,0 +1,6 @@ |
|||
{ |
|||
"culture": "en", |
|||
"texts": { |
|||
"Volo.GlobalFeature:010001": "The '{ServiceName}' service needs to enable '{GlobalFeatureName}' feature." |
|||
} |
|||
} |
|||
@ -0,0 +1,6 @@ |
|||
{ |
|||
"culture": "tr", |
|||
"texts": { |
|||
"Volo.GlobalFeature:010001": "'{ServiceName}' hizmetinin '{GlobalFeatureName}' özelliğini etkinleştirmesi gerekiyor." |
|||
} |
|||
} |
|||
@ -0,0 +1,6 @@ |
|||
{ |
|||
"culture": "zh-Hans", |
|||
"texts": { |
|||
"Volo.GlobalFeature:010001": "'{ServiceName}'服务需要启用'{GlobalFeatureName}'功能." |
|||
} |
|||
} |
|||
@ -0,0 +1,6 @@ |
|||
{ |
|||
"culture": "zh-Hant", |
|||
"texts": { |
|||
"Volo.GlobalFeature:010001": "'{ServiceName}'服務需要啟用'{GlobalFeatureName}'功能." |
|||
} |
|||
} |
|||
@ -0,0 +1,30 @@ |
|||
using Shouldly; |
|||
using Volo.Abp.AspNetCore.ExceptionHandling; |
|||
using Volo.Abp.Localization; |
|||
using Xunit; |
|||
|
|||
namespace Volo.Abp.GlobalFeatures |
|||
{ |
|||
public class AbpGlobalFeatureNotEnableException_Localization_Test : GlobalFeatureTestBase |
|||
{ |
|||
private readonly IExceptionToErrorInfoConverter _exceptionToErrorInfoConverter; |
|||
|
|||
public AbpGlobalFeatureNotEnableException_Localization_Test() |
|||
{ |
|||
_exceptionToErrorInfoConverter = GetRequiredService<IExceptionToErrorInfoConverter>(); |
|||
} |
|||
|
|||
[Fact] |
|||
public void AbpAuthorizationException_Localization() |
|||
{ |
|||
using (CultureHelper.Use("zh-Hans")) |
|||
{ |
|||
var exception = new AbpGlobalFeatureNotEnabledException(code: AbpGlobalFeatureErrorCodes.GlobalFeatureIsNotEnabled) |
|||
.WithData("ServiceName", "MyService") |
|||
.WithData("GlobalFeatureName", "TestFeature");; |
|||
var errorInfo = _exceptionToErrorInfoConverter.Convert(exception, false); |
|||
errorInfo.Message.ShouldBe("'MyService'服务需要启用'TestFeature'功能."); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,61 @@ |
|||
using System.Threading.Tasks; |
|||
using Shouldly; |
|||
using Volo.Abp.Application.Services; |
|||
using Volo.Abp.DependencyInjection; |
|||
using Xunit; |
|||
|
|||
namespace Volo.Abp.GlobalFeatures |
|||
{ |
|||
public class GlobalFeatureInterceptor_Tests : GlobalFeatureTestBase |
|||
{ |
|||
private readonly TestAppServiceV1 _testAppServiceV1; |
|||
private readonly TestAppServiceV2 _testAppServiceV2; |
|||
|
|||
public GlobalFeatureInterceptor_Tests() |
|||
{ |
|||
_testAppServiceV1 = GetRequiredService<TestAppServiceV1>(); |
|||
_testAppServiceV2 = GetRequiredService<TestAppServiceV2>(); |
|||
} |
|||
|
|||
[Fact] |
|||
public async Task Interceptor_Test() |
|||
{ |
|||
var ex = await Assert.ThrowsAsync<AbpGlobalFeatureNotEnabledException>(async () => |
|||
{ |
|||
await _testAppServiceV1.TestMethod(); |
|||
}); |
|||
|
|||
ex.Data["ServiceName"].ShouldBe(_testAppServiceV1.GetType().FullName); |
|||
ex.Data["GlobalFeatureName"].ShouldBe(TestFeature.Name); |
|||
|
|||
GlobalFeatureManager.Instance.Enable(TestFeature.Name); |
|||
|
|||
(await _testAppServiceV1.TestMethod()).ShouldBe(1); |
|||
(await _testAppServiceV2.TestMethod()).ShouldBe(1); |
|||
} |
|||
|
|||
public interface ITestAppService : IApplicationService |
|||
{ |
|||
Task<int> TestMethod(); |
|||
} |
|||
|
|||
[RequiresGlobalFeature(TestFeature.Name)] |
|||
[ExposeServices(typeof(TestAppServiceV1))] |
|||
public class TestAppServiceV1 : ApplicationService, ITestAppService |
|||
{ |
|||
public virtual Task<int> TestMethod() |
|||
{ |
|||
return Task.FromResult(1); |
|||
} |
|||
} |
|||
|
|||
[ExposeServices(typeof(TestAppServiceV2))] |
|||
public class TestAppServiceV2 : ApplicationService, ITestAppService |
|||
{ |
|||
public virtual Task<int> TestMethod() |
|||
{ |
|||
return Task.FromResult(1); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,12 @@ |
|||
using Volo.Abp.Testing; |
|||
|
|||
namespace Volo.Abp.GlobalFeatures |
|||
{ |
|||
public abstract class GlobalFeatureTestBase : AbpIntegratedTest<GlobalFeatureTestModule> |
|||
{ |
|||
protected override void SetAbpApplicationCreationOptions(AbpApplicationCreationOptions options) |
|||
{ |
|||
options.UseAutofac(); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,16 @@ |
|||
using Volo.Abp.Application; |
|||
using Volo.Abp.Autofac; |
|||
using Volo.Abp.ExceptionHandling; |
|||
using Volo.Abp.Modularity; |
|||
|
|||
namespace Volo.Abp.GlobalFeatures |
|||
{ |
|||
[DependsOn(typeof(AbpAutofacModule))] |
|||
[DependsOn(typeof(AbpGlobalFeaturesModule))] |
|||
[DependsOn(typeof(AbpDddApplicationModule))] |
|||
[DependsOn(typeof(AbpExceptionHandlingModule))] |
|||
public class GlobalFeatureTestModule : AbpModule |
|||
{ |
|||
|
|||
} |
|||
} |
|||
@ -0,0 +1,27 @@ |
|||
namespace Volo.Abp.GlobalFeatures |
|||
{ |
|||
[GlobalFeatureName(Name)] |
|||
public class TestFeature : Abp.GlobalFeatures.GlobalFeature |
|||
{ |
|||
public const string Name = "TestFeature1"; |
|||
|
|||
internal TestFeature(TestGlobalModuleFeatures testGlobalModule) |
|||
: base(testGlobalModule) |
|||
{ |
|||
|
|||
} |
|||
} |
|||
|
|||
public class TestGlobalModuleFeatures : GlobalModuleFeatures |
|||
{ |
|||
public const string ModuleName = "GlobalFeatureTest"; |
|||
|
|||
public TestFeature Test => GetFeature<TestFeature>(); |
|||
|
|||
public TestGlobalModuleFeatures(GlobalFeatureManager featureManager) |
|||
: base(featureManager) |
|||
{ |
|||
AddFeature(new TestFeature(this)); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,14 @@ |
|||
using Volo.Abp.AspNetCore.Components.Server.Theming; |
|||
using Volo.Abp.Modularity; |
|||
|
|||
namespace Volo.Abp.FeatureManagement.Blazor.Server |
|||
{ |
|||
[DependsOn( |
|||
typeof(AbpFeatureManagementBlazorModule), |
|||
typeof(AbpAspNetCoreComponentsServerThemingModule) |
|||
)] |
|||
public class AbpFeatureManagementBlazorServerModule : AbpModule |
|||
{ |
|||
|
|||
} |
|||
} |
|||
@ -0,0 +1,3 @@ |
|||
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd"> |
|||
<ConfigureAwait ContinueOnCapturedContext="false" /> |
|||
</Weavers> |
|||
@ -0,0 +1,30 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> |
|||
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. --> |
|||
<xs:element name="Weavers"> |
|||
<xs:complexType> |
|||
<xs:all> |
|||
<xs:element name="ConfigureAwait" minOccurs="0" maxOccurs="1"> |
|||
<xs:complexType> |
|||
<xs:attribute name="ContinueOnCapturedContext" type="xs:boolean" /> |
|||
</xs:complexType> |
|||
</xs:element> |
|||
</xs:all> |
|||
<xs:attribute name="VerifyAssembly" type="xs:boolean"> |
|||
<xs:annotation> |
|||
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation> |
|||
</xs:annotation> |
|||
</xs:attribute> |
|||
<xs:attribute name="VerifyIgnoreCodes" type="xs:string"> |
|||
<xs:annotation> |
|||
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation> |
|||
</xs:annotation> |
|||
</xs:attribute> |
|||
<xs:attribute name="GenerateXsd" type="xs:boolean"> |
|||
<xs:annotation> |
|||
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation> |
|||
</xs:annotation> |
|||
</xs:attribute> |
|||
</xs:complexType> |
|||
</xs:element> |
|||
</xs:schema> |
|||
@ -0,0 +1,18 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk.Razor"> |
|||
|
|||
<Import Project="..\..\..\..\configureawait.props"/> |
|||
<Import Project="..\..\..\..\common.props"/> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>net5.0</TargetFramework> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.AspNetCore.Components.Server.Theming\Volo.Abp.AspNetCore.Components.Server.Theming.csproj"/> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\Volo.Abp.FeatureManagement.Blazor\Volo.Abp.FeatureManagement.Blazor.csproj"/> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -0,0 +1,14 @@ |
|||
using Volo.Abp.AspNetCore.Components.WebAssembly.Theming; |
|||
using Volo.Abp.Modularity; |
|||
|
|||
namespace Volo.Abp.FeatureManagement.Blazor.WebAssembly |
|||
{ |
|||
[DependsOn( |
|||
typeof(AbpFeatureManagementBlazorModule), |
|||
typeof(AbpAspNetCoreComponentsWebAssemblyThemingModule), |
|||
typeof(AbpFeatureManagementHttpApiClientModule) |
|||
)] |
|||
public class AbpFeatureManagementBlazorWebAssemblyModule : AbpModule |
|||
{ |
|||
} |
|||
} |
|||
@ -0,0 +1,3 @@ |
|||
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd"> |
|||
<ConfigureAwait ContinueOnCapturedContext="false" /> |
|||
</Weavers> |
|||
@ -0,0 +1,30 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> |
|||
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. --> |
|||
<xs:element name="Weavers"> |
|||
<xs:complexType> |
|||
<xs:all> |
|||
<xs:element name="ConfigureAwait" minOccurs="0" maxOccurs="1"> |
|||
<xs:complexType> |
|||
<xs:attribute name="ContinueOnCapturedContext" type="xs:boolean" /> |
|||
</xs:complexType> |
|||
</xs:element> |
|||
</xs:all> |
|||
<xs:attribute name="VerifyAssembly" type="xs:boolean"> |
|||
<xs:annotation> |
|||
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation> |
|||
</xs:annotation> |
|||
</xs:attribute> |
|||
<xs:attribute name="VerifyIgnoreCodes" type="xs:string"> |
|||
<xs:annotation> |
|||
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation> |
|||
</xs:annotation> |
|||
</xs:attribute> |
|||
<xs:attribute name="GenerateXsd" type="xs:boolean"> |
|||
<xs:annotation> |
|||
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation> |
|||
</xs:annotation> |
|||
</xs:attribute> |
|||
</xs:complexType> |
|||
</xs:element> |
|||
</xs:schema> |
|||
@ -0,0 +1,19 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk.Razor"> |
|||
|
|||
<Import Project="..\..\..\..\configureawait.props" /> |
|||
<Import Project="..\..\..\..\common.props" /> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>net5.0</TargetFramework> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.AspNetCore.Components.WebAssembly.Theming\Volo.Abp.AspNetCore.Components.WebAssembly.Theming.csproj" /> |
|||
<ProjectReference Include="..\Volo.Abp.FeatureManagement.HttpApi.Client\Volo.Abp.FeatureManagement.HttpApi.Client.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\Volo.Abp.FeatureManagement.Blazor\Volo.Abp.FeatureManagement.Blazor.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -0,0 +1,15 @@ |
|||
using Volo.Abp.AspNetCore.Components.Server.Theming; |
|||
using Volo.Abp.Modularity; |
|||
using Volo.Abp.PermissionManagement.Blazor.Server; |
|||
|
|||
namespace Volo.Abp.Identity.Blazor.Server |
|||
{ |
|||
[DependsOn( |
|||
typeof(AbpIdentityBlazorModule), |
|||
typeof(AbpPermissionManagementBlazorServerModule), |
|||
typeof(AbpAspNetCoreComponentsServerThemingModule) |
|||
)] |
|||
public class AbpIdentityBlazorServerModule : AbpModule |
|||
{ |
|||
} |
|||
} |
|||
@ -0,0 +1,3 @@ |
|||
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd"> |
|||
<ConfigureAwait ContinueOnCapturedContext="false" /> |
|||
</Weavers> |
|||
@ -0,0 +1,30 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> |
|||
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. --> |
|||
<xs:element name="Weavers"> |
|||
<xs:complexType> |
|||
<xs:all> |
|||
<xs:element name="ConfigureAwait" minOccurs="0" maxOccurs="1"> |
|||
<xs:complexType> |
|||
<xs:attribute name="ContinueOnCapturedContext" type="xs:boolean" /> |
|||
</xs:complexType> |
|||
</xs:element> |
|||
</xs:all> |
|||
<xs:attribute name="VerifyAssembly" type="xs:boolean"> |
|||
<xs:annotation> |
|||
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation> |
|||
</xs:annotation> |
|||
</xs:attribute> |
|||
<xs:attribute name="VerifyIgnoreCodes" type="xs:string"> |
|||
<xs:annotation> |
|||
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation> |
|||
</xs:annotation> |
|||
</xs:attribute> |
|||
<xs:attribute name="GenerateXsd" type="xs:boolean"> |
|||
<xs:annotation> |
|||
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation> |
|||
</xs:annotation> |
|||
</xs:attribute> |
|||
</xs:complexType> |
|||
</xs:element> |
|||
</xs:schema> |
|||
@ -0,0 +1,19 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk.Razor"> |
|||
|
|||
<Import Project="..\..\..\..\configureawait.props"/> |
|||
<Import Project="..\..\..\..\common.props"/> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>net5.0</TargetFramework> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.AspNetCore.Components.Server.Theming\Volo.Abp.AspNetCore.Components.Server.Theming.csproj"/> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\Volo.Abp.Identity.Blazor\Volo.Abp.Identity.Blazor.csproj"/> |
|||
<ProjectReference Include="..\..\..\permission-management\src\Volo.Abp.PermissionManagement.Blazor.Server\Volo.Abp.PermissionManagement.Blazor.Server.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -0,0 +1,16 @@ |
|||
using Volo.Abp.AspNetCore.Components.WebAssembly.Theming; |
|||
using Volo.Abp.Modularity; |
|||
using Volo.Abp.PermissionManagement.Blazor.WebAssembly; |
|||
|
|||
namespace Volo.Abp.Identity.Blazor.WebAssembly |
|||
{ |
|||
[DependsOn( |
|||
typeof(AbpIdentityBlazorModule), |
|||
typeof(AbpPermissionManagementBlazorWebAssemblyModule), |
|||
typeof(AbpAspNetCoreComponentsWebAssemblyThemingModule), |
|||
typeof(AbpIdentityHttpApiClientModule) |
|||
)] |
|||
public class AbpIdentityBlazorWebAssemblyModule : AbpModule |
|||
{ |
|||
} |
|||
} |
|||
@ -0,0 +1,3 @@ |
|||
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd"> |
|||
<ConfigureAwait ContinueOnCapturedContext="false" /> |
|||
</Weavers> |
|||
@ -0,0 +1,30 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> |
|||
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. --> |
|||
<xs:element name="Weavers"> |
|||
<xs:complexType> |
|||
<xs:all> |
|||
<xs:element name="ConfigureAwait" minOccurs="0" maxOccurs="1"> |
|||
<xs:complexType> |
|||
<xs:attribute name="ContinueOnCapturedContext" type="xs:boolean" /> |
|||
</xs:complexType> |
|||
</xs:element> |
|||
</xs:all> |
|||
<xs:attribute name="VerifyAssembly" type="xs:boolean"> |
|||
<xs:annotation> |
|||
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation> |
|||
</xs:annotation> |
|||
</xs:attribute> |
|||
<xs:attribute name="VerifyIgnoreCodes" type="xs:string"> |
|||
<xs:annotation> |
|||
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation> |
|||
</xs:annotation> |
|||
</xs:attribute> |
|||
<xs:attribute name="GenerateXsd" type="xs:boolean"> |
|||
<xs:annotation> |
|||
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation> |
|||
</xs:annotation> |
|||
</xs:attribute> |
|||
</xs:complexType> |
|||
</xs:element> |
|||
</xs:schema> |
|||
@ -0,0 +1,20 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk.Razor"> |
|||
|
|||
<Import Project="..\..\..\..\configureawait.props" /> |
|||
<Import Project="..\..\..\..\common.props" /> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>net5.0</TargetFramework> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.AspNetCore.Components.WebAssembly.Theming\Volo.Abp.AspNetCore.Components.WebAssembly.Theming.csproj" /> |
|||
<ProjectReference Include="..\Volo.Abp.Identity.HttpApi.Client\Volo.Abp.Identity.HttpApi.Client.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\Volo.Abp.Identity.Blazor\Volo.Abp.Identity.Blazor.csproj" /> |
|||
<ProjectReference Include="..\..\..\permission-management\src\Volo.Abp.PermissionManagement.Blazor.WebAssembly\Volo.Abp.PermissionManagement.Blazor.WebAssembly.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -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; |
|||
} |
|||
} |
|||
} |
|||
@ -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; |
|||
} |
|||
} |
|||
} |
|||
@ -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; |
|||
} |
|||
} |
|||
} |
|||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue