private static void InitPolicy(CasbinDbContext <Guid> context)
        {
            context.CasbinRule.Add(new CasbinRule <Guid>
            {
                PType = "p",
                V0    = "r.sub.Age > 18 && r.sub.Age < 60",
                V1    = "/data1",
                V2    = "read",
                V3    = "formlang"
            });

            context.CasbinRule.Add(new CasbinRule <Guid>
            {
                PType = "p",
                V0    = "bool.Parse(r.sub.IsTenantMember) == true",
                V1    = "/data2",
                V2    = "write"
            });

            context.SaveChanges();
        }
예제 #2
0
 private static void InitPolicy(CasbinDbContext <Guid> context)
 {
     context.CasbinRule.Add(new CasbinRule <Guid>
     {
         PType = "p",
         V0    = "alice",
         V1    = "data1",
         V2    = "read",
         V3    = "formlang1"
     });
     context.CasbinRule.Add(new CasbinRule <Guid>
     {
         PType = "p",
         V0    = "bob",
         V1    = "data1",
         V2    = "write",
         V3    = "formlang2"
     });
     context.CasbinRule.Add(new CasbinRule <Guid>
     {
         PType = "p",
         V0    = "data2_admin",
         V1    = "data2",
         V2    = "read",
     });
     context.CasbinRule.Add(new CasbinRule <Guid>
     {
         PType = "p",
         V0    = "data2_admin",
         V1    = "data2",
         V2    = "write",
     });
     context.CasbinRule.Add(new CasbinRule <Guid>
     {
         PType = "g",
         V0    = "alice",
         V1    = "data2_admin",
     });
     context.SaveChanges();
 }
 private void Dispose(CasbinDbContext <Guid> context)
 {
     context.RemoveRange(context.CasbinRule);
     context.SaveChanges();
 }