fullstackhero / blazor-starter-kit

Clean Architecture Template for Blazor WebAssembly Built with MudBlazor Components.
MIT License
3.45k stars 726 forks source link

Feature Request: Nested permissions using classes? #332

Open dotnetshadow opened 2 years ago

dotnetshadow commented 2 years ago

Is your feature request related to a problem? Please describe. Just an idea (not sure what others think)

Currently if you want to group permissions under a parent group you would have come up with explicit names for the nested object such as the follows:

        [DisplayName("Products")]
        [Description("Products Permissions")]
        public static class Products
        {
            public const string View = "Permissions.Products.View";
            public const string Create = "Permissions.Products.Create";
            public const string Edit = "Permissions.Products.Edit";
            public const string Delete = "Permissions.Products.Delete";
            public const string Export = "Permissions.Products.Export";
            public const string Search = "Permissions.Products.Search";

            // Can't use Create because it's already been taken so need to use another name
            public const string CreateReview = "Permissions.Products.ProductReviews.Create";
        }

Describe the solution you'd like Being able to have permissions nested using a class allows for consistent naming for your permissions The other benefit is that you could potentially have a tree like structure for displaying permissions

        [DisplayName("Products")]
        [Description("Products Permissions")]
        public static class Products
        {
            public const string View = "Permissions.Products.View";
            public const string Create = "Permissions.Products.Create";
            public const string Edit = "Permissions.Products.Edit";
            public const string Delete = "Permissions.Products.Delete";
            public const string Export = "Permissions.Products.Export";
            public const string Search = "Permissions.Products.Search";

            // Here we can keep using the same name because the review is nested 
            [DisplayName("ProductsReview")]
            [Description("Products Review Permissions")]
            public static class ProductsReview
            {
                public const string Create = "Permissions.Products.ProductReviews.Create";
            }
        }

What are people's thoughts on this?