public void Configuration(IAppBuilder app)
        {
            // config identity server
            var factory = new IdentityServerServiceFactory
            {
                CorsPolicyService = new IdentityServer3.Core.Configuration.Registration<ICorsPolicyService>(new DefaultCorsPolicyService {AllowAll = true}),
                ScopeStore = new IdentityServer3.Core.Configuration.Registration<IScopeStore>(new InMemoryScopeStore(Scopes.Get())),
                ClientStore = new IdentityServer3.Core.Configuration.Registration<IClientStore>(new InMemoryClientStore(Clients.Get()))
            };
            factory.ConfigureUserService(ConnectionString);

            app.Map("/identity", idServer => idServer.UseIdentityServer(new IdentityServerOptions
            {
                SiteName = "Identity Server for 8sApp",
                RequireSsl = false,
                Factory = factory,
                SigningCertificate = Certificate.Certificate.Get(),
                AuthenticationOptions = new AuthenticationOptions()
                {
                    LoginPageLinks = new[]
                    {
                        new LoginPageLink
                        {
                            Text = "Register",
                            Href = "register"
                        }
                    }
                }
            }));

            // config identity manager
            app.Map("/admin", adminApp =>
            {
                var identityManagerServiceFactory = new IdentityManagerServiceFactory();
                identityManagerServiceFactory.ConfigureIdentityManagerService(ConnectionString);
                var options = new IdentityManagerOptions
                {
                    Factory = identityManagerServiceFactory,
                    SecurityConfiguration = {RequireSsl = false}
                };
                adminApp.UseIdentityManager(options);
            });

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

            app.UseCors(CorsOptions.AllowAll);
            app.UseWebApi(config);
        }
Esempio n. 2
0
        public void Configuration(IAppBuilder app)
        {
            app.Map("/admin", adminApp =>
            {
                var factory = new IdentityAdminServiceFactory();
                factory.Configure("AspId");

                adminApp.UseIdentityAdmin(new IdentityAdminOptions
                {
                    Factory = factory
                });
            });

            app.Map("/manager", managerApp =>
            {
                var factory = new IdentityManagerServiceFactory();
                factory.ConfigureIdentityManagerService("AspId");

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

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

                var options = new IdentityServerOptions
                {
                    SiteName              = "Cabroso Identity Server",
                    SigningCertificate    = IdentityServer.Certificate.Get(),
                    Factory               = idSvrFactory,
                    AuthenticationOptions = new AuthenticationOptions
                    {
                        LoginPageLinks = new List <LoginPageLink>
                        {
                            new LoginPageLink()
                            {
                                Href = "passwordReset",
                                Text = "Reset Your Password",
                                Type = "resetTestType"
                            }
                        }
                    }
                };

                core.UseIdentityServer(options);
            });
        }
        public static IdentityManagerOptions CreateIdentityManagerOptions()
        {
            var factory = new IdentityManagerServiceFactory();
            factory.ConfigureIdentityManagerService("IdentityManagerConfig");

            return new IdentityManagerOptions
            {
                Factory = factory,
                SecurityConfiguration = new HostSecurityConfiguration
                {
                    HostAuthenticationType = "Cookies"
                    , AdminRoleName = "IdentityManagerAdministrator"
                    , RequireSsl = GlobalConfiguration.RequireSSL ?? true
                }
            };
        }
Esempio n. 4
0
        public void Configuration(IAppBuilder app)
        {
            // for the identity server itself
            app.Map("/identity", idsrvApp =>
            {
                var factory = ConfigureEFStores();
                //var factory = ConfigureInMemoryStores();


                // if we need to authenticate via CORS
                //factory.CorsPolicyService = new Registration<ICorsPolicyService>(new DefaultCorsPolicyService
                //{
                //    AllowedOrigins = new[] { "https://localhost:44302", "https://localhost:44304", "https://localhost:44303", "http://localhost:26210", "http://localhost:32411", "http://localhost:20754" }
                //});


                idsrvApp.UseIdentityServer(new IdentityServerOptions
                {
                    SiteName           = "Embedded IdentityServer",
                    SigningCertificate = LoadCertificate(),

                    Factory = factory,

                    AuthenticationOptions = new Thinktecture.IdentityServer.Core.Configuration.AuthenticationOptions
                    {
                        IdentityProviders = ConfigureIdentityProviders
                    }
                });
            });


            // this bit is for all the identity manager stuff......
            app.Map("/admin", adminApp =>
            {
                var factory = new IdentityManagerServiceFactory();
                factory.ConfigureIdentityManagerService(ConfigurationManager.ConnectionStrings["IdSvr3Config"].ConnectionString);

                adminApp.UseIdentityManager(new IdentityManagerOptions()
                {
                    Factory = factory
                });
            });
        }
Esempio n. 5
0
        public void Configuration(IAppBuilder app)
        {
            Log.Logger = new LoggerConfiguration()
                         .MinimumLevel.Debug()                // change with your desired log level
                         .WriteTo.File(@"C:\temp\myPath.txt") // remember to assign proper writing privileges on the file
                         .CreateLogger();

            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = "Cookies"
            });

            app.Map("/identity", idsrvApp =>
            {
                var options = new IdentityServerOptions
                {
                    SiteName           = "Security Token Server",
                    SigningCertificate = LoadCertificate(),
                    Factory            = IdSrvFactory.Configure("SecurityTokenServiceConfig")
                };

                idsrvApp.UseIdentityServer(options);
            });

            app.Map("/UserManagement", adminApp =>
            {
                adminApp.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions
                {
                    Authority    = "https://*****:*****@"https://localhost:44300/UserManagement/",
                    ResponseType = "id_token",
                    SignInAsAuthenticationType = "Cookies",
                    Notifications = new OpenIdConnectAuthenticationNotifications
                    {
                        SecurityTokenValidated = n =>
                        {
                            return(AddClaims(n));
                        }
                    }
                });
                var factory = new IdentityManagerServiceFactory();
                factory.ConfigureIdentityManagerService("SecurityTokenServiceConfig");

                adminApp.UseIdentityManager(new IdentityManagerOptions()
                {
                    Factory = factory,
                    SecurityConfiguration = new HostSecurityConfiguration
                    {
                        HostAuthenticationType = "Cookies",
                        AdminRoleName          = "UserManagementAdmin"
                    }
                });
            });

            app.Map("/Admin", adminApp =>
            {
                adminApp.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions
                {
                    Authority    = "https://*****:*****@"https://localhost:44300/Admin/",
                    ResponseType = "id_token",
                    SignInAsAuthenticationType = "Cookies",
                    Notifications = new OpenIdConnectAuthenticationNotifications
                    {
                        SecurityTokenValidated = n =>
                        {
                            return(AddClaims(n));
                        }
                    }
                });
                var factory = new IdentityAdminServiceFactory();
                factory.Configure();
                adminApp.UseIdentityAdmin(new IdentityAdminOptions
                {
                    Factory = factory,
                    AdminSecurityConfiguration = new AdminHostSecurityConfiguration
                    {
                        HostAuthenticationType = "Cookies",
                        AdminRoleName          = "ClientScopeManagementAdmin"
                    }
                });
            });
        }