Search code examples
c#.net-coreorchard-modulesorchardcore

How can an Orchard Core module add new roles and permissions?


IPermissionProvider doesn't seem to be able to add new roles (maybe I missed something), and it also seems to only be called during the module's initial installation, which seems batty.

How can my module add new roles and permissions?


Solution

  • IPermissionProvider implements two methods which you can implement.

    • Task<IEnumerable<Permission>> GetPermissionsAsync() which allows your module to return a Permission which your module provides, and

    • IEnumerable<PermissionStereotype> GetDefaultStereotypes() which allows you to define what of the permissions you have created will have by default, and/or add a PermissionStereotype to define a new role.