Ejemplo n.º 1
0
        public void Configuration(IAppBuilder app)
        {
            LogProvider.SetCurrentLogProvider(new DiagnosticsTraceLogProvider());
            Log.Logger = new LoggerConfiguration()
               .MinimumLevel.Debug()
               .WriteTo.Trace()
               .CreateLogger();

            app.Map("/admin", adminApp =>
            {
                var factory = new IdentityManagerServiceFactory();
                factory.ConfigureSimpleIdentityManagerService("AspId");

                adminApp.UseIdentityManager(new IdentityManagerOptions()
                {
                    Factory = factory
                });
            });

            app.Map("/core", core =>
            {
                var idSvrFactory = Factory.Configure();
                idSvrFactory.ConfigureUserService("AspId");

                var options = new IdentityServerOptions
                {
                    SiteName = "IdentityServer3 - AspNetIdentity 2FA",
                    SigningCertificate = Certificate.Get(),
                    Factory = idSvrFactory,
                };

                core.UseIdentityServer(options);
            });
        }
Ejemplo n.º 2
0
        public void Configuration(IAppBuilder app)
        {
            LogProvider.SetCurrentLogProvider(new DiagnosticsTraceLogProvider());
            Log.Logger = new LoggerConfiguration()
               .MinimumLevel.Debug()
               .WriteTo.Trace()
               .CreateLogger();

            app.UseAesDataProtectorProvider();
            app.Map("/admin", adminApp =>
                {
                    var factory = new IdentityManagerServiceFactory();
                   
                    factory.ConfigureSimpleIdentityManagerService("AspId");
                    //factory.ConfigureCustomIdentityManagerServiceWithIntKeys("AspId_CustomPK");

                    var adminOptions = new IdentityManagerOptions(){
                        Factory = factory
                    };
                    adminOptions.SecurityConfiguration.RequireSsl = false;
                    adminApp.UseIdentityManager(adminOptions);
                });

            var idSvrFactory = Factory.Configure();
            idSvrFactory.ConfigureUserService("AspId");

            var viewOptions = new ViewServiceOptions
            {
                TemplatePath = this.basePath.TrimEnd(new char[] { '/' })
            };
            idSvrFactory.ViewService = new IdentityServer3.Core.Configuration.Registration<IViewService>(new ViewService(viewOptions));

            var options = new IdentityServerOptions
            {
                SiteName = "IdentityServer3 - ViewSerive-AspNetIdentity",
                SigningCertificate = Certificate.Get(),
                Factory = idSvrFactory,
                RequireSsl = false,
                AuthenticationOptions = new AuthenticationOptions
                {
                    IdentityProviders = ConfigureAdditionalIdentityProviders,
                }
            };

            app.Map("/core", core =>
            {
                core.UseIdentityServer(options);
            });

            app.UseStaticFiles(new StaticFileOptions
            {
                RequestPath = new PathString("/Content"),
                FileSystem = new PhysicalFileSystem(Path.Combine(this.basePath, "Content")) 
            });

            var config = new HttpConfiguration();
          //  config.MapHttpAttributeRoutes();
            config.Routes.MapHttpRoute("API", "api/{controller}/{action}", new { controller = "Home", action = "Get" });
            app.UseWebApi(config);
        }
        public void Configuration(IAppBuilder app)
        {
            app.Map("/admin", adminApp =>
            {
                var factory = new IdentityManagerServiceFactory();
                factory.ConfigureSimpleIdentityManagerService("AspId");

                adminApp.UseIdentityManager(new IdentityManagerOptions()
                {
                    Factory = factory
                });
            });
            app.Map("/core", core =>
            {
                var idSvrFactory = Factory.Configure();
                idSvrFactory.ConfigureUserService("AspId");

                var options = new IdentityServerOptions
                {
                    SiteName = "Thinktecture IdentityServer3 - AspNetIdentity 2FA",
                    SigningCertificate = Certificate.Get(),
                    Factory = idSvrFactory,
                };

                core.UseIdentityServer(options);
            });
        }
        public static void UseIdentityServer(this IApplicationBuilder app, IdentityServerOptions options)
        {
            app.UseOwin(pipeline =>
            {
                pipeline(next =>
                {
                    var builder  = new Microsoft.Owin.Builder.AppBuilder();
                    var provider = app.ApplicationServices.GetService <DataProtection.IDataProtectionProvider>();

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

                    builder.Map("/admin", adminApp =>
                    {
                        var factory = new IdentityManagerServiceFactory();
                        factory.ConfigureSimpleIdentityManagerService("AspId");
                        //factory.ConfigureCustomIdentityManagerServiceWithIntKeys("AspId_CustomPK");

                        adminApp.UseIdentityManager(new IdentityManagerOptions()
                        {
                            Factory = factory
                        });
                    });

                    builder.UseIdentityServer(options);
                    builder.UseAesDataProtectorProvider();
                    var appFunc = builder.Build(typeof(Func <IDictionary <string, object>, Task>)) as Func <IDictionary <string, object>, Task>;
                    return(appFunc);
                });
            });
        }
