Activities of "maksym"

  • ABP Framework version: v7.3.3
  • UI Type: Blazor Server
  • Database System: EF Core SQL Server
  • Tiered (for MVC) or Auth Server Separated (for Angular): yes
  • Exception message and full stack trace:
  • Steps to reproduce the issue:

Inspired by this documentation.

What is the best way to enable/disable a global EF filter for particular users based on their permissions?

In this particular case, we have created a ITestData interface which domain objects can inherit from and implement bool IsTestDate { get; set; } that states whether a particular line in the database is test data or not. Used in some tests we have in production. Like so:

class SomeUserData : FullyAuditedEntity, ITestData
{
	public string UserData1 { get; set; }
	public string UserData2 { get; set; }

	public bool IsTestData { get; set; } = true; // <- come from ITestData
}

We don't want regular users to see this test data, so we want to tie it with a permission.

We do that by creating a middleware that enables/disables the ITestData EF global filter if the user has or doesn't have the permission assigned respectively.

public class TestDataPermissionMiddleware : IMiddleware, IScopedDependency
{
    private readonly ILogger<TestDataPermissionMiddleware> _logger;
    private readonly IAuthorizationService _authorizationService;
    private readonly IDataFilter<ITestData> _dataFilter;

    public TestDataPermissionMiddleware(ILogger<TestDataPermissionMiddleware> logger, IAuthorizationService authorizationService, IDataFilter<ITestData> dataFilter)
    {
        _logger = logger;
        _authorizationService = authorizationService;
        _dataFilter = dataFilter;
    }
    
    public async Task InvokeAsync(HttpContext context, RequestDelegate next)
    {
        try
        {
            bool granted = await _authorizationService.IsGrantedAsync(SharedEntitiesPermissions.TestDataAccess.Default);
            if (!granted)
                _dataFilter.Enable();
            else
                _dataFilter.Disable();
        }
        catch (Exception ex)
        {
            _logger?.LogError(ex, "TestDataPermissionMiddleware: Error occurred.");
        }

        await next(context);
    }
}

Here is the data filter code:

protected bool IsTestDataFilterEnabled => DataFilter?.IsEnabled<ITestData>() ?? true;

protected override bool ShouldFilterEntity<TEntity>(IMutableEntityType entityType)
{
	if (typeof(ITestData).IsAssignableFrom(typeof(TEntity)))
	{
		return true;
	}

	return base.ShouldFilterEntity<TEntity>(entityType);
}

protected override Expression<Func<TEntity, bool>> CreateFilterExpression<TEntity>()
{
	var expression = base.CreateFilterExpression<TEntity>();

	if (typeof(ITestData).IsAssignableFrom(typeof(TEntity)))
	{
		Expression<Func<TEntity, bool>> isTestDataFilter = e => !IsTestDataFilterEnabled || !EF.Property<bool>(e, nameof(ITestData.IsTestData));
		expression = expression == null
			? isTestDataFilter
			: CombineExpressions(expression, isTestDataFilter);
	}

	return expression;
}

It works fine, but I was wondering if there is a better way of doing this that you could recommend?

Check the docs before asking a question: https://docs.abp.io/en/commercial/latest/ Check the samples, to see the basic tasks: https://docs.abp.io/en/commercial/latest/samples/index The exact solution to your question may have been answered before, please use the search on the homepage.

If you're creating a bug/problem report, please include followings:

  • ABP Framework version: v4.3.0
  • UI type: Blazor
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): yes
    • Exception message and stack trace:
  • Steps to reproduce the issue:"

We are unable to get dependency injection of ISettingManager in the constructor of a Blazor component we created to configure the settings for a module.

The module which uses the ISettingManager is as follows:

This has worked in a separate ABP Blazor solution, but in this case we have it in a separate module in another ABP solution and when visiting the respective page we get this error:

Check the docs before asking a question: https://docs.abp.io/en/commercial/latest/ Check the samples, to see the basic tasks: https://docs.abp.io/en/commercial/latest/samples/index The exact solution to your question may have been answered before, please use the search on the homepage.

If you're creating a bug/problem report, please include followings:

  • ABP Framework version: v5.3.0
  • UI type: Blazor
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): yes
  • Exception message and stack trace: 401
  • Steps to reproduce the issue:"

We created a Module using ABP Suite and added the Feature support as explained in the documentation, but when using the RequiresFeature attribute, it doesn't work when the feature is set to "True".

I see the feature when editing features of an edition:

And in the database:

But when adding the RequiresFeature attribute to either a class or a method:

Always throws an error stating that the feature is not enabled. This is the error I copied from Audit Logging:

These are the Settings strings consts:

  • ABP Framework version: v5.3.1
  • UI type: Blazor
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): yes
  • Exception message and stack trace: AbpException: Could not find the bundle file '/client-proxies/identity-proxy.js' for the bundle 'Volo.CmsKit.Admin.Web.Pages.CmsKit.Menus.MenuItems.IndexModel'!
  • Steps to reproduce the issue:"

We initially created override code for the Menus page for the CmsKit in an MVC-based project without issues.

But now we are trying to migrate our infrastructure to Blazor and tried to override the CmsKit page the same way with no success.

Here are the page files we used to override CmsKit (which worked in MVC and not in Blazor):

And the problematic area seems to be here in the index.cshtml file

And gives us the following error:

Is there a way to generate these proxy javascript files?

We've tried everything from "abp install-libs" and deleting the yarn.lock files before to recreating a new Blazor solution from scratch and even trying to run the javascript proxy generator as well as reinstalling the Volo.Indentity.Pro module into the solution.

Showing 1 to 4 of 4 entries
Made with ❤️ on ABP v9.0.0-preview Updated on September 19, 2024, 10:13