Esempio n. 1
0
        public void Configure(IApplicationBuilder app, IServiceProvider serviceProvider)
        {
            // TOOD: PR this to https://github.com/IdentityServer/IdentityServer3.Samples/blob/master/source/AspNet5Host/src/IdentityServerAspNet5/Startup.cs#L21
            var certFile     = Path.Combine(_appEnv.ApplicationBasePath, "idsrv3test.pfx");
            var idSvrFactory = IdSrvFactory.Configure();

            idSvrFactory.ConfigureCustomUserService(serviceProvider);

            var idsrvOptions = new IdentityServerOptions
            {
                SiteName           = "ModernShopping",
                SigningCertificate = new X509Certificate2(certFile, "idsrv3test"),
                Factory            = idSvrFactory,
                RequireSsl         = false,

                AuthenticationOptions = new AuthenticationOptions
                {
                    EnablePostSignOutAutoRedirect = true,
                    IdentityProviders             = ConfigureIdentityProviders
                }
            };

            app.UseDeveloperExceptionPage();
            app.UseIdentityServer(idsrvOptions);
        }
Esempio n. 2
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"
                    }
                });
            });
        }