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

Define Permissions in Table AbpPermissions #267


User avatar
0
behiunforgiven created

Is it Possible to define permissions in AbpPermission in database?

I define a permission

public class EPEDCAuthorizationProvider : AuthorizationProvider
    {
        public override void SetPermissions(IPermissionDefinitionContext context)
        {
            var administration = context.CreatePermission("Administration", new FixedLocalizableString("Site Admin"), true);
        }

    }

but it is not stored anywhere ! and All Users are granted for it by default!

How can I define Permissions for specific Roles and Users?


6 Answer(s)
  • User Avatar
    0
    behiunforgiven created

    Is it Possible to have dynamic Permissions?

  • User Avatar
    0
    hikalkan created
    Support Team

    Permissions are not defined dynamically (and there is no need to that). Instead, users are granted int the database. Have you seen <a class="postlink" href="http://www.aspnetboilerplate.com/Pages/Documents/Zero/Permission-Management">http://www.aspnetboilerplate.com/Pages/ ... Management</a> document? All user/role permissions are stored in AbpPermissions table. And you can use UserManager and RoleManager to grant permissions (to modify the table).

  • User Avatar
    0
    behiunforgiven created

    thank you for reply I read the document but I can't understand one thing:

    I want to have a dynamic Navigation system with dynamic accessing rules. How can I implement this by Abp+Zero ?

  • User Avatar
    0
    hikalkan created
    Support Team

    Hi,

    In the navigation doc (<a class="postlink" href="http://www.aspnetboilerplate.com/Pages/Documents/Navigation">http://www.aspnetboilerplate.com/Pages/ ... Navigation</a>) there is a property named "requiredPermissionName". If you fill it, then user should have this permission to see that menu. This works if you use IUserNavigationManager to get the menu. You can see startup templates for examples.

  • User Avatar
    0
    kmg created

    It seems a cannot find any use of IUserNavigationManager in the startup templates, can you give me a lead? Actually I'm trying to implement a pesmission's based menu and I'm confused on the part where I need to process the requiredPermissionName to hide a menu item when the user is not granted that permission. Where could I do this? Is there an example implementation?

  • User Avatar
    0
    hikalkan created
    Support Team

    See usage of IUserNavigationManager: <a class="postlink" href="https://github.com/aspnetboilerplate/module-zero-template/blob/master/src/AbpCompanyName.AbpProjectName.WebMpa/Controllers/LayoutController.cs#L11">https://github.com/aspnetboilerplate/mo ... ler.cs#L11</a>

    If your project is SPA, then you can get the menu from javascript (<a class="postlink" href="https://github.com/aspnetboilerplate/module-zero-template/blob/master/src/AbpCompanyName.AbpProjectName.WebSpaAngular/App/Main/views/layout/header.js">https://github.com/aspnetboilerplate/mo ... /header.js</a>) which is already filtered by permissions.

    There is a sample in the documentation (<a class="postlink" href="http://www.aspnetboilerplate.com/Pages/Documents/Navigation">http://www.aspnetboilerplate.com/Pages/ ... Navigation</a>). No such a working example project yet.

    You don't process requiredPermissionName. IUserNavigationManager already process it and filters menu by permission for given user.