Beispiel #1
0
        private static Authorize.Domain.Applications.Application SeedApplication(IAppDbContext context, IAuthPermissions authPermissions)
        {
            var app = new Authorize.Domain.Applications.Application("authorize.application")
            {
                Permissions = authPermissions.Permissions.ToList()
            };

            context.Applications.Add(app);
            return(app);
        }
Beispiel #2
0
 private static void SeedApplication(IAppDbContext context, IAuthPermissions authPermissions)
 {
     string[] apiAuthNames = { "authorize.application", "authorize.application1", "authorize.application2" };
     foreach (var apiAuthName in apiAuthNames)
     {
         var app = context.Applications.Where(a => a.Name == apiAuthName).FirstOrDefault();
         if (app == null)
         {
             app = new Authorize.Domain.Applications.Application(apiAuthName)
             {
                 Permissions = authPermissions.Permissions.ToList()
             };
             context.Applications.Add(app);
         }
     }
 }
Beispiel #3
0
        private static void SeedUserDefault(IAppDbContext context, Authorize.Domain.Applications.Application appAuth)
        {
            var defaultRole = new Role("admin", "admin");
            var defaultUser = new User("admin");

            defaultRole.Applications.Add(new ApplicationRole()
            {
                Application = appAuth,
                Permissions = appAuth.Permissions
            });
            defaultRole.Users.Add(new Domain.Relations.UserRole()
            {
                User = defaultUser,
                Role = defaultRole
            });


            context.Users.Add(defaultUser);
            context.Roles.Add(defaultRole);
        }
Beispiel #4
0
        private static void SeedApiRegister(IAppDbContext context, Authorize.Domain.Applications.Application appAuth)
        {
            var defaultRole = new Role("ApiRegister", "This role can register a new api");
            var defaultUser = new User("ApiRegister");

            defaultRole.Applications.Add(new ApplicationRole()
            {
                Application = appAuth,
                Permissions = new List <Permission>()
                {
                    Permission.For(AuthPermissions.ApplicationCreated)
                }
            });
            defaultRole.Users.Add(new Domain.Relations.UserRole()
            {
                User = defaultUser,
                Role = defaultRole
            });


            context.Users.Add(defaultUser);
            context.Roles.Add(defaultRole);
        }