Beispiel #1
0
        protected void Init()
        {
            clients = TestClients.Get();
            var clientStore = new InMemoryClientStore(clients);
            var scopeStore  = new InMemoryScopeStore(TestScopes.Get());

            var factory = new IdentityServerServiceFactory
            {
                ScopeStore  = Registration.RegisterFactory <IScopeStore>(() => scopeStore),
                ClientStore = Registration.RegisterFactory <IClientStore>(() => clientStore)
            };

            server = TestServer.Create(app =>
            {
                appBuilder = app;

                mockUserService          = new Mock <InMemoryUserService>(TestUsers.Get());
                mockUserService.CallBase = true;
                factory.UserService      = Registration.RegisterFactory <IUserService>(() => mockUserService.Object);

                options         = TestIdentityServerOptions.Create();
                options.Factory = factory;
                options.AuthenticationOptions.IdentityProviders = OverrideIdentityProviderConfiguration ?? ConfigureAdditionalIdentityProviders;

                protector = options.DataProtector;

                app.UseIdentityServer(options);

                ticketFormatter = new TicketDataFormat(
                    new DataProtectorAdapter(protector, options.AuthenticationOptions.CookieOptions.Prefix + Constants.PartialSignInAuthenticationType));
            });

            client = server.HttpClient;
        }
        public static IdentityServerServiceFactory Create()
        {
            var scopes  = new InMemoryScopeStore(TestScopes.Get());
            var clients = new InMemoryClientStore(TestClients.Get());

            var fact = new IdentityServerServiceFactory
            {
                ScopeStore  = Registration.RegisterFactory <IScopeStore>((resolver) => scopes),
                ClientStore = Registration.RegisterFactory <IClientStore>((resolver) => clients)
            };

            return(fact);
        }