Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Custom authorization policies ver 8.1 Angular .Net Core #8435


User avatar
0
admin@SYNTAQ created

Hi,

I have added custom authorization policies to the startup.cs. They work for the MVC controllers but not the API controllers. Where SHould I configure these so that they work for both?

Ver 8.1 Angular .Net Core

        services.AddAuthorization(options =>
        {
            options.AddPolicy("ViewById", policy => policy.Requirements.Add(new SyntaqAuthorizationRequirement("View", "Id")));
            options.AddPolicy("EditById", policy => policy.Requirements.Add(new SyntaqAuthorizationRequirement("Edit", "Id")));
            options.AddPolicy("DeleteById", policy => policy.Requirements.Add(new SyntaqAuthorizationRequirement("Delete", "Id")));

            options.AddPolicy("ViewByOriginalId", policy => policy.Requirements.Add(new SyntaqAuthorizationRequirement("View", "IdOriginal")));
            options.AddPolicy("EditByOriginalId", policy => policy.Requirements.Add(new SyntaqAuthorizationRequirement("Edit", "IdOriginal")));
            options.AddPolicy("DeleteByOriginalId", policy => policy.Requirements.Add(new SyntaqAuthorizationRequirement("Delete", "IdOriginal")));

        });

Thanks

Cheers


4 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team

    They work for the MVC controllers but not the API controllers.

    Do you mean the dynamic api of the application service layer?

  • User Avatar
    0
    admin@SYNTAQ created

    Yes.

  • User Avatar
    0
    maliming created
    Support Team

    hi admin@syntaq

    The abp framework does not currently support policy authorization. It has its own authorization design.

    https://aspnetboilerplate.com/Pages/Documents/Authorization

  • User Avatar
    0
    ismcagdas created
    Support Team

    This issue is closed because of no recent activity. Please create a new issue if you are still having this problem.