Beispiel #1
0
        public static void ConfigureClients(IEnumerable <Client> clients, DocumentDbServiceOptions options)
        {
            ClientRepository clientRepository = new ClientRepository(options.CollectionNameResolver, options.ToConnectionSettings());
            var allClients = clientRepository.GetAllClients().Result;

            if (!allClients.Any())
            {
                foreach (var c in clients)
                {
                    clientRepository.AddClient(c.ToDocument()).Wait();
                }
            }
        }
Beispiel #2
0
        public static void ConfigureScopes(IEnumerable <Scope> scopes, DocumentDbServiceOptions options)
        {
            ScopeRepository scopeRepository = new ScopeRepository(options.CollectionNameResolver, options.ToConnectionSettings());
            var             allScopes       = scopeRepository.GetAllScopes().Result;

            if (!allScopes.Any())
            {
                foreach (var s in scopes)
                {
                    scopeRepository.AddScope(s.ToDocument()).Wait();
                }
            }
        }
Beispiel #3
0
        public static IdentityServerServiceFactory Configure(DocumentDbServiceOptions documentDbServiceOptions)
        {
            var efConfig = documentDbServiceOptions;

            var cleanup = new TokenCleanup(efConfig, 10);

            cleanup.Start();

            // these two calls just pre-populate the test DB from the in-memory config
            ConfigureClients(Clients.Get(), efConfig);
            ConfigureScopes(Scopes.Get(), efConfig);

            var factory = new IdentityServerServiceFactory();

            factory.RegisterConfigurationServices(efConfig);
            factory.RegisterOperationalServices(efConfig);

            factory.UseInMemoryUsers(Users.Get());

            return(factory);
        }