Allen
Allen

Reputation: 82

Configuring ASP.NET Boilerplate Authorization

I'm studying the use of ASP.NET Boilerplate and I've noticed that the ASP.NET Boilerplate authorization mechanism uses Attributes like this:

[AbpAuthorize("CanDeletePerson")]
public async Task DeletePerson(EntityDto input)
{
   await _personRepository.DeleteAsync(input.Id);
}

Let's say for example a person named 'Clay' who has the CanDeletePerson permission set. Then subsequently this permission is removed. How do I add back the permission?

Is there some administration system / UI set-up in the free Abp templates that allows for the configuration and maintenance of User Permissions?

Upvotes: 0

Views: 3303

Answers (2)

Nick Hoàng
Nick Hoàng

Reputation: 437

First you have to add permission to DB, by code you can follow these steps:

  • In File .Core\Authorization\AspNetMvc5StartUpTemplateAuthorizationProvider.cs, add a line:

    context.CreatePermission("CanDeletePerson", L("CanDeletePerson"));

  • Add localization text in .Core\Localization\Source

  • Open web UI then goto Roles menu -> edit a role and where you will see your new permission and add it to a role.

Hope it help. Cheers

Upvotes: 1

jazb
jazb

Reputation: 5791

As far as I am aware only the premium template has a pre-built UI for you to use from the outset.

With the free version we have to build Permission admin pages ourselves.

There is a class called 'HostRoleAndUserCreator'. Find that class and you will see how RolePermissionSetting are persisted/initialised.

You will also see from your MyAppAuthorizationProvider how permissions themselves are seeded.

Upvotes: 0

Related Questions