public void Configuration(IAppBuilder app) { var connectionString = "MembershipReboot"; app.Map("/admin", adminApp => { var factory = new IdentityManagerServiceFactory(); factory.Configure(connectionString); adminApp.UseIdentityManager(new IdentityManagerOptions() { Factory = factory }); }); var idSvrFactory = Factory.Configure(); idSvrFactory.ConfigureCustomUserService(connectionString); var options = new IdentityServerOptions { IssuerUri = "https://idsrv3.com", SiteName = "Thinktecture IdentityServer3 - UserService-MembershipReboot", SigningCertificate = Certificate.Get(), Factory = idSvrFactory, CorsPolicy = CorsPolicy.AllowAll, AuthenticationOptions = new AuthenticationOptions{ IdentityProviders = ConfigureAdditionalIdentityProviders, } }; app.UseIdentityServer(options); }
public void Configuration(IAppBuilder app) { var connectionString = "MembershipReboot"; app.Map("/admin", adminApp => { var factory = new IdentityManagerServiceFactory(); factory.Configure(connectionString); adminApp.UseIdentityManager(new IdentityManagerOptions() { Factory = factory }); }); var idSvrFactory = Factory.Configure(); idSvrFactory.ConfigureCustomUserService(connectionString); var options = new IdentityServerOptions { IssuerUri = "https://idsrv3.com", SiteName = "Thinktecture IdentityServer3 - UserService-MembershipReboot", SigningCertificate = Certificate.Get(), Factory = idSvrFactory, CorsPolicy = CorsPolicy.AllowAll, AuthenticationOptions = new AuthenticationOptions { IdentityProviders = ConfigureAdditionalIdentityProviders, } }; app.UseIdentityServer(options); }
public void Configuration(IAppBuilder app) { var factory = new IdentityManagerServiceFactory(); factory.Configure("CustomMembershipReboot"); app.UseIdentityManager(new IdentityManagerOptions() { Factory = factory }); }
public void Configuration(IAppBuilder app) { LogProvider.SetCurrentLogProvider(new TraceSourceLogProvider()); var factory = new IdentityManagerServiceFactory(); factory.Configure("CustomMembershipReboot"); app.UseIdentityManager(new IdentityManagerOptions() { Factory = factory }); }
public void Configuration(IAppBuilder app) { //grab the conn names for the MR and IdSrv databases var mrDbConnStringName = ConfigurationManager.AppSettings["MembershipRebootDb"]; var idSrvDbConnStringName = ConfigurationManager.AppSettings["IdentityServerDb"]; //expose identity manager at /admin app.Map("/admin", adminApp => { var factory = new IdentityManagerServiceFactory(); factory.Configure(mrDbConnStringName); adminApp.UseIdentityManager(new IdentityManagerOptions() { Factory = factory }); }); //expose identity server at /core app.Map("/core", core => { var idSvrFactory = Factory.Configure(idSrvDbConnStringName); idSvrFactory.ConfigureCustomUserService(mrDbConnStringName); var options = new IdentityServerOptions { SiteName = "EmapaSA IdentityServer", IssuerUri = ConfigurationManager.AppSettings["IdentityServerUri"], //If the IdSrv is behind a firewall, load balancer, webgarden, it needs to know what is its public uri PublicOrigin = ConfigurationManager.AppSettings["IdentityServerOrigin"], SigningCertificate = Certificate.Get(), Factory = idSvrFactory }; core.UseIdentityServer(options); }); }
public void Configuration(IAppBuilder app) { LogProvider.SetCurrentLogProvider(new DiagnosticsTraceLogProvider()); Log.Logger = new LoggerConfiguration() .MinimumLevel.Debug() .WriteTo.Trace() .CreateLogger(); var connectionString = "MembershipReboot"; app.Map("/admin", adminApp => { var factory = new IdentityManagerServiceFactory(); factory.Configure(connectionString); adminApp.UseIdentityManager(new IdentityManagerOptions() { Factory = factory }); }); app.Map("/core", core => { var idSvrFactory = Factory.Configure(); idSvrFactory.ConfigureCustomUserService(connectionString); var options = new IdentityServerOptions { SiteName = "IdentityServer3 - UserService-MembershipReboot", 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(); var connectionString = "MembershipReboot"; app.Map("/admin", adminApp => { var factory = new IdentityManagerServiceFactory(); factory.Configure(connectionString); adminApp.UseIdentityManager(new IdentityManagerOptions() { Factory = factory }); }); app.Map("/core", core => { var idSvrFactory = Factory.Configure(); idSvrFactory.ConfigureCustomUserService(connectionString); var options = new IdentityServerOptions { SiteName = "IdentityServer3 - UserService-MembershipReboot", SigningCertificate = Certificate.Get(), Factory = idSvrFactory, AuthenticationOptions = new AuthenticationOptions{ IdentityProviders = ConfigureAdditionalIdentityProviders, } }; core.UseIdentityServer(options); }); }
public void Configuration(IAppBuilder appBuilder) { //var options = new IdentityServerOptions //{ // SigningCertificate = Certificate.Load(), // Factory = factory, //}; //appBuilder.UseIdentityServer(options); var connectionString = "MembershipReboot"; //------------------------------------------------ const string IdServBaseUri = @"https://*****:*****@"https://localhost:44333/admin/"; AntiForgeryConfig.UniqueClaimTypeIdentifier = "sub"; JwtSecurityTokenHandler.InboundClaimTypeMap = new Dictionary<string, string>(); appBuilder.Map("/admin", adminApp => { adminApp.UseCookieAuthentication(new CookieAuthenticationOptions { AuthenticationType = "Cookies" }); adminApp.UseOpenIdConnectAuthentication( new OpenIdConnectAuthenticationOptions { AuthenticationType = "oidc", ClientId = "hybridclient", Authority = IdServBaseUri, RedirectUri = ClientUri, PostLogoutRedirectUri = @"https://*****:*****@"https://localhost:44333/connect/userinfo"), n.ProtocolMessage.AccessToken); var userInfo = await userInfoClient.GetAsync(); List<Tuple<string, string>> mn = userInfo.Claims as List<Tuple<string, string>>; mn.ForEach(x => nIdentity.AddClaim(new Claim(x.Item1, x.Item2))); //userInfo.Claims.ToList().ForEach(x => nIdentity.AddClaim(new Claim(x.Item1, x.Item2))); /*var tokenClient = new OAuth2Client(new Uri(@"https://*****:*****@"https://localhost:44333/useraccount/", ResponseType = "code id_token token", Scope = "openid profile email roles all_claims", //offline_access SignInAsAuthenticationType = "Cookies", PostLogoutRedirectUri = @"https://*****:*****@"https://localhost:44333/connect/userinfo"), n.ProtocolMessage.AccessToken); var userInfo = await userInfoClient.GetAsync(); List<Tuple<string, string>> mn = userInfo.Claims as List<Tuple<string, string>>; mn.ForEach(x => nIdentity.AddClaim(new Claim(x.Item1, x.Item2))); nIdentity.AddClaim(new Claim("id_token", n.ProtocolMessage.IdToken)); n.Options.Caption += "id_token_hint=" + n.ProtocolMessage.IdToken; n.AuthenticationTicket = new Microsoft.Owin.Security.AuthenticationTicket( nIdentity, n.AuthenticationTicket.Properties); }, RedirectToIdentityProvider = async n => { if (n.ProtocolMessage.RequestType == OpenIdConnectRequestType.LogoutRequest) { var idTokenHint = n.OwinContext.Authentication.User.FindFirst("id_token").Value; n.ProtocolMessage.IdTokenHint = idTokenHint; //var caption = n.Options.Caption; //var indexOfTokenHint = caption.IndexOf("id_token_hint="); //var idTokenHint = caption.Substring(indexOfTokenHint).Replace("id_token_hint=", ""); //n.Options.Caption = caption.Remove(indexOfTokenHint); //n.ProtocolMessage.IdTokenHint = idTokenHint; } } } }); }); var idSvrFactory = Factory.Configure(); idSvrFactory.ConfigureCustomUserService(connectionString); idSvrFactory.ViewService = new Thinktecture.IdentityServer.Core.Configuration.Registration<IViewService>(typeof(CustomViewService)); var options = new IdentityServerOptions { IssuerUri = "https://localhost:44333/", //"https://localhost:44333/core" SiteName = "SLEEK Auth System", SigningCertificate = Certificate.Load(), //.Get(), Factory = idSvrFactory, CorsPolicy = CorsPolicy.AllowAll, AuthenticationOptions = new AuthenticationOptions { IdentityProviders = ConfigureAdditionalIdentityProviders, LoginPageLinks = new LoginPageLink[] { new LoginPageLink(){ Href = "UserAccount/PasswordReset", Text = "I can't access my account" }, new LoginPageLink(){ Href = "Registration", Text = "Create account" } } }, //EnableWelcomePage = false }; appBuilder.UseIdentityServer(options); }
public void Configuration(IAppBuilder app) { LogProvider.SetCurrentLogProvider(new DiagnosticsTraceLogProvider()); Log.Logger = new LoggerConfiguration() .MinimumLevel.Debug() .WriteTo.Trace() .CreateLogger(); app.UseCookieAuthentication(new Microsoft.Owin.Security.Cookies.CookieAuthenticationOptions() { AuthenticationType = "Cookies", LoginPath = new PathString("/Home/Login") }); // Adding below stuff to secure identity manager //JwtSecurityTokenHandler.InboundClaimTypeMap = new Dictionary<string, string>(); //app.UseCookieAuthentication(new Microsoft.Owin.Security.Cookies.CookieAuthenticationOptions //{ // AuthenticationType = "Cookies", //}); //app.UseOpenIdConnectAuthentication(new Microsoft.Owin.Security.OpenIdConnect.OpenIdConnectAuthenticationOptions //{ // AuthenticationType = "oidc", // Authority = WebConfigurationManager.AppSettings["IdentityServerURL"], // https://localhost:44301/identity, // ClientId = "WorksuiteThinClient", // RedirectUri = WebConfigurationManager.AppSettings["IdentityServerAuthRedirectURL"], //"https://localhost:44301", // ResponseType = "id_token", // UseTokenLifetime = false, // Scope = "openid idmgr", // SignInAsAuthenticationType = "Cookies", // Notifications = new Microsoft.Owin.Security.OpenIdConnect.OpenIdConnectAuthenticationNotifications // { // SecurityTokenValidated = n => // { // n.AuthenticationTicket.Identity.AddClaim(new Claim("id_token", n.ProtocolMessage.IdToken)); // return Task.FromResult(0); // }, // RedirectToIdentityProvider = async n => // { // if (n.ProtocolMessage.RequestType == Microsoft.IdentityModel.Protocols.OpenIdConnectRequestType.LogoutRequest) // { // var result = await n.OwinContext.Authentication.AuthenticateAsync("Cookies"); // if (result != null) // { // var id_token = result.Identity.Claims.GetValue("id_token"); // if (id_token != null) // { // n.ProtocolMessage.IdTokenHint = id_token; // n.ProtocolMessage.PostLogoutRedirectUri = WebConfigurationManager.AppSettings["IdentityManagerURL"]; //"https://localhost:44337/idm"; // } // } // } // } // } //}); //////////////// var connectionString = "MembershipReboot"; app.Map("/admin", adminApp => { var factory = new IdentityManagerServiceFactory(); factory.Configure(connectionString); adminApp.UseIdentityManager(new IdentityManagerOptions() { Factory = factory, SecurityConfiguration = new HostSecurityConfiguration() { HostAuthenticationType = "Cookies", NameClaimType = "name", RoleClaimType = "role", AdminRoleName = "UsersAdmin" } }); }); app.Map("/identity", core => { var idSvrFactory = Factory.Configure(); idSvrFactory.ConfigureCustomUserService(connectionString); var options = new IdentityServerOptions { SiteName = "IdentityServer3 - UserService-MembershipReboot", SigningCertificate = Certificate.Get(), Factory = idSvrFactory, AuthenticationOptions = new AuthenticationOptions { } }; core.UseIdentityServer(options); }); }
public void Configuration(IAppBuilder appBuilder) { var connectionString = ConfigurationManager.AppSettings["Connection"]; JwtSecurityTokenHandler.InboundClaimTypeMap = new Dictionary <string, string>(); appBuilder.UseCookieAuthentication(new CookieAuthenticationOptions { AuthenticationType = "Cookies" }); appBuilder.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie); appBuilder.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions { AuthenticationType = "oidc", Authority = ConfigurationManager.AppSettings["IdentityServer"], ClientId = "idmgr_client", RedirectUri = ConfigurationManager.AppSettings["IdentityManager"], ResponseType = "id_token", UseTokenLifetime = false, Scope = "openid idmgr", SignInAsAuthenticationType = "Cookies" }); // Identity Manager appBuilder.Map("/admin", adminApp => { var factory = new IdentityManagerServiceFactory(); factory.Configure(connectionString); var options = new IdentityManagerOptions { Factory = factory }; if (Convert.ToBoolean(ConfigurationManager.AppSettings["SecurityEnabled"])) { options.SecurityConfiguration = new HostSecurityConfiguration { HostAuthenticationType = "Cookies", AdditionalSignOutType = "oidc" }; } adminApp.UseIdentityManager(options); }); // Identity Server var idFactory = new IdentityServerServiceFactory(); idFactory.Configure(connectionString); var idOptions = new IdentityServerOptions { SigningCertificate = Certificate.Load(), Factory = idFactory, CorsPolicy = CorsPolicy.AllowAll, AuthenticationOptions = new AuthenticationOptions { IdentityProviders = ConfigureIdentityProviders } }; appBuilder.UseIdentityServer(idOptions); }
public void Configuration(IAppBuilder app) { LogProvider.SetCurrentLogProvider(new DiagnosticsTraceLogProvider()); Log.Logger = new LoggerConfiguration() .MinimumLevel.Debug() .WriteTo.Trace() .CreateLogger(); var connectionString = "MembershipReboot"; var factory = new IdentityManagerServiceFactory(); factory.Configure(connectionString); app.UseIdentityManager(new IdentityManagerOptions() { Factory = factory, //SecurityConfiguration = new HostSecurityConfiguration //{ // HostAuthenticationType = "Cookies", // AdditionalSignOutType = "oidc" //} }); //JwtSecurityTokenHandler.InboundClaimTypeMap = new Dictionary<string, string>(); //app.UseCookieAuthentication(new Microsoft.Owin.Security.Cookies.CookieAuthenticationOptions //{ // AuthenticationType = "Cookies", //}); //app.UseOpenIdConnectAuthentication(new Microsoft.Owin.Security.OpenIdConnect.OpenIdConnectAuthenticationOptions //{ // AuthenticationType = "oidc", // Authority = "https://localhost:44344/", // ClientId = "idmgr_client", // RedirectUri = "https://localhost:44345/", // ResponseType = "id_token", // UseTokenLifetime = false, // Scope = "openid idmgr", // SignInAsAuthenticationType = "Cookies", // Notifications = new Microsoft.Owin.Security.OpenIdConnect.OpenIdConnectAuthenticationNotifications // { // SecurityTokenValidated = n => // { // n.AuthenticationTicket.Identity.AddClaim(new Claim("id_token", n.ProtocolMessage.IdToken)); // return Task.FromResult(0); // }, // RedirectToIdentityProvider = async n => // { // if (n.ProtocolMessage.RequestType == Microsoft.IdentityModel.Protocols.OpenIdConnectRequestType.LogoutRequest) // { // var result = await n.OwinContext.Authentication.AuthenticateAsync("Cookies"); // if (result != null) // { // var id_token = result.Identity.Claims.GetValue("id_token"); // if (id_token != null) // { // n.ProtocolMessage.IdTokenHint = id_token; // n.ProtocolMessage.PostLogoutRedirectUri = "https://localhost:44345"; // } // } // } // } // } //}); }
public void Configuration(IAppBuilder app) { //app.UseCookieAuthentication(new CookieAuthenticationOptions //{ // AuthenticationType = "Cookie", // /* TODO: Add admin security // LoginPath = new PathString("/core/login") // */ //}); //var options = new NtlmAuthenticationOptions //{ // SignInAsAuthenticationType = "Ntlm", // AuthenticationMode = AuthenticationMode.Active, // Description = new OwinAuthenticationDescription // { // AuthenticationType = NtlmAuthenticationDefaults.AuthenticationType, // Caption = "NTLM" // }, // CallbackPath = new PathString("/membership/ntlm-signin") //}; //app.UseNtlmAuthentication(options); //app.Map("/admin", admin => //{ // var factory = new IdentityAdminServiceFactory(); // factory.Configure(); // admin.UseIdentityAdmin(new IdentityAdminOptions // { // Factory = factory // }); //}); app.Map("/membership", membership => { var factory = new IdentityManagerServiceFactory(); factory.Configure(Config.MembershipDb); membership.UseIdentityManager(new IdentityManagerOptions() { Factory = factory, /* TODO: Add admin security * SecurityConfiguration = new HostSecurityConfiguration * { * HostAuthenticationType = "Ntlm", * NameClaimType = "name", * RoleClaimType = "role", * AdminRoleName = "Admin" * } */ }); }); app.Map("/core", core => { var factory = new IdentityServerServiceFactory() .UseInMemoryClients(InMemory.Clients) .UseInMemoryScopes(InMemory.Scopes); var ef = new EntityFrameworkServiceOptions { ConnectionString = Config.HostDb }; ConfigureClients(InMemory.Clients, ef); ConfigureScopes(InMemory.Scopes, ef); factory.ConfigureCustomUserService(Config.MembershipDb); factory.RegisterConfigurationServices(ef); factory.RegisterOperationalServices(ef); factory.ConfigureClientStoreCache(); factory.ConfigureScopeStoreCache(); factory.ConfigureUserServiceCache(); core.UseIdentityServer(new IdentityServerOptions { SiteName = "Validus Identity Server", SigningCertificate = Certificate.Get(), Factory = factory, Endpoints = new EndpointOptions { EnableAccessTokenValidationEndpoint = true }, AuthenticationOptions = new IdentityAuthenticationOptions { IdentityProviders = ConfigureIdentityProviders, EnablePostSignOutAutoRedirect = false } }); }); }