コード例 #1
0
 public AuthorizationCodeRepository(IEtimoIdDbContext dbContext)
 {
     _dbContext = dbContext;
 }
コード例 #2
0
 public UserRepository(IEtimoIdDbContext dbContext)
 {
     _dbContext = dbContext;
 }
コード例 #3
0
 public RefreshTokenRepository(IEtimoIdDbContext dbContext)
 {
     _dbContext = dbContext;
 }
コード例 #4
0
 public AccessTokenRepository(IEtimoIdDbContext dbContext)
 {
     _dbContext = dbContext;
 }
コード例 #5
0
 public RoleRepository(IEtimoIdDbContext dbContext)
 {
     _dbContext = dbContext;
 }
コード例 #6
0
        public static async Task SeedAsync(IEtimoIdDbContext context, IServiceProvider services)
        {
            context.Database.EnsureCreated();

            if (context.Users.Any())
            {
                return;
            }

            var passwordHasher = services.GetService(typeof(IPasswordHasher)) as IPasswordHasher;

            Console.WriteLine("Start seeding the database.");

            var adminUserId = new Guid("b7b229a3-c84d-495f-b4ac-da3a4fd0757f");
            var adminUser   = new User
            {
                UserId   = adminUserId,
                Username = "******",
                Password = passwordHasher.Hash("etimo")
            };

            context.Users.Add(adminUser);

            var adminClientId = new Guid("11111111-1111-1111-1111-111111111111");

            context.Applications.Add(new Application
            {
                ApplicationId = 1,
                Name          = "etimo-default",
                Description   = "Automatically generated.",
                HomepageUri   = "https://localhost:5010",
                RedirectUri   = "https://localhost:5010/oauth2/callback",
                ClientId      = adminClientId,
                ClientSecret  = passwordHasher.Hash("etimo"),
                UserId        = adminUserId,
                Type          = "confidential"
            });

            var adminRole = new Role
            {
                Name          = "admin",
                Description   = "Automatically generated.",
                ApplicationId = 1,
                Users         = new List <User> {
                    adminUser
                }
            };

            context.Roles.Add(adminRole);

            var scopes = GetBuiltInScopes("read")
                         .Concat(GetBuiltInScopes("write"))
                         .Concat(GetBuiltInScopes("admin"))
                         .ToList();

            context.Scopes.AddRange(scopes);

            adminRole.Scopes = scopes;

            await context.SaveChangesAsync();

            Console.WriteLine("Finished seeding the database.");
        }
コード例 #7
0
 public ApplicationRepository(IEtimoIdDbContext dbContext)
 {
     _dbContext = dbContext;
 }