Ejemplo n.º 5
0
        public void Configuration(IAppBuilder app)
        {
            app.Map("/idmgr", adminApp =>
            {
                var factory = new IdentityManagerServiceFactory();
                factory.ConfigureSimpleIdentityManagerService("DefaultConnection");

                adminApp.UseIdentityManager(new IdentityManagerOptions()
                {
                    Factory = factory
                });
            });

            app.Map("/idsvr", core =>
            {
                var idSvrFactory = Factory.Configure();
                idSvrFactory.ConfigureUserService("DefaultConnection");

                var options = new IdentityServerOptions
                {
                    SiteName = "IdentityServer3 - UserService-AspNetIdentity",
                    SigningCertificate = Certificate.Get(),
                    Factory = idSvrFactory,
                    AuthenticationOptions = new AuthenticationOptions
                    {
                        IdentityProviders = ConfigureAdditionalIdentityProviders,
                    }
                };

                core.UseIdentityServer(options);
            });
        }
        public void Configuration(IAppBuilder app)
        {
            app.Map("/admin", adminApp =>
            {
                var factory = new IdentityManagerServiceFactory();
                factory.ConfigureSimpleIdentityManagerService("AspId");

                adminApp.UseIdentityManager(new IdentityManagerOptions()
                {
                    Factory = factory
                });
            });
            app.Map("/core", core =>
            {
                var idSvrFactory = Factory.Configure();
                idSvrFactory.ConfigureUserService("AspId");

                var options = new IdentityServerOptions
                {
                    SiteName           = "Thinktecture IdentityServer3 - AspNetIdentity 2FA",
                    SigningCertificate = Certificate.Get(),
                    Factory            = idSvrFactory,
                };

                core.UseIdentityServer(options);
            });
        }
Ejemplo n.º 7
0
        public static void Configure(IAppBuilder app)
        {
            Log.Logger = new LoggerConfiguration()
                         .MinimumLevel.Debug()
                         .WriteTo.Trace()
                         .CreateLogger();
            app.UseAesDataProtectorProvider();

            BasePath = AppDomain.CurrentDomain.BaseDirectory;
            var certFile = Path.Combine(BasePath, "idsrv3test.pfx");

            Console.WriteLine(certFile);
            var options = ConfigureIdentityServer(certFile);

            //  var cpath = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),"..", "..", "..", "src", "Janitor", "Content"));
            //  Console.WriteLine(cpath);
            //  app.UseStaticFiles (new StaticFileOptions {
            //		RequestPath = new PathString("/Content"),
            //		FileSystem = new PhysicalFileSystem(cpath)
            //	});

            app.Map("/admin", adminApp =>
            {
                var factory = new IdentityManagerServiceFactory();
                factory.ConfigureSimpleIdentityManagerService("AspId");
                var adminOptions = new IdentityManagerOptions
                {
                    Factory = factory,
                };
                adminOptions.SecurityConfiguration.RequireSsl = false;
                adminApp.UseIdentityManager(adminOptions);
            });

            app.UseIdentityServer(options);
        }
        public void Configuration(IAppBuilder app)
        {
            app.Map("/admin", adminApp =>
            {
                var factory = new IdentityManagerServiceFactory();
                factory.ConfigureSimpleIdentityManagerService("AspId");
                //factory.ConfigureCustomIdentityManagerServiceWithIntKeys("AspId_CustomPK");

                adminApp.UseIdentityManager(new IdentityManagerOptions()
                {
                    Factory = factory
                });
            });

            var idSvrFactory = Factory.Configure();
            idSvrFactory.ConfigureUserService("AspId");
            //idSvrFactory.ConfigureCustomUserService("AspId_CustomPK");

            var options = new IdentityServerOptions
            {
                SiteName = "Thinktecture IdentityServer3 - UserService-AspNetIdentity",
                SigningCertificate = Certificate.Get(),
                Factory = idSvrFactory,
                CorsPolicy = CorsPolicy.AllowAll,
                AuthenticationOptions = new AuthenticationOptions
                {
                    IdentityProviders = ConfigureAdditionalIdentityProviders,
                }
            };

            app.UseIdentityServer(options);
        }
