Activities of "ageiter"

In version 8.1, the following structure was generated by the Suite for the EntityFramework (for a Blazor Server project):

And now in 8.2.0-rc.3 it looks like this (for a Blazor Web App project):

Basically, I find it much clearer now. But I would like to add additions to the model, which I previously did in the “...DbContextBase” class. If I now do this in the “...DbContext” class, it will be deleted again the next time I generate it. How could I do this so that it remains there regardless of generation?

I would like to add the following for the decimal properties:

protected override void OnModelCreating(ModelBuilder builder)
{
    base.OnModelCreating(builder);
    
    builder.Entity<Disability>(b =>
    {
        b.Property(x => x.DegreeOfDisability).HasPrecision(18, 4);
    });
}

Using ABP 8.2.0-rc.3

I have generated the following entities with Blazor UI:

  • "Incident" as master
  • "Disability" as child of "Incident"

In the child entity there is a decimal property with min & max values.

In the generated Razor page these are expected in the constant class of the master entity.

I think the error can be found in this template:

Possibility for inheritance of entities.

https://learn.microsoft.com/en-us/ef/core/modeling/inheritance

https://community.abp.io/posts/inheritance-strategies-in-entity-framework-core-7-hg82tp4h?utm_source=twitter&utm_medium=announcement

I understand the problem... In my case, it's mainly about the modal control, which doesn't work. If at least that would work, I would be happy. I could live with the rest of the error messages. But without the modal control, of course the whole admin area doesn't work.

I think the Blazorise controls are the main problem. Can you address the need there as well?

There is already an issue there: https://github.com/Megabit/Blazorise/issues/5460

But which part of the code contains inline CSS? The one from ABP? The one from Blazorise? Because I have fixed everything in my code.

Have you been able to reproduce it with the ABP Suite template? What alternatives do I have if the customer insists on a secure CSP?

Sure... but it's the same as in the code above ;-)

  1. Generate Blazor Server project with ABP Suite template (I have version 8.0.4)
  2. Add the following method in the BlazorModule:
private void ConfigureSecurityHeaders()
{
    Configure<AbpSecurityHeadersOptions>(options =>
    {
        options.UseContentSecurityPolicyHeader = true;
        options.ContentSecurityPolicyValue = "base-uri 'self'; default-src 'none'; img-src 'self' data:; script-src 'self'; style-src 'self'; font-src 'self'; connect-src 'self'; frame-ancestors 'none'";
    });
}
  1. Call it under ConfigureServices:

  2. If necessary, the order in OnApplicationInitialization must be changed so that app.UseAbpSecurityHeaders() is called after app.UseRouting() (see https://github.com/abpframework/abp/issues/19653)

  3. Testing... Open the console in the browser and open a modal dialog, for example.

  • ABP Framework version: v8.0.4
  • UI Type: Blazor Server
  • Database System: EF Core (SQL Server)
  • Tiered (for MVC) or Auth Server Separated (for Angular): no

We have to apply certain CSPs (Content Security Headers) for our customer. I have problems with the following policy:

style-src 'self'

For example, the column widths are no longer set correctly in the DataGrid and, more importantly, the modal components are no longer displayed.

The policy looks like this:

options.UseContentSecurityPolicyHeader = true; 
options.ContentSecurityPolicyValue = "base-uri 'self'; default-src 'none'; img-src 'self' data:; script-src 'self'; style-src 'self'; font-src 'self'; connect-src 'self'; frame-ancestors 'none'";

With style-src 'self' 'unsafe-inline' it would work... but is not allowed.

Need a solution as soon as possible... Thank you!

Thanks for the hint and the link.

I have now implemented this as follows:

AppService method:

[AuthorizeWithOrCondition(MyProjectPermissions.TargetSystems.UserWrite, MyProjectPermissions.TargetSystems.AgentWrite)]
public virtual async Task CreateAsync(TargetSystemCreateDto input)
{
   ...
}

AuthorizeAttribute:

    public class AuthorizeWithOrConditionAttribute : AuthorizeAttribute,  IAuthorizationRequirementData
    {
        public string[] PermissionNames { get; }

        public AuthorizeWithOrConditionAttribute(params string[] permissionNames)
        {
            PermissionNames = permissionNames;
        }

        public IEnumerable<IAuthorizationRequirement> GetRequirements()
        {
            yield return new PermissionsRequirement(PermissionNames, requiresAll: false);
        }
    }
  • ABP Framework version: v8.0.4
  • UI Type: Blazor Server
  • Database System: EF Core (SQL Server)
  • Tiered (for MVC) or Auth Server Separated (for Angular): no

Our customer gives us a certain authorization structure that is not quite standard. Different permissions should grant access to a service method (not just one permission as usual).

Example:

  • Role "User" has the permission "UserWrite"
  • Role "Agent" has the permission "AgentWrite"

If I use the AuthorizeAttribute twice, the permissions are AND combined. However, I need them with an OR combination.

I tried it with my own AuthorizeAttribute, but failed. It also didn't work in combination with my own AuthorizationHandler, as I couldn't access the AuthorizationService there (-> circular dependency).

The only variant that worked was to implement this directly in the service method:

public virtual async Task<TargetSystemDto> CreateAsync(TargetSystemCreateDto input)
{
    var authUserWrite = await AuthorizationService.AuthorizeAsync(_currentPrincipalAccessor.Principal, null, MyProjectPermissions.TargetSystems.UserWrite);
    var authAgentWrite = await AuthorizationService.AuthorizeAsync(_currentPrincipalAccessor.Principal, null, MyProjectPermissions.TargetSystems.AgentWrite);
    if (!authUserWrite.Succeeded && !authAgentWrite.Succeeded)
    {
        throw new AbpAuthorizationException();
    }

    var targetSystem = await _targetSystemManager.CreateAsync(...);
    return ObjectMapper.Map<TargetSystem, TargetSystemDto>(targetSystem);
}

But I would prefer to have this in an attribute. So that I could call it up as follows, for example: [AuthorizeWithOrCondition(MyProjectPermissions.TargetSystems.AgentWrite, MyProjectPermissions.TargetSystems.UserWrite)]

How could this be realized? There must be a way...

Thanks, Adrian

Showing 131 to 140 of 312 entries
Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.1.0-preview. Updated on October 30, 2025, 06:33