public static AppBuilder Create()
        {
            AppBuilder app = new AppBuilder();

            app.UseIdentityServer(new IdentityServerOptions
            {
                Factory = new IdentityServerServiceFactory()
                            .UseInMemoryClients(Clients.Get())
                            .UseInMemoryScopes(Scopes.Get())
                            .UseInMemoryUsers(new List<InMemoryUser>())
            });

            return app;
        }
Beispiel #2
0
        public static AppBuilder Create()
        {
            AppBuilder app = new AppBuilder();

            var factory = new IdentityServerServiceFactory()
                            .UseInMemoryClients(Clients.Get())
                            .UseInMemoryScopes(Scopes.Get())
                            .UseInMemoryUsers(Users.Get());

            factory.CustomGrantValidators.Add(new Registration<ICustomGrantValidator, CustomGrantValidator>());
            factory.CustomGrantValidators.Add(new Registration<ICustomGrantValidator, CustomGrantValidator2>());

            app.UseIdentityServer(new IdentityServerOptions
            {
                EventsOptions = new EventsOptions
                {
                    RaiseErrorEvents = true,
                    RaiseFailureEvents = true,
                    RaiseInformationEvents = true,
                    RaiseSuccessEvents = true
                },

                IssuerUri = "https://idsrv3",
                SigningCertificate = TestCert.Load(),

                Factory = factory
            });

            return app;
        }
        public static void UseIdentityServer(this IApplicationBuilder app, IdentityServerOptions options)
        {
            app.UseOwin(addToPipeline =>
            {
                addToPipeline(next =>
                {
                    var builder = new AppBuilder();

                    var provider = app.ApplicationServices.GetService<IDataProtectionProvider>();

                    builder.Properties["security.DataProtectionProvider"] = new DataProtectionProviderDelegate(purposes =>
                    {
                        var dataProtection = provider.CreateProtector(String.Join(",", purposes));
                        return new DataProtectionTuple(dataProtection.Protect, dataProtection.Unprotect);
                    });

                    builder.UseIdentityServer(options);

                    var appFunc = builder.Build(typeof(Func<IDictionary<string, object>, Task>)) as Func<IDictionary<string, object>, Task>;
                    return appFunc;
                });
            });
        }