Ejemplo n.º 9
0
        public void Configuration(IAppBuilder app)
        {
            app.Map("/idmgr", adminApp =>
            {
                var factory = new IdentityManagerServiceFactory();
                factory.ConfigureSimpleIdentityManagerService("DefaultConnection");

                adminApp.UseIdentityManager(new IdentityManagerOptions()
                {
                    Factory = factory
                });
            });

            app.Map("/idsvr", core =>
            {
                var idSvrFactory = Factory.Configure();
                idSvrFactory.ConfigureUserService("DefaultConnection");

                var options = new IdentityServerOptions
                {
                    SiteName              = "IdentityServer3 - UserService-AspNetIdentity",
                    SigningCertificate    = Certificate.Get(),
                    Factory               = idSvrFactory,
                    AuthenticationOptions = new AuthenticationOptions
                    {
                        IdentityProviders = ConfigureAdditionalIdentityProviders,
                    }
                };

                core.UseIdentityServer(options);
            });
        }
Ejemplo n.º 10
0
        public void Configuration(IAppBuilder app)
        {
            app.Map("/admin", adminApp =>
            {
                var factory = new IdentityManagerServiceFactory();
                factory.ConfigureSimpleIdentityManagerService("AspId");
                //factory.ConfigureCustomIdentityManagerServiceWithIntKeys("AspId_CustomPK");

                adminApp.UseIdentityManager(new IdentityManagerOptions()
                {
                    Factory = factory
                });
            });

            var idSvrFactory = Factory.Configure();

            idSvrFactory.ConfigureUserService("AspId");
            //idSvrFactory.ConfigureCustomUserService("AspId_CustomPK");

            var options = new IdentityServerOptions
            {
                SiteName              = "Thinktecture IdentityServer3 - UserService-AspNetIdentity",
                SigningCertificate    = Certificate.Get(),
                Factory               = idSvrFactory,
                CorsPolicy            = CorsPolicy.AllowAll,
                AuthenticationOptions = new AuthenticationOptions
                {
                    IdentityProviders = ConfigureAdditionalIdentityProviders,
                }
            };

            app.UseIdentityServer(options);
        }
        public static void UseIdentityServer(this IApplicationBuilder app, IdentityServerOptions options)
        {
            
            app.UseOwin(pipeline =>
            {
                pipeline(next =>
                {
                    var builder = new Microsoft.Owin.Builder.AppBuilder();
                    var provider = app.ApplicationServices.GetService<DataProtection.IDataProtectionProvider>();

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

                    builder.Map("/admin", adminApp =>
                    {
                        var factory = new IdentityManagerServiceFactory();
                        factory.ConfigureSimpleIdentityManagerService("AspId");
                        //factory.ConfigureCustomIdentityManagerServiceWithIntKeys("AspId_CustomPK");

                        adminApp.UseIdentityManager(new IdentityManagerOptions()
                        {
                            Factory = factory
                        });
                    });

                    builder.UseIdentityServer(options);
                    builder.UseAesDataProtectorProvider();
                    var appFunc = builder.Build(typeof(Func<IDictionary<string, object>, Task>)) as Func<IDictionary<string, object>, Task>;
                    return appFunc;
                });
            });
        }
