Example #1
0
        public ClientStore(ClientConfigurationContext <TKey> context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            this.context = context;
        }
Example #2
0
 public HomeController(ClientConfigurationContext clientContext,
                       ScopeConfigurationContext scopeContext,
                       OperationalContext operationalContext,
                       UserManager <ApplicationUser> userManager,
                       RoleManager <IdentityRole> roleManager)
 {
     _clientContext      = clientContext;
     _scopeContext       = scopeContext;
     _operationalContext = operationalContext;
     _userManager        = userManager;
     _roleManager        = roleManager;
 }
        public void CanAddAndDeleteClientRedirectUri()
        {
            using (var db = new ClientConfigurationContext<int>(_options))
            {
                db.Clients.Add(new Client<int>
                {
                    ClientId = "test-client",
                    ClientName = "Test Client"
                });

                db.SaveChanges();
            }

            using (var db = new ClientConfigurationContext<int>(_options))
            {
                var client = db.Clients
                    .First();

                client.RedirectUris = new HashSet<ClientRedirectUri<int>>();
                client.RedirectUris.Add(new ClientRedirectUri<int>
                {
                    Uri = "https://redirect-uri-1"
                });

                db.SaveChanges();
            }

            using (var db = new ClientConfigurationContext<int>(_options))
            {
                var client = db.Clients
                    .Include(e => e.RedirectUris)
                    .First();
                var redirectUri = client.RedirectUris.First();

                client.RedirectUris.Remove(redirectUri);

                db.SaveChanges();
            }

            using (var db = new ClientConfigurationContext<int>(_options))
            {
                var client = db.Clients
                    .Include(e => e.RedirectUris)
                    .First();

                Assert.Equal(0, client.RedirectUris.Count());
            }
        }
        public void CanAddAndDeleteClientRedirectUri()
        {
            using (var db = new ClientConfigurationContext <int>(_options))
            {
                db.Clients.Add(new Client <int>
                {
                    ClientId   = "test-client",
                    ClientName = "Test Client"
                });

                db.SaveChanges();
            }

            using (var db = new ClientConfigurationContext <int>(_options))
            {
                var client = db.Clients
                             .First();

                client.RedirectUris = new HashSet <ClientRedirectUri <int> >();
                client.RedirectUris.Add(new ClientRedirectUri <int>
                {
                    Uri = "https://redirect-uri-1"
                });

                db.SaveChanges();
            }

            using (var db = new ClientConfigurationContext <int>(_options))
            {
                var client = db.Clients
                             .Include(e => e.RedirectUris)
                             .First();
                var redirectUri = client.RedirectUris.First();

                client.RedirectUris.Remove(redirectUri);

                db.SaveChanges();
            }

            using (var db = new ClientConfigurationContext <int>(_options))
            {
                var client = db.Clients
                             .Include(e => e.RedirectUris)
                             .First();

                Assert.Equal(0, client.RedirectUris.Count());
            }
        }
        public void CanAddAndDeleteClientScopes()
        {
            using (var db = new ClientConfigurationContext<int>(_options))
            {
                db.Clients.Add(new Client<int>
                {
                    ClientId = "test-client-scopes",
                    ClientName = "Test Client"
                });

                db.SaveChanges();
            }

            using (var db = new ClientConfigurationContext<int>(_options))
            {
                var client = db.Clients.First();

                client.AllowedScopes = new HashSet<ClientScope<int>>();
                client.AllowedScopes.Add(new ClientScope<int>
                {
                    Scope = "test"
                });

                db.SaveChanges();
            }

            using (var db = new ClientConfigurationContext<int>(_options))
            {
                var client = db.Clients
                    .Include(e => e.AllowedScopes)
                    .First();
                var scope = client.AllowedScopes.First();

                client.AllowedScopes.Remove(scope);

                db.SaveChanges();
            }

            using (var db = new ClientConfigurationContext<int>(_options))
            {
                var client = db.Clients
                    .Include(e => e.AllowedScopes)
                    .First();

                Assert.Equal(0, client.AllowedScopes.Count());
            }
        }
        public void CanAddAndDeleteClientScopes()
        {
            using (var db = new ClientConfigurationContext <int>(_options))
            {
                db.Clients.Add(new Client <int>
                {
                    ClientId   = "test-client-scopes",
                    ClientName = "Test Client"
                });

                db.SaveChanges();
            }

            using (var db = new ClientConfigurationContext <int>(_options))
            {
                var client = db.Clients.First();

                client.AllowedScopes = new HashSet <ClientScope <int> >();
                client.AllowedScopes.Add(new ClientScope <int>
                {
                    Scope = "test"
                });

                db.SaveChanges();
            }

            using (var db = new ClientConfigurationContext <int>(_options))
            {
                var client = db.Clients
                             .Include(e => e.AllowedScopes)
                             .First();
                var scope = client.AllowedScopes.First();

                client.AllowedScopes.Remove(scope);

                db.SaveChanges();
            }

            using (var db = new ClientConfigurationContext <int>(_options))
            {
                var client = db.Clients
                             .Include(e => e.AllowedScopes)
                             .First();

                Assert.Equal(0, client.AllowedScopes.Count());
            }
        }
Example #7
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IApplicationEnvironment env, ILoggerFactory loggerFactory,
            ScopeConfigurationContext scopeContext, ClientConfigurationContext clientContext)
        {
            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();

            app.UseIISPlatformHandler();

            app.UseStaticFiles();

            X509Certificate2 certificate = null;
            var certFile = env.ApplicationBasePath + $"{System.IO.Path.DirectorySeparatorChar}idsrv3test.pfx";
            certificate = new X509Certificate2(certFile, "idsrv3test", X509KeyStorageFlags.MachineKeySet);

            var factory = new IdentityServerServiceFactory();
            factory.ConfigureEntityFramework(app.ApplicationServices)
                .RegisterOperationalStores<OperationalContext>()
                .RegisterClientStore<Guid, ClientConfigurationContext>()
                .RegisterScopeStore<Guid, ScopeConfigurationContext>();
            factory.UseInMemoryUsers(Users.Get());

            var idsvrOptions = new IdentityServerOptions
            {
                SiteName = "Sample Site",
                Factory = factory,
                SigningCertificate = certificate,
                RequireSsl = false
            };

            app.UseIdentityServer(idsvrOptions);

            var scopeinit = new ScopeConfigurationInitializer(scopeContext);
            var clientinit = new ClientConfigurationInitializer(clientContext);

            scopeinit.InitializeData();
            clientinit.InitializeData();
        }
 public ClientConfigurationInitializer(ClientConfigurationContext context)
 {
     _context = context;
 }
 public ClientConfigurationCorsPolicyService(ClientConfigurationContext ctx)
 {
     _context = ctx;
 }
 public ClientConfigurationCorsPolicyService(ClientConfigurationContext <TKey> ctx)
 {
     context = ctx;
 }