Base solution for your next web application
Open Closed

Authorization in asp.net Boilerplate #2431


User avatar
0
oprakash created

Hi There, I was trying to implement authorization in asp.net boiler plate. I followed below steps Database

  1. I added two new roles(Accounts, Sales) in "AbpRoles" Table.
  2. I added a user with Accounts roles in "AbpUserRoles".
  3. Also added some Permission in "AbpPermissions" table. Like -

Id Name IsGranted CreationTime CreatorUserId RoleId UserId Discriminator TenantId 119 Pages.Roles 1 59:59.9 2 4 Null Pages.Roles 1 120 Pages.Roles.Dashboard 1 59:59.9 2 4 Null Pages.Roles.Dashboard 1 121 Pages.Roles.Dashboard.ToDoList 1 59:59.9 2 4 Null Pages.Roles.Dashboard.ToDoList 1 122 Pages.Roles.Dashboard.Notifications 1 59:59.9 2 4 Null Pages.Roles.Dashboard.Notifications 1

Front end Code. 4. Added constant variable under "Code.Authorization.PermissionNames" as Below public const string Pages_Roles = "Pages.Roles"; public const string Pages_Roles_Dashboard = "Pages.Roles.Dashboard"; public const string Pages_Roles_Dashboard_ToDoList = "Pages.Roles.Dashboard.ToDoList"; public const string Pages_Roles_Dashboard_Notifications = "Pages.Roles.Dashboard.Notifications";

  1. Then I set permission in "Core.Authorization.ProjectNameAuthorizationProvider as below public override void SetPermissions(IPermissionDefinitionContext context) { //Common permissions var pages = context.GetPermissionOrNull(PermissionNames.Pages); if (pages == null) { pages = context.CreatePermission(PermissionNames.Pages, L("Pages")); } var Pages_Roles = users.CreateChildPermission(PermissionNames.Pages_Roles, L("Pages.Roles")); var Pages_Roles_Dashboard = Pages_Roles.CreateChildPermission(PermissionNames.Pages_Roles_Dashboard, L("Pages.Roles.Dashboard")); var Pages_Roles_Dashboard_ToDoList = Pages_Roles_Dashboard.CreateChildPermission(PermissionNames.Pages_Roles_Dashboard_ToDoList, L("Pages.Roles.Dashboard.ToDoList")); var Pages_Roles_Dashboard_Notifications = Pages_Roles_Dashboard.CreateChildPermission(PermissionNames.Pages_Roles_Dashboard_Notifications, L("Pages.Roles.Dashboard.Notifications"));

Result - Now when i log in by the user assigned this id (4-Account) the permissions are not granted to him.

Please Help me.

Thanks and Regards Om Prakash


1 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Can you send your project and your database to <a href="mailto:[email protected]">[email protected]</a> if it is possible ? It will be easier to say something on this problem like that.

    Thanks.