Ejemplo n.º 12
0
        public void Configuration(IAppBuilder app)
        {
            LogProvider.SetCurrentLogProvider(new DiagnosticsTraceLogProvider());
            Log.Logger = new LoggerConfiguration()
                         .MinimumLevel.Debug()
                         .WriteTo.Trace()
                         .CreateLogger();

            app.Map("/admin", adminApp =>
            {
                var factory = new IdentityManagerServiceFactory();
                factory.ConfigureSimpleIdentityManagerService("AspId");

                adminApp.UseIdentityManager(new IdentityManagerOptions()
                {
                    Factory = factory
                });
            });

            app.Map("/core", core =>
            {
                var idSvrFactory = Factory.Configure();
                idSvrFactory.ConfigureUserService("AspId");

                var options = new IdentityServerOptions
                {
                    SiteName           = "IdentityServer3 - AspNetIdentity 2FA",
                    SigningCertificate = Certificate.Get(),
                    Factory            = idSvrFactory,
                };

                core.UseIdentityServer(options);
            });
        }
        public void Configuration(IAppBuilder app)
        {
            // Configuring logging
            LogProvider.SetCurrentLogProvider(new DiagnosticsTraceLogProvider());

            // Configuring thinktecture identity manager
            app.Map("/admin", adminApp =>
            {
                var adminFactory = new IdentityManagerServiceFactory();
                adminFactory.ConfigureSimpleIdentityManagerService();

                adminApp.UseIdentityManager(new IdentityManagerOptions
                {
                    Factory = adminFactory
                });
            });

            // Configuring thinktecture auth server with Asp.Net identity
            var factory = Factory.Configure();
            factory.ConfigureCustomServices();
            var options = new IdentityServerOptions
            {
                SiteName = "My Auth Server",
                RequireSsl = false,
                SigningCertificate = Certificate.Load(),
                Factory = factory,
                CorsPolicy = CorsPolicy.AllowAll
            };
            app.UseIdentityServer(options);
        }
Ejemplo n.º 14
0
        public void Configuration(IAppBuilder app)
        {
            //Log.Logger = new LoggerConfiguration()
            //    .WriteTo.RollingFile("log-{Date}.txt")
            //    .CreateLogger();
            Log.Logger = new LoggerConfiguration()
                         .MinimumLevel.Debug()
                         .WriteTo.Trace()
                         .CreateLogger();

            var efConfig = new EntityFrameworkServiceOptions
            {
                ConnectionString = "DefaultConnection"
            };

#if DEBUG
            Database.SetInitializer(new DropCreateDatabaseIfModelChanges <ApplicationDbContext>());
#endif

            app.Map("/admin", adminApp =>
            {
                var imgrFactory = new IdentityManagerServiceFactory();
                imgrFactory.ConfigureSimpleIdentityManagerService();

                adminApp.UseIdentityManager(new IdentityManagerOptions()
                {
                    Factory = imgrFactory
                });
            });

            var factory = new IdentityServerServiceFactory();

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

#if DEBUG
            // these two calls just pre-populate the test DB from the in-memory config
            TestClients.ConfigureClients(TestClients.Get(), efConfig);
            TestScopes.ConfigureScopes(TestScopes.Get(), efConfig);
#endif

            var options = new IdentityServerOptions
            {
                SiteName           = "MyIdentityServer - Server",
                Factory            = factory,
                RequireSsl         = false,
                SigningCertificate = Certificate.Get(),
            };
            app.UseIdentityServer(options);

            var cleanup = new TokenCleanup(efConfig, 10);
            cleanup.Start();
        }
        public void Configuration(IAppBuilder app)
        {
            var factory = new IdentityManagerServiceFactory();

            factory.ConfigureSimpleIdentityManagerService("AspId");
            //factory.ConfigureCustomIdentityManagerServiceWithIntKeys("AspId_CustomPK");

            app.UseIdentityManager(new IdentityManagerOptions()
            {
                Factory = factory
            });
        }
