有关CRUD应用程序的.NET策略授权现实世界问题

时间:2019-04-04 13:47:44

标签: .net-core policy

我有一个CRUD系统。
我希望分类中的每个实体都具有读/写/删除权限。

假设我们要为每个实体类创建一个策略。

将我的保单称为以下内容有意义吗?

services.AddAuthorization(options=>
{
  options.AddPolicy("EntityEditor", policy =>
  {
    policy.AddAuthenticationSchemes("Cookie, Bearer");
    policy.RequireAuthenticatedUser();

    policy.RequireClaim("ArticleEntity", "read");
    policy.RequireClaim("ArticleEntity", "write");
    policy.RequireClaim("ArticleEntity", "delete");

    policy.RequireClaim("PageEntity", "read");
    policy.RequireClaim("PageEntity", "write");
    policy.RequireClaim("PageEntity", "delete");

    policy.RequireClaim("MenuEntity", "read");
    policy.RequireClaim("MenuEntity", "write");
    policy.RequireClaim("MenuEntity", "delete");


  });
}

您如何在CRUD环境中对策略建模?

除CRUD之外,还有更多其他操作。例如“ ApproveDocuments”或“ MergePages”

谢谢

0 个答案:

没有答案