Ejemplo n.º 16
0
        public void Configuration(IAppBuilder app)
        {
            LogProvider.SetCurrentLogProvider(new TraceSourceLogProvider());

            var factory = new IdentityManagerServiceFactory();

            factory.ConfigureSimpleIdentityManagerService("AspId");
            //factory.ConfigureCustomIdentityManagerServiceWithIntKeys("AspId_CustomPK");

            app.UseIdentityManager(new IdentityManagerOptions()
            {
                Factory = factory
            });
        }
        public void Configuration(IAppBuilder app)
        {
            LogProvider.SetCurrentLogProvider(new TraceSourceLogProvider());

            var factory = new IdentityManagerServiceFactory();
            
            factory.ConfigureSimpleIdentityManagerService("AspId");
            //factory.ConfigureCustomIdentityManagerServiceWithIntKeys("AspId_CustomPK");

            app.UseIdentityManager(new IdentityManagerOptions()
            {
                Factory = factory
            });
        }
Ejemplo n.º 18
0
        void InitializeUserAdmin(IAppBuilder app)
        {
            // Users and Roles manager
            app.Map("/useradmin", adminApp =>
            {
                var factory = new IdentityManagerServiceFactory();
                factory.ConfigureSimpleIdentityManagerService(MyConstants.UserAdminConfig);

                adminApp.UseIdentityManager(new IdentityManagerOptions
                {
                    Factory = factory
                });
            });
        }
Ejemplo n.º 19
0
        public void Configuration(IAppBuilder app)
        {
            app.UseCookieAuthentication(new CookieAuthenticationOptions()
            {
                AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                LoginPath = new PathString("/home/login")
            });

            app.Map("/admin", adminApp =>
            {
                var factory = new IdentityManagerServiceFactory();
                factory.ConfigureSimpleIdentityManagerService();

                adminApp.UseIdentityManager(new IdentityManagerOptions()
                {
                    Factory = factory,
                    SecurityConfiguration = new HostSecurityConfiguration()
                    {
                        HostAuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                        NameClaimType = "name",
                        RoleClaimType = "role",
                        AdminRoleName = "Admin"
                    }
                });
            });

            app.Map("/core", core =>
            {
                var idSvrFactory = Factory.Configure();
                idSvrFactory.ConfigureUserService();

                var options = new IdentityServerOptions
                {
                    SiteName = "IdentityServer3 - UserService-AspNetIdentity",
                    SigningCertificate = Certificate.Get(),
                    Factory = idSvrFactory,
                    AuthenticationOptions = new AuthenticationOptions
                    {
                        IdentityProviders = ConfigureAdditionalIdentityProviders,
                    }
                };

                core.UseIdentityServer(options);
            });

            ConfigureAuth(app);
        }
Ejemplo n.º 20
0
        public void Configuration(IAppBuilder app)
        {
            app.UseCookieAuthentication(new CookieAuthenticationOptions()
            {
                AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                LoginPath          = new PathString("/home/login")
            });

            app.Map("/admin", adminApp =>
            {
                var factory = new IdentityManagerServiceFactory();
                factory.ConfigureSimpleIdentityManagerService();

                adminApp.UseIdentityManager(new IdentityManagerOptions()
                {
                    Factory = factory,
                    SecurityConfiguration = new HostSecurityConfiguration()
                    {
                        HostAuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                        NameClaimType          = "name",
                        RoleClaimType          = "role",
                        AdminRoleName          = "Admin"
                    }
                });
            });

            app.Map("/core", core =>
            {
                var idSvrFactory = Factory.Configure();
                idSvrFactory.ConfigureUserService();

                var options = new IdentityServerOptions
                {
                    SiteName              = "IdentityServer3 - UserService-AspNetIdentity",
                    SigningCertificate    = Certificate.Get(),
                    Factory               = idSvrFactory,
                    AuthenticationOptions = new AuthenticationOptions
                    {
                        IdentityProviders = ConfigureAdditionalIdentityProviders,
                    }
                };

                core.UseIdentityServer(options);
            });

            ConfigureAuth(app);
        }
Ejemplo n.º 21
0
        // 此代码会配置 Web API。启动类指定为
        // WebApp.Start 方法中的类型参数。
        public static void ConfigureApp(IAppBuilder appBuilder)
        {
            // 配置自托管的 Web API。
            HttpConfiguration config = new HttpConfiguration();

            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
                );

            appBuilder.UseWebApi(config);

            appBuilder.Map("/admin", adminApp =>
            {
                var factory = new IdentityManagerServiceFactory();
                factory.ConfigureSimpleIdentityManagerService("AspId");

                adminApp.UseIdentityManager(new IdentityManagerOptions()
                {
                    Factory = factory,
                    SecurityConfiguration = { RequireSsl = false }
                });
            });

            appBuilder.Map("/core", core =>
            {
                var idSvrFactory = Factory.Configure();
                idSvrFactory.ConfigureUserService("AspId");

                var options = new IdentityServerOptions
                {
                    SiteName   = "IdentityServer3 - AspNetIdentity 2FA",
                    RequireSsl = false,
                    //SigningCertificate = Certificate.Get(),
                    Factory = idSvrFactory,
                };

                core.UseIdentityServer(options);
            });
        }
Ejemplo n.º 22
0
        public void Configure(IApplicationBuilder app, IApplicationEnvironment env)
        {
            Log.Logger = new LoggerConfiguration().MinimumLevel.Debug().WriteTo.Trace().CreateLogger();
            BasePath = env.ApplicationBasePath;
            var certFile = Path.Combine(BasePath, "idsrv3test.pfx");
            var options = ConfigureIdentityServer(certFile);
          
            app.UseOwin(pipeline =>
            {
                pipeline(next =>
                {
                    var builder = new Microsoft.Owin.Builder.AppBuilder();
                    var provider = app.ApplicationServices.GetService<Microsoft.AspNet.DataProtection.IDataProtectionProvider>();

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

                    builder.UseAesDataProtectorProvider();
                    builder.Map("/admin", adminApp =>
                    {
                        var factory = new IdentityManagerServiceFactory();
                        factory.ConfigureSimpleIdentityManagerService("AspId");
                        //factory.ConfigureCustomIdentityManagerServiceWithIntKeys("AspId_CustomPK");

                        adminApp.UseIdentityManager(new IdentityManagerOptions()
                        {
                            Factory = factory
                        });
                    });

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

            app.UseIdentityServer(options);
        }
Ejemplo n.º 23
0
        public void Configure(IApplicationBuilder app, IApplicationEnvironment env)
        {
            Log.Logger = new LoggerConfiguration().MinimumLevel.Debug().WriteTo.Trace().CreateLogger();
            BasePath   = env.ApplicationBasePath;
            var certFile = Path.Combine(BasePath, "idsrv3test.pfx");
            var options  = ConfigureIdentityServer(certFile);

            app.UseOwin(pipeline =>
            {
                pipeline(next =>
                {
                    var builder  = new Microsoft.Owin.Builder.AppBuilder();
                    var provider = app.ApplicationServices.GetService <Microsoft.AspNet.DataProtection.IDataProtectionProvider>();

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

                    builder.UseAesDataProtectorProvider();
                    builder.Map("/admin", adminApp =>
                    {
                        var factory = new IdentityManagerServiceFactory();
                        factory.ConfigureSimpleIdentityManagerService("AspId");
                        //factory.ConfigureCustomIdentityManagerServiceWithIntKeys("AspId_CustomPK");

                        adminApp.UseIdentityManager(new IdentityManagerOptions()
                        {
                            Factory = factory
                        });
                    });

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

            app.UseIdentityServer(options);
        }
Ejemplo n.º 24
0
        public void ConfigureIdentityServer(IAppBuilder app)
        {
            LogProvider.SetCurrentLogProvider(new DiagnosticsTraceLogProvider());
            Log.Logger = new LoggerConfiguration()
                         .MinimumLevel.Debug()
                         .WriteTo.Trace()
                         .CreateLogger();

            app.Map("/admin", adminApp =>
            {
                var factory = new IdentityManagerServiceFactory();
                factory.ConfigureSimpleIdentityManagerService("CADB");
                //factory.ConfigureCustomIdentityManagerServiceWithIntKeys("AspId_CustomPK");

                adminApp.UseIdentityManager(new IdentityManagerOptions()
                {
                    Factory = factory
                });
            });

            app.Map("/core", core =>
            {
                var idSvrFactory = Factory.Configure();
                idSvrFactory.ConfigureUserService("CADB");
                //idSvrFactory.ConfigureCustomUserService("AspId_CustomPK");

                var options = new IdentityServerOptions
                {
                    SiteName              = "IdentityServer3 - UserService-AspNetIdentity",
                    SigningCertificate    = Certificate.Get(),
                    Factory               = idSvrFactory,
                    AuthenticationOptions = new AuthenticationOptions
                    {
                        IdentityProviders = ConfigureAdditionalIdentityProviders,
                    }
                };

                core.UseIdentityServer(options);
            });
        }
        public void Configuration(IAppBuilder app)
        {
            LogProvider.SetCurrentLogProvider(new DiagnosticsTraceLogProvider());
            Log.Logger = new LoggerConfiguration()
               .MinimumLevel.Debug()
               .WriteTo.Trace()
               .CreateLogger();

            app.Map("/admin", admin =>
            {
                var factory = new IdentityManagerServiceFactory();
                factory.ConfigureSimpleIdentityManagerService();

                admin.UseIdentityManager(new IdentityManagerOptions
                {
                    Factory = factory
                });
            });

            app.Map("/core", core =>
            {
                var factory = Factory.Configure();

                var options = new IdentityServerOptions
                {
                    SiteName = "Cardeal - Servidor de Identidade",
                    SigningCertificate = Certificate.Get(),
                    Factory = factory,
                    AuthenticationOptions = new AuthenticationOptions
                    {
                        EnablePostSignOutAutoRedirect = true,
                        EnableSignOutPrompt = false,
                        PostSignOutAutoRedirectDelay = 1
                    },
                    IssuerUri = "http://adsprev.com.br"
                };

                core.UseIdentityServer(options);
            });
        }
Ejemplo n.º 26
0
        public void Configuration(IAppBuilder app)
        {
            LogProvider.SetCurrentLogProvider(new DiagnosticsTraceLogProvider());
            Log.Logger = new LoggerConfiguration()
               .MinimumLevel.Debug()
               .WriteTo.Trace()
               .CreateLogger();

            app.UseAesDataProtectorProvider();
            app.Map("/admin", adminApp =>
                {
                    var factory = new IdentityManagerServiceFactory();

                    factory.ConfigureSimpleIdentityManagerService("AspId");
                    //factory.ConfigureCustomIdentityManagerServiceWithIntKeys("AspId_CustomPK");

                    var adminOptions = new IdentityManagerOptions(){
                        Factory = factory
                    };
                    adminOptions.SecurityConfiguration.RequireSsl = false;
                    adminApp.UseIdentityManager(adminOptions);
                });

            var idSvrFactory = Factory.Configure();
            idSvrFactory.ConfigureUserService("AspId");
            //idSvrFactory.ConfigureCustomUserService("AspId_CustomPK");

            var options = new IdentityServerOptions
            {
                SiteName = "IdentityServer3 - UserService-AspNetIdentity",
                SigningCertificate = Certificate.Get(),
                Factory = idSvrFactory,
                RequireSsl = false,
                AuthenticationOptions = new AuthenticationOptions
                {
                    IdentityProviders = ConfigureAdditionalIdentityProviders,
                }
            };

            app.UseIdentityServer(options);
        }
Ejemplo n.º 27
0
        public static void Configure(IAppBuilder app)
        {
            Log.Logger = new LoggerConfiguration()
                       .MinimumLevel.Debug()
                       .WriteTo.Trace()
                       .CreateLogger();
            app.UseAesDataProtectorProvider();

            BasePath = AppDomain.CurrentDomain.BaseDirectory;
            var certFile = Path.Combine(BasePath, "idsrv3test.pfx");
            Console.WriteLine(certFile);
            var options = ConfigureIdentityServer(certFile);

            //  var cpath = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),"..", "..", "..", "src", "Janitor", "Content"));
            //  Console.WriteLine(cpath);
            //  app.UseStaticFiles (new StaticFileOptions {
            //		RequestPath = new PathString("/Content"),
            //		FileSystem = new PhysicalFileSystem(cpath)
            //	});

            app.Map("/admin", adminApp =>
            {
                var factory = new IdentityManagerServiceFactory();
                factory.ConfigureSimpleIdentityManagerService("AspId");
                    var adminOptions = new IdentityManagerOptions
                        {
                            Factory = factory,

                        };
                    adminOptions.SecurityConfiguration.RequireSsl = false;
                    adminApp.UseIdentityManager(adminOptions);
            });

            app.UseIdentityServer(options);
        }
Ejemplo n.º 28
0
        public void Configuration(IAppBuilder app)
        {
            LogProvider.SetCurrentLogProvider(new DiagnosticsTraceLogProvider());

            // uncomment to enable HSTS headers for the host
            // see: https://developer.mozilla.org/en-US/docs/Web/Security/HTTP_strict_transport_security
            //app.UseHsts();

            app.Map("/admin", adminApp =>
            {
                var factory = new IdentityManagerServiceFactory();
                factory.ConfigureSimpleIdentityManagerService("AspId");

                adminApp.UseIdentityManager(new IdentityManagerOptions()
                {
                    Factory = factory
                });
            });


            app.Map("/core", coreApp =>
            {
                //In order to run server under hard coded collection of
                //iusers use following configuration: var factory =
                //InMemoryFactory.Create(
                //    users:   Users.Get(),
                //    clients: Clients.Get(),
                //    scopes:  Scopes.Get());

                var idSvrFactory = Factory.Configure();
                idSvrFactory.ConfigureUserService("AspId");



                var idsrvOptions = new IdentityServerOptions
                {
                    Factory            = idSvrFactory,
                    SigningCertificate = Cert.Load(),

                    CorsPolicy = CorsPolicy.AllowAll,

                    AuthenticationOptions = new AuthenticationOptions
                    {
                        IdentityProviders   = ConfigureIdentityProviders,
                        EnableSignOutPrompt = false,
                        //operating cookies here
                    },

                    LoggingOptions = new LoggingOptions
                    {
                        //EnableHttpLogging = true,
                        //EnableWebApiDiagnostics = true,
                        //IncludeSensitiveDataInLogs = true
                    },

                    EventsOptions = new EventsOptions
                    {
                        RaiseFailureEvents     = true,
                        RaiseInformationEvents = true,
                        RaiseSuccessEvents     = true,
                        RaiseErrorEvents       = true
                    },
                };

                coreApp.UseIdentityServer(idsrvOptions);
            });
        }
Ejemplo n.º 29
0
        public void Configuration(IAppBuilder app)
        {
            LogProvider.SetCurrentLogProvider(new DiagnosticsTraceLogProvider());
            Log.Logger = new LoggerConfiguration()
                         .MinimumLevel.Debug()
                         .WriteTo.Trace()
                         .CreateLogger();

            app.UseAesDataProtectorProvider();
            app.Map("/admin", adminApp =>
            {
                var factory = new IdentityManagerServiceFactory();

                factory.ConfigureSimpleIdentityManagerService("AspId");
                //factory.ConfigureCustomIdentityManagerServiceWithIntKeys("AspId_CustomPK");

                var adminOptions = new IdentityManagerOptions()
                {
                    Factory = factory
                };
                adminOptions.SecurityConfiguration.RequireSsl = false;
                adminApp.UseIdentityManager(adminOptions);
            });

            var idSvrFactory = Factory.Configure();

            idSvrFactory.ConfigureUserService("AspId");

            var viewOptions = new ViewServiceOptions
            {
                TemplatePath = this.basePath.TrimEnd(new char[] { '/' })
            };

            idSvrFactory.ViewService = new IdentityServer3.Core.Configuration.Registration <IViewService>(new ViewService(viewOptions));

            var options = new IdentityServerOptions
            {
                SiteName              = "IdentityServer3 - ViewSerive-AspNetIdentity",
                SigningCertificate    = Certificate.Get(),
                Factory               = idSvrFactory,
                RequireSsl            = false,
                AuthenticationOptions = new AuthenticationOptions
                {
                    IdentityProviders = ConfigureAdditionalIdentityProviders,
                }
            };

            app.Map("/core", core =>
            {
                core.UseIdentityServer(options);
            });

            app.UseStaticFiles(new StaticFileOptions
            {
                RequestPath = new PathString("/Content"),
                FileSystem  = new PhysicalFileSystem(Path.Combine(this.basePath, "Content"))
            });

            var config = new HttpConfiguration();

            //  config.MapHttpAttributeRoutes();
            config.Routes.MapHttpRoute("API", "api/{controller}/{action}", new { controller = "Home", action = "Get" });
            app.UseWebApi(config);
        }