public void Configuration(IAppBuilder appBuilder) { // Configure Web API for self-host. HttpConfiguration config = new HttpConfiguration(); config.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/{controller}/{id}", defaults: new { id = RouteParameter.Optional } ); appBuilder.UseWebApi(config); var appFolder = Path.Combine(Directory.GetParent(AppDomain.CurrentDomain.BaseDirectory).Parent.Parent.FullName, "Webportal"); appBuilder.UseFileServer(new Microsoft.Owin.StaticFiles.FileServerOptions { RequestPath = new PathString(WebPortalUrl), FileSystem = new PhysicalFileSystem(appFolder), EnableDirectoryBrowsing = true }); appBuilder.Map(PathString.Empty, a => a.Use<PortalRedirectionMiddelware>(WebPortalUrl)); appBuilder.Use<AdminMiddleware>(); }
private void ConfigureWebApi(IAppBuilder app) { var config = new HttpConfiguration(); config.MapHttpAttributeRoutes(); config.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "{controller}/{action}" ); config.Formatters.JsonFormatter.SerializerSettings.Formatting = Formatting.Indented; app.Map("/api", api => { var corsOptions = new CorsOptions() { PolicyProvider = new CorsPolicyProvider { PolicyResolver = ctx => { var policy = new CorsPolicy(); policy.Origins.Add("http://localhost:3054"); policy.AllowAnyHeader = true; policy.Methods.Add("GET"); return Task.FromResult(policy); } } }; api.UseCors(corsOptions); api.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 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) { 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.MapSignalR<SendingConnection>("/sending-connection"); app.MapSignalR<TestConnection>("/test-connection"); app.MapSignalR<RawConnection>("/raw-connection"); app.MapSignalR<StreamingConnection>("/streaming-connection"); app.Use(typeof(ClaimsMiddleware)); ConfigureSignalR(GlobalHost.DependencyResolver, GlobalHost.HubPipeline); var config = new HubConfiguration() { EnableDetailedErrors = true }; app.MapSignalR(config); app.Map("/cors", map => { map.UseCors(CorsOptions.AllowAll); map.MapSignalR<RawConnection>("/raw-connection"); map.MapSignalR(); }); app.Map("/basicauth", map => { map.UseBasicAuthentication(new BasicAuthenticationProvider()); map.MapSignalR<AuthenticatedEchoConnection>("/echo"); map.MapSignalR(); }); BackgroundThread.Start(); }
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) { app.UseErrorPage(); app.Map("/raw-connection", map => { // Turns cors support on allowing everything // In real applications, the origins should be locked down map.UseCors(CorsOptions.AllowAll) .RunSignalR<RawConnection>(); }); app.Map("/signalr", map => { var config = new HubConfiguration { // You can enable JSONP by uncommenting this line // JSONP requests are insecure but some older browsers (and some // versions of IE) require JSONP to work cross domain // EnableJSONP = true }; // Turns cors support on allowing everything // In real applications, the origins should be locked down map.UseCors(CorsOptions.AllowAll) .RunSignalR(config); }); // Turn tracing on programmatically GlobalHost.TraceManager.Switch.Level = SourceLevels.All; }
public void Configuration(IAppBuilder app) { //app.Run(async context => await context.Response.WriteAsync("Hello!")); app.Use(async (context, next) => { await context.Response.WriteAsync("=== BEFORE ==="); await next(); await context.Response.WriteAsync("=== AFTER ==="); }); app.Map("/class", classApp => classApp.UseHelloWorld( new HelloWorldOptions() { Greeting = "Hello from Middleware Class" })); app.Map("/owin", owinApp => { var middleware = new Func<AppFunc, AppFunc>(next => async env => { var bytes = Encoding.UTF8.GetBytes("Hello OWIN!"); var headers = (IDictionary<string, string[]>)env["owin.ResponseHeaders"]; headers["Content-Type"] = new[] { "text/html" }; var response = (Stream)env["owin.ResponseBody"]; await response.WriteAsync(bytes, 0, bytes.Length); await next(env); }); owinApp.Use(middleware); }); }
public void Configuration(IAppBuilder app) { app.Use<AddBreadCrumbMiddleware>("start-of-the-line"); app.Map("/branch1", app1 => { app1.Use<AddBreadCrumbMiddleware>("took-branch1"); // Nesting paths, e.g. /branch1/branch2 app1.Map("/branch2", app2 => { app2.Use<AddBreadCrumbMiddleware>("took-branch2"); app2.Use<DisplayBreadCrumbs>(); }); MapIfIE(app1); app1.Use<DisplayBreadCrumbs>(); }); // Only full segments are matched, so /branch1 does not match /branch100 app.Map("/branch100", app1 => { app1.Use<AddBreadCrumbMiddleware>("took-branch100"); app1.Use<DisplayBreadCrumbs>(); }); MapIfIE(app); app.Use<AddBreadCrumbMiddleware>("no-branches-taken"); app.Use<DisplayBreadCrumbs>(); }
// This code configures Web API. The Startup class is specified as a type // parameter in the WebApp.Start method. public void Configuration(IAppBuilder appBuilder) { // Configure Web API for self-host. HttpConfiguration config = ConfigurationBuilder.HttpConfiguration; config.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "{controller}/{id}", defaults: new { id = RouteParameter.Optional } ); config.MapHttpAttributeRoutes(); config.Routes.MapHttpRoute("MyROute", "jobs/{name}/trigger", new {controller = "Jobs", action = "PostTriggerJob"}); appBuilder.UseFileServer(new FileServerOptions() { FileSystem = new PhysicalFileSystem("./Assets/assets"), RequestPath = new PathString("/assets") }); appBuilder.Map("/quartzadmin", builder => builder.UseNancy()); appBuilder.Map("/api", builder => builder.UseWebApi(config)); //appBuilder.UseWebApi(config); }
public void Configuration(IAppBuilder app) { // this configures IdentityManager // we're using a Map just to test hosting not at the root app.Map("/idm", idm => { LogProvider.SetCurrentLogProvider(new DiagnosticsTraceLogProvider()); var factory = new IdentityManagerServiceFactory(); var rand = new System.Random(); var users = Users.Get(rand.Next(5000, 20000)); var roles = Roles.Get(rand.Next(15)); factory.Register(new Registration<ICollection<InMemoryUser>>(users)); factory.Register(new Registration<ICollection<InMemoryRole>>(roles)); factory.IdentityManagerService = new Registration<IIdentityManagerService, InMemoryIdentityManagerService>(); idm.UseIdentityManager(new IdentityManagerOptions { Factory = factory, SecurityMode = SecurityMode.LocalMachine, OAuth2Configuration = new OAuth2Configuration { AuthorizationUrl = "http://localhost:17457/ids/connect/authorize", Issuer = "https://idsrv3.com", Audience = "https://idsrv3.com/resources", ClientId = "idmgr", SigningCert = Cert.Load(), Scope = "idmgr", ClaimsTransformation = user => { if (user.IsInRole("Foo")) { ((ClaimsIdentity)user.Identity).AddClaim(new Claim("role", "IdentityManagerAdministrator")); } return user; }, //PersistToken = true, //AutomaticallyRenewToken = true } }); }); // this configures an embedded IdentityServer to act as an external authentication provider // when using IdentityManager in Token security mode. normally you'd configure this elsewhere. app.Map("/ids", ids => { IdSvrConfig.Configure(ids); }); // used to redirect to the main admin page visiting the root of the host app.Run(ctx => { ctx.Response.Redirect("/idm/"); return System.Threading.Tasks.Task.FromResult(0); }); }
public void Configuration(IAppBuilder app) { // When we call the base address + /stringPage app.Map("/stringPage", UseTheStringResponder); // When we call the base address + /htmlPage app.Map("/htmlPage", UseTheHtmlResponder); }
static void CombinedConfig(IAppBuilder builder) { builder.Map("/eventsource", EventSourceSample.BuildSample); builder.Map("/routeheader", RouteHeaderSample.BuildSample); builder.Map("/routequery", RouteQuerySample.BuildSample); builder.Map("/routeparams", RouteParamsSample.BuildSample); builder.Map("/branchsample", RouteBranchSample.BuildSample); }
public void Configuration(IAppBuilder app) { Log.Logger = new LoggerConfiguration() .MinimumLevel.Debug() .WriteTo.Trace() .CreateLogger(); //LogProvider.SetCurrentLogProvider(new DiagnosticsTraceLogProvider()); LogProvider.SetCurrentLogProvider(new DiagnosticsTraceLogProvider()); var builder = new ContainerBuilder(); Modules.Register(builder); var container = builder.Build(); using (var scope = container.BeginLifetimeScope()) { app.Map("/core", coreApp => { scope.Resolve<IdentityServerBootstrapper>().Run(coreApp); }); app.Map("/admin", adminApp => { scope.Resolve<IdentityAdminBootstrapper>().Run(adminApp); }); app.Map("/manage", manageApp => { scope.Resolve<IdentityManagerBootstrapper>().Run(manageApp); }); //app.Map("/memory", memoryApp => //{ // using IdentityManager; // using IdentityManager.Configuration; // using System.Collections.Generic; // var factory = new IdentityManagerServiceFactory // { // }; // var rand = new System.Random(); // var users = new List<InMemoryUser>(); // var roles = new List<InMemoryRole>(); // factory.Register(new Registration<ICollection<InMemoryUser>>(users)); // factory.Register(new Registration<ICollection<InMemoryRole>>(roles)); // factory.IdentityManagerService = new Registration<IIdentityManagerService, InMemoryIdentityManagerService>(); // memoryApp.UseIdentityManager(new IdentityManagerOptions // { // Factory = factory, // }); //}); } }
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); }
public void Configuration(IAppBuilder app) { // setup serilog to use diagnostics trace Log.Logger = new LoggerConfiguration() .WriteTo.Trace(outputTemplate: "{Timestamp} [{Level}] ({Name}){NewLine} {Message}{NewLine}{Exception}") .CreateLogger(); app.Map("/core", coreApp => { var factory = new IdentityServerServiceFactory() .UseInMemoryUsers(Users.Get()) .UseInMemoryClients(Clients.Get()) .UseInMemoryScopes(Scopes.Get()); var options = new IdentityServerOptions { SiteName = "IdentityServer3 with WS-Federation", SigningCertificate = Certificate.Get(), Factory = factory, PluginConfiguration = ConfigurePlugins, }; coreApp.UseIdentityServer(options); }); }
public void Configuration(IAppBuilder app) { //log4net.Config.XmlConfigurator.Configure(); var bootstrapper = new Bootstrapper(); var container = bootstrapper.Build(); var priceFeed = container.Resolve<IPriceFeed>(); priceFeed.Start(); var cleaner = container.Resolve<Cleaner>(); cleaner.Start(); app.UseCors(CorsOptions.AllowAll); app.Map("/signalr", map => { var hubConfiguration = new HubConfiguration { // you don't want to use that in prod, just when debugging EnableDetailedErrors = true, EnableJSONP = true, Resolver = new AutofacSignalRDependencyResolver(container) }; map.UseCors(CorsOptions.AllowAll) .RunSignalR(hubConfiguration); }); }
public void Configuration(IAppBuilder app) { //app.MapSignalR(); app.Map("/signalr", map => { map.UseCors(CorsOptions.AllowAll); var hubConfiguration = new HubConfiguration { EnableJSONP = true }; map.RunSignalR(hubConfiguration); }); // Branch the pipeline here for requests that start with "/signalr" //app.Map("/signalr", map => //{ // // Setup the CORS middleware to run before SignalR. // // By default this will allow all origins. You can // // configure the set of origins and/or http verbs by // // providing a cors options with a different policy. // map.UseCors(CorsOptions.AllowAll); // var hubConfiguration = new HubConfiguration // { // // You can enable JSONP by uncommenting line below. // // JSONP requests are insecure but some older browsers (and some // // versions of IE) require JSONP to work cross domain // // EnableJSONP = true // }; // // Run the SignalR pipeline. We're not using MapSignalR // // since this branch already runs under the "/signalr" // // path. // map.RunSignalR(hubConfiguration); //}); }
public void Configuration(IAppBuilder app) { LogProvider.SetCurrentLogProvider(new DiagnosticsTraceLogProvider()); app.Map("/core", coreApp => { // allow cross origin calls coreApp.UseCors(CorsOptions.AllowAll); var factory = Factory.Create( issuerUri: "https://idsrv3.com", siteName: "Thinktecture IdentityServer v3 - preview 1", publicHostAddress: "http://localhost:3333/core"); //factory.UserService = Registration.RegisterFactory<IUserService>(Thinktecture.IdentityServer.MembershipReboot.UserServiceFactory.Factory); //factory.UserService = Registration.RegisterFactory<IUserService>(Thinktecture.IdentityServer.AspNetIdentity.UserServiceFactory.Factory); var idsrvOptions = new IdentityServerOptions { Factory = factory, AdditionalIdentityProviderConfiguration = ConfigureAdditionalIdentityProviders, ConfigurePlugins = ConfigurePlugins }; coreApp.UseIdentityServer(idsrvOptions); }); }
public void Configuration(IAppBuilder app) { app.Map("/signalr", map => { app.UseCors(CorsOptions.AllowAll); var hubConfiguration = new HubConfiguration { EnableJSONP = true }; /* GlobalHost.DependencyResolver.UseSqlServer( "Data Source=(local);"+ "Initial Catalog=SignalRChat;"+ "Integrated Security=True" ); GlobalHost.DependencyResolver.UseRedis( "localhost", 6379, "", "signalr.key"); GlobalHost.DependencyResolver.UseServiceBus( "your connection string from azure", "signalr"); */ map.RunSignalR(hubConfiguration); }); }
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) { app.Map("/identity", idsrvApp => { idsrvApp.UseIdentityServer(new IdentityServerOptions { SiteName = "Embedded IdentityServer", SigningCertificate = this.LoadCertificate(), Factory = new IdentityServerServiceFactory() .UseInMemoryUsers(Users.Get()) .UseInMemoryClients(Clients.Get()) .UseInMemoryScopes(StandardScopes.All) }); }); app.UseCookieAuthentication(new CookieAuthenticationOptions { AuthenticationType = "Cookies" }); app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions { Authority = Config.authorityLink, ClientId = Config.clientId, RedirectUri = Config.host, ResponseType = "id_token", SignInAsAuthenticationType = "Cookies" }); }
public void Configuration(IAppBuilder app) { Log.Logger = new LoggerConfiguration() .MinimumLevel.Debug() .WriteTo.Trace() .CreateLogger(); app.Map("/core", coreApp => { var factory = new IdentityServerServiceFactory() .UseInMemoryUsers(Users.Get()) .UseInMemoryClients(Clients.Get()) .UseInMemoryScopes(Scopes.Get()); var viewOptions = new DefaultViewServiceOptions(); viewOptions.Stylesheets.Add("/Content/Site.css"); viewOptions.CacheViews = false; factory.ConfigureDefaultViewService(viewOptions); var options = new IdentityServerOptions { SiteName = "IdentityServer3 - Configuring DefaultViewService", SigningCertificate = Certificate.Get(), Factory = factory, AuthenticationOptions = new AuthenticationOptions{ IdentityProviders = ConfigureAdditionalIdentityProviders, } }; coreApp.UseIdentityServer(options); }); }
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("/core", coreApp => { var factory = Factory.Create(); var idsrvOptions = new IdentityServerOptions { IssuerUri = "https://idsrv3.com", SiteName = "Thinktecture IdentityServer v3 - preview 1", SigningCertificate = Cert.Load(), CspReportEndpoint = EndpointSettings.Enabled, AccessTokenValidationEndpoint = EndpointSettings.Enabled, PublicHostName = "http://localhost:3333", Factory = factory, AdditionalIdentityProviderConfiguration = ConfigureAdditionalIdentityProviders, CorsPolicy = CorsPolicy.AllowAll }; coreApp.UseIdentityServer(idsrvOptions); }); }
public void Configuration(IAppBuilder appBuilder) { Log.Logger = new LoggerConfiguration() .WriteTo.Trace(outputTemplate: "{Timestamp} [{Level}] ({Name}){NewLine} {Message}{NewLine}{Exception}") .CreateLogger(); var factory = new IdentityServerServiceFactory() .UseInMemoryUsers(Users.Get()) .UseInMemoryClients(Clients.Get()) .UseInMemoryScopes(Scopes.Get()); // Use the Mvc View Service instead of the default factory.ViewService = new Registration<IViewService, MvcViewService<LogonWorkflowController>>(); // These registrations are also needed since these are dealt with using non-standard construction factory.Register(new Registration<HttpContext>(resolver => HttpContext.Current)); factory.Register(new Registration<HttpContextBase>(resolver => new HttpContextWrapper(resolver.Resolve<HttpContext>()))); factory.Register(new Registration<HttpRequestBase>(resolver => resolver.Resolve<HttpContextBase>().Request)); factory.Register(new Registration<HttpResponseBase>(resolver => resolver.Resolve<HttpContextBase>().Response)); factory.Register(new Registration<HttpServerUtilityBase>(resolver => resolver.Resolve<HttpContextBase>().Server)); factory.Register(new Registration<HttpSessionStateBase>(resolver => resolver.Resolve<HttpContextBase>().Session)); var options = new IdentityServerOptions { SigningCertificate = Certificate.Load(), Factory = factory }; appBuilder.Map("/core", idsrvApp => { idsrvApp.UseIdentityServer(options); }); }
public void Configuration(IAppBuilder app) { app.Map("/core", coreApp => { var factory = InMemoryFactory.Create( users : Users.Get(), clients: Clients.Get(), scopes: Scopes.Get()); var embeddedViewServiceConfig = new EmbeddedAssetsViewServiceConfiguration(); embeddedViewServiceConfig.Stylesheets.Add("/Content/Site.css"); factory.Register(Registration.RegisterSingleton(embeddedViewServiceConfig)); var options = new IdentityServerOptions { IssuerUri = "https://idsrv3.com", SiteName = "Thinktecture IdentityServer v3 - UserService-CustomWorkflows", PublicHostName = "http://localhost:3333", SigningCertificate = Certificate.Get(), Factory = factory, AdditionalIdentityProviderConfiguration = ConfigureAdditionalIdentityProviders, CorsPolicy = CorsPolicy.AllowAll, }; coreApp.UseIdentityServer(options); }); }
public void Configuration(IAppBuilder app) { app.Map("/signalr", map => { var corsPolicy = new CorsPolicy { AllowAnyHeader = true, AllowAnyMethod = true, AllowAnyOrigin = true }; corsPolicy.AllowAnyHeader = true; corsPolicy.AllowAnyMethod = true; corsPolicy.SupportsCredentials = true; map.UseCors(new CorsOptions { PolicyProvider = new CorsPolicyProvider { PolicyResolver = r => Task.FromResult(corsPolicy) } }); map.RunSignalR(new HubConfiguration() { EnableJSONP = true, EnableJavaScriptProxies = true }); }); ConfigureAuth(app); }
public void Configuration(IAppBuilder app) { //worsks to client //app.UseCors(CorsOptions.AllowAll); //app.MapSignalR(); //not working // Branch the pipeline here for requests that start with "/signalr" app.Map("/signalr", map => { // Setup the CORS middleware to run before SignalR. // By default this will allow all origins. You can // configure the set of origins and/or http verbs by // providing a cors options with a different policy. map.UseCors(CorsOptions.AllowAll); var hubConfiguration = new HubConfiguration { Resolver = new AutofacSignalRDependencyResolver(App.Container), }; // Run the SignalR pipeline. We're not using MapSignalR // since this branch already runs under the "/signalr" // path. map.RunSignalR(hubConfiguration); }); }
public void Configuration(IAppBuilder app) { app.Map ( "/signalr", map => { map.UseCors(CorsOptions.AllowAll); var configuration = new HubConfiguration { EnableJavaScriptProxies = true }; map.RunSignalR(configuration); var module = new AuthorizeModule(null, null); GlobalHost.HubPipeline.AddModule(module); }); ViewEngines.Engines.Clear(); ViewEngines.Engines.Add(new FrapidRazorViewEngine()); LogManager.InternalizeLogger(); AreaRegistration.RegisterAllAreas(); WebApiConfig.Register(GlobalConfiguration.Configuration); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); AssetConfig.Register(); StartupRegistration.RegisterAsync().Wait(); BackupRegistration.Register(); EodTaskRegistration.Register(); AccountConfig.Register(app); }
public void Configuration(IAppBuilder app) { app.Map("/chat", map => { map.UseCors(CorsOptions.AllowAll); var config = new HubConfiguration() { EnableJSONP = true, EnableJavaScriptProxies = false }; #if DEBUG ////////////////////////////// config.EnableDetailedErrors = true; #endif ////////////////////////////// map.RunSignalR(config); }); }
public void Configuration(IAppBuilder app) { // End point for client to connect to. // /signalr/hubs returns js meta data for hubs app.Map("/signalr", map => { // Allow cross site calls map.UseCors(CorsOptions.AllowAll); var hubConfiguration = new HubConfiguration { EnableDetailedErrors = true, EnableJSONP = true }; map.RunSignalR(hubConfiguration); }); }
public void Configuration(IAppBuilder app) { // Any connection or hub wire up and configuration should go here GlobalHost.DependencyResolver.UseStackExchangeRedis("localhost", 6379, "", "SignalRNotif"); app.UseCors(CorsOptions.AllowAll); app.Map("/signalr", map => { var hubConfigration = new HubConfiguration { EnableJSONP = true, EnableJavaScriptProxies = false, EnableDetailedErrors = true }; map.RunSignalR(hubConfigration); }); //app.MapAzureSignalR(this.GetType().FullName); }
public void Configuration(IAppBuilder app) { HttpConfiguration config = new HttpConfiguration(); ConfigureOAuth(app); WebApiConfig.Register(config); app.UseCors(Microsoft.Owin.Cors.CorsOptions.AllowAll); app.UseWebApi(config); app.Map("/signalr", map => { map.UseCors(CorsOptions.AllowAll); var hubConfiguration = new HubConfiguration { }; map.RunSignalR(hubConfiguration); }); }
public void Configuration(IAppBuilder app) { //app.Map("/messageHub", map => //{ // map.RunSignalR(new Microsoft.AspNet.SignalR.HubConfiguration { EnableJavaScriptProxies = true }); //}); //app.Map("/NoticeHub", map => //{ // map.RunSignalR(new Microsoft.AspNet.SignalR.HubConfiguration { EnableJavaScriptProxies = true }); //}); app.Map("/signalr", map => { map.RunSignalR(new Microsoft.AspNet.SignalR.HubConfiguration { EnableJavaScriptProxies = true }); }); }
public void Configuration(IAppBuilder app) { app.Map("/core", coreApp => { var factory = TestOptionsFactory.Create( issuerUri: "https://idsrv3.com", siteName: "Thinktecture IdentityServer v3 - preview 1 (WAWS)", publicHostAddress: "http://idsrv3.azurewebsites.net"); var options = new IdentityServerCoreOptions { Factory = factory, SocialIdentityProviderConfiguration = ConfigureSocialIdentityProviders }; coreApp.UseIdentityServerCore(options); }); }
public void Configuration(IAppBuilder app) { app.Use <AuthMiddleware>(); app.UseErrorPage(); app.Map("/message", map => { var config = new HubConfiguration { EnableJSONP = true, EnableJavaScriptProxies = true, }; map.UseCors(CorsOptions.AllowAll) .RunSignalR(config); }); GlobalHost.DependencyResolver.Register(typeof(IUserIdProvider), () => new UserIdProvider()); GlobalHost.Configuration.DefaultMessageBufferSize = 2000; GlobalHost.TraceManager.Switch.Level = SourceLevels.Information; }
public void Configuration(IAppBuilder app) { // For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=316888 JwtSecurityTokenHandler.InboundClaimTypeMap = new Dictionary <string, string>(); //Prevents the re-mapping of JWT claims to Microsoft ones. // For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=316888 app.Map("/api", webApi => { webApi.UseCors(Microsoft.Owin.Cors.CorsOptions.AllowAll); //Enable CORS for everything from everywhere. May want to lock this down later. webApi.UseIdentityServerBearerTokenAuthentication(new IdentityServerBearerTokenAuthenticationOptions { Authority = _appConfig.Authority, EnableValidationResultCache = true, ValidationResultCacheDuration = new TimeSpan(0, 5, 0), RequiredScopes = new[] { "myday-api" }, RoleClaimType = "role", NameClaimType = "preferred_username" }); //Setup JSON serialisation formatting var config = new HttpConfiguration(); config.Formatters.Clear(); config.Formatters.Add(new JsonMediaTypeFormatter()); //Ensures serialisation of json objects use camel case property names and do not include null values in json response. config.Formatters.JsonFormatter.SerializerSettings = new Newtonsoft.Json.JsonSerializerSettings { ContractResolver = new Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver(), NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore }; //Force all enumerations values in models to be serialised to strings instead of integers config.Formatters.JsonFormatter.SerializerSettings.Converters.Add(new Newtonsoft.Json.Converters.StringEnumConverter()); // Web API routes using attribute routing only WebApiConfig.Register(config); IoCConfig.RegisterIoC(config); webApi.UseWebApi(config); }); }
public void Configuration(IAppBuilder app) { Log.Logger = new LoggerConfiguration() .MinimumLevel.Debug() .WriteTo.Trace() .CreateLogger(); app.Map("/core", coreApp => { var factory = new IdentityServerServiceFactory() .UseInMemoryUsers(Users.Get()) .UseInMemoryClients(Clients.Get()) .UseInMemoryScopes(Scopes.Get()); var opts = new LocaleOptions { LocaleProvider = env => { var owinContext = new OwinContext(env); var owinRequest = owinContext.Request; var headers = owinRequest.Headers; var accept_language_header = headers["accept-language"].ToString(); var languages = accept_language_header.Split(',').Select(StringWithQualityHeaderValue.Parse).OrderByDescending(s => s.Quality.GetValueOrDefault(1)); var locale = languages.First().Value; return(locale); } }; factory.Register(new Registration <LocaleOptions>(opts)); factory.LocalizationService = new Registration <ILocalizationService, GlobalizedLocalizationService>(); var options = new IdentityServerOptions { SiteName = "IdentityServer33 - Localized from accept-language http header Messages", SigningCertificate = Certificate.Get(), Factory = factory }; coreApp.UseIdentityServer(options); }); }
public void Configuration(IAppBuilder app) { var httpConfiguration = new HttpConfiguration(); httpConfiguration.Formatters.Clear(); httpConfiguration.Formatters.Add(new JsonMediaTypeFormatter()); httpConfiguration.Formatters.JsonFormatter.SerializerSettings = new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }; // Attribute routing. httpConfiguration.MapHttpAttributeRoutes(); httpConfiguration.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/{controller}/{id}", defaults: new { id = RouteParameter.Optional }); app.UseWebApi(httpConfiguration); // Any connection or hub wire up and configuration should go here // Branch the pipeline here for requests that start with "/signalr" app.Map("/signalr", map => { // Setup the CORS middleware to run before SignalR. // By default this will allow all origins. You can // configure the set of origins and/or http verbs by // providing a cors options with a different policy. map.UseCors(CorsOptions.AllowAll); var hubConfiguration = new HubConfiguration { // You can enable JSONP by uncommenting line below. // JSONP requests are insecure but some older browsers (and some // versions of IE) require JSONP to work cross domain EnableJSONP = true }; // Run the SignalR pipeline. We're not using MapSignalR // since this branch already runs under the "/signalr" // path. map.RunSignalR(hubConfiguration); }); }
internal void BearerTokenAuthenticationWithProviderConfiguration(IAppBuilder app) { var bearerOptions = new OAuthBearerAuthenticationOptions() { Provider = new OAuthBearerAuthenticationProvider() { OnRequestToken = context => { context.OwinContext.Set <bool>("OnRequestToken", true); return(Task.FromResult(0)); }, OnValidateIdentity = context => { context.OwinContext.Set <bool>("OnValidateIdentity", true); return(Task.FromResult(0)); } } }; app.UseOAuthBearerAuthentication(bearerOptions); app.Map("/BearerAuthenticationToken", subApp => { subApp.Run(async context => { var identity = new ClaimsIdentity(new Claim[] { new Claim(ClaimTypes.Name, "test") }, bearerOptions.AuthenticationType, ClaimTypes.Name, ClaimTypes.Role); identity.AddClaim(new Claim(identity.RoleClaimType, "Guest", ClaimValueTypes.String)); var ticket = bool.Parse(context.Request.Query["issueExpiredToken"]) ? new AuthenticationTicket(identity, new AuthenticationProperties() { ExpiresUtc = DateTime.UtcNow }) : new AuthenticationTicket(identity, new AuthenticationProperties() { ExpiresUtc = DateTime.UtcNow.AddYears(4) }); await context.Response.WriteAsync(bearerOptions.AccessTokenFormat.Protect(ticket)); }); }); app.UseBearerApplication(); }
public void Configuration(IAppBuilder app) { app.Use(async(Context, next) => { Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-EN"); var token = Context.Request.Query.Get("token"); if (token != null) { Context.Response.Cookies.Append(SlowpokeHub.TokenCookieName, token); Context.Response.Redirect("\\Static\\Slowpoke.html"); } else { await next.Invoke(); } }); ConfigureAuth(app); GlobalHost.Configuration.MaxIncomingWebSocketMessageSize = int.MaxValue; GlobalHost.Configuration.DisconnectTimeout = TimeSpan.FromSeconds(18); GlobalHost.Configuration.KeepAlive = TimeSpan.FromSeconds(5); GlobalHost.Configuration.DefaultMessageBufferSize = int.MaxValue; app.Map("/signalr", map => { map.UseCors(CorsOptions.AllowAll); var hubConfiguration = new HubConfiguration(); hubConfiguration.EnableDetailedErrors = true; var serializerSettings = new JsonSerializerSettings(); serializerSettings.TypeNameHandling = TypeNameHandling.Objects; var serializer = JsonSerializer.Create(serializerSettings); GlobalHost.DependencyResolver.Register(typeof(JsonSerializer), () => serializer); map.RunSignalR(hubConfiguration); }); SlowpokeHub.Run(new NLogAdapter("Slowpoke.Log")); }
public void Configuration(IAppBuilder app) { // For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864 // Configure the db context, user manager and signin manager to use a single instance per request. app.CreatePerOwinContext(ApplicationDbContext.Create); app.CreatePerOwinContext <ApplicationUserManager>(ApplicationUserManager.Create); app.CreatePerOwinContext <ApplicationSignInManager>(ApplicationSignInManager.Create); // Enable the application to use a cookie to store information for the signed in user // and to use a cookie to temporarily store information about a user logging in with a third party login provider. // Configure the sign in cookie. app.UseCookieAuthentication(new CookieAuthenticationOptions { AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie, LoginPath = new PathString("/Apps/Shell/Pages/Login.aspx"), Provider = new CookieAuthenticationProvider { // Enables the application to validate the security stamp when the user logs in. // This is a security feature which is used when you change a password or add an external login to your account. OnValidateIdentity = SecurityStampValidator.OnValidateIdentity <ApplicationUserManager, ApplicationUser>( validateInterval: TimeSpan.FromMinutes(30), regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager)), OnApplyRedirect = ApplyRedirect, OnResponseSignedIn = context => ServiceLocator.Current.GetInstance <ISynchronizingUserService>().SynchronizeAsync(context.Identity, Enumerable.Empty <string>()) } }); app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie); // Enables the application to temporarily store user information when they are verifying the second factor in the two-factor authentication process. app.UseTwoFactorSignInCookie(DefaultAuthenticationTypes.TwoFactorCookie, TimeSpan.FromMinutes(5)); // Enables the application to remember the second login verification factor such as phone or email. // Once you check this option, your second step of verification during the login process will be remembered on the device where you logged in from. // This is similar to the RememberMe option when you log in. app.UseTwoFactorRememberBrowserCookie(DefaultAuthenticationTypes.TwoFactorRememberBrowserCookie); app.Map(LogoutUrl, map => map.Run(ctx => { ctx.Authentication.SignOut(); return(Task.Run(() => ctx.Response.Redirect("/"))); })); }
public void Configuration(IAppBuilder app) { LoadUrlIdenityServerConfiguration(); LoadCredentialBasicAuthConfiguration(); app.UseBasicAuthentication(new BasicAuthenticationOptions("SecureAPI", async(username, password) => await Authenticate(username, password))); app.UseSignalTokenAuthentication(); app.UseIdentityServerBearerTokenAuthentication(new IdentityServerBearerTokenAuthenticationOptions { //endereço identity server Authority = urlIdentityServer, AuthenticationType = "Bearer", AuthenticationMode = Microsoft.Owin.Security.AuthenticationMode.Active, RequiredScopes = new[] { scopesIdentityServer } }); //app.MapSignalR(); app.Map("/signalr", map => { // Setup the CORS middleware to run before SignalR. // By default this will allow all origins. You can // configure the set of origins and/or http verbs by // providing a cors options with a different policy. map.UseCors(CorsOptions.AllowAll); // add middleware to translate the query string token // passed by SignalR into an Authorization Bearer header var hubConfiguration = new HubConfiguration { // You can enable JSONP by uncommenting line below. // JSONP requests are insecure but some older browsers (and some // versions of IE) require JSONP to work cross domain // EnableJSONP = true }; // Run the SignalR pipeline. We're not using MapSignalR // since this branch already runs under the "/signalr" // path. map.RunSignalR(hubConfiguration); }); }
public static IAppBuilder UseIdentityServer(this IAppBuilder app) { // 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("/core", coreApp => { var factory = new IdentityServerServiceFactory() .UseInMemoryUsers(Users.Get()) .UseInMemoryClients(Clients.Get()) .UseInMemoryScopes(Scopes.Get()); factory.AddCustomGrantValidators(); factory.AddCustomTokenResponseGenerator(); factory.ConfigureClientStoreCache(); factory.ConfigureScopeStoreCache(); factory.ConfigureUserServiceCache(); var idsrvOptions = new IdentityServerOptions { Factory = factory, SigningCertificate = Cert.Load(), Endpoints = new EndpointOptions { // replaced by the introspection endpoint in v2.2 EnableAccessTokenValidationEndpoint = false }, AuthenticationOptions = new AuthenticationOptions { IdentityProviders = ConfigureIdentityProviders, EnableAutoCallbackForFederatedSignout = true }, RequireSsl = false }; coreApp.UseIdentityServer(idsrvOptions); }); return(app); }
public virtual void Configure(IAppBuilder owinApp) { string path = $@"/Metadata/V{AppEnvironment.AppInfo.Version}"; owinApp.Map(path, innerApp => { if (AppEnvironment.DebugMode == true) { innerApp.Use <OwinNoCacheResponseMiddleware>(); } else { innerApp.Use <OwinCacheResponseMiddleware>(); } innerApp.UseXContentTypeOptions(); innerApp.UseXDownloadOptions(); innerApp.Use <MetadatMiddleware>(); }); }
//public void Configuration(IAppBuilder app) //{ // app.Map("/identity", idsrvApp => // { // idsrvApp.UseIdentityServer(new IdentityServerOptions // { // SiteName = "Embedded IdentityServer", // SigningCertificate = LoadCertificate(), // // In memory configuration // Factory = new IdentityServerServiceFactory() // .UseInMemoryUsers(Users.Get()) // .UseInMemoryClients(Clients.Get()) // .UseInMemoryScopes(StandardScopes.All) // }); // }); //} public void Configuration(IAppBuilder app) { //Install-Package Serilog //Install-Package Serilog.Sinks.Trace //Web.config update <system.diagnostics> tree Log.Logger = new LoggerConfiguration().MinimumLevel.Debug().WriteTo.Trace().CreateLogger(); app.Map("/identity", core => { // Configure clients, scopes and users services - asp.net identity database var idSvrFactory = Factory.Configure(); idSvrFactory.ConfigureUserService("DefaultConnection"); // Custom View Service - include content/app+custom+libs folders idSvrFactory.ViewService = new Registration <IViewService>(typeof(CustomViewService)); idSvrFactory.CorsPolicyService = new Registration <ICorsPolicyService>(new DefaultCorsPolicyService { AllowAll = true }); List <LoginPageLink> loginPageLinks = new List <LoginPageLink>(); loginPageLinks.Add(new LoginPageLink { Href = "", Text = "Forgot Password ?", Type = "" }); loginPageLinks.Add(new LoginPageLink { Href = "", Text = "Not Registered ?", Type = "" }); var options = new IdentityServerOptions { SiteName = "Identity Server Name", IssuerUri = "https://localhost:44364/identity/.well-known/openid-configuration", //not required: this app url with openid spec SigningCertificate = LoadCertificate(), Factory = idSvrFactory, AuthenticationOptions = new AuthenticationOptions { IdentityProviders = ConfigureOAuthIdentityProviders, EnablePostSignOutAutoRedirect = true, EnableSignOutPrompt = false } }; core.UseIdentityServer(options); }); }
public void Configuration(IAppBuilder appBuilder) { Log.Logger = new LoggerConfiguration() .MinimumLevel.Debug() .WriteTo.Trace() .CreateLogger(); appBuilder.Map("/core", core => { var options = new IdentityServerOptions { SiteName = "IdentityServer3 (EntityFramework)", SigningCertificate = Certificate.Get(), Factory = Factory.Configure("IdSvr3Config") }; core.UseIdentityServer(options); }); }
public void Configuration(IAppBuilder app) { app.Map("/signalr", map => { // Cors gör att vi får stöd för CrossDomain-kommunikation! map.UseCors(CorsOptions.AllowAll); var hubConfiguration = new HubConfiguration { EnableDetailedErrors = true // You can enable JSONP by uncommenting line below. // JSONP requests are insecure but some older browsers (and some // versions of IE) require JSONP to work cross domain // EnableJSONP = true }; hubConfiguration.EnableDetailedErrors = true; map.RunSignalR(hubConfiguration); }); }
public void Configuration(IAppBuilder app) { string rootPath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot"); if (Directory.Exists(rootPath)) { app.UseStaticFiles(new StaticFileOptions() { FileSystem = new PhysicalFileSystem(rootPath), RequestPath = new PathString("/root") }); } var httpConfiguratin = new HttpConfiguration(); JsonSerializerSettings setting = new JsonSerializerSettings(); //日期类型默认格式化处理 setting.DateFormatHandling = DateFormatHandling.MicrosoftDateFormat; setting.DateFormatString = "yyyy-MM-dd HH:mm:ss.ffff"; setting.ContractResolver = new CamelCasePropertyNamesContractResolver(); // 将长整型数据转为字符串 // 否则id=1202054749357081610 会变成id = 1.2020547493570816E+18 setting.Converters.Add(new LongToString()); //空值处理 setting.NullValueHandling = NullValueHandling.Ignore; httpConfiguratin.Formatters.JsonFormatter.SerializerSettings = setting; httpConfiguratin.Routes.MapHttpRoute("default", "api/{controller}/{action}/{id}", defaults: new { id = RouteParameter.Optional }); httpConfiguratin.Filters.Add(new AuthFilterAttribute()); Framework.IocContainer.Builder(httpConfiguratin); app.UseAutofacWebApi(httpConfiguratin); app.UseWebApi(httpConfiguratin); //signalr app.Map("/wsc", map => { map.UseCors(CorsOptions.AllowAll); map.RunSignalR(new HubConfiguration()); }); }
public void Configuration(IAppBuilder app) { LogProvider.SetCurrentLogProvider(new DiagnosticsTraceLogProvider()); app.Map("/core", coreApp => { var factory = InMemoryFactory.Create( clients: Clients.Get(), scopes: Scopes.Get()); // different examples of custom user services var userService = new RegisterFirstExternalRegistrationUserService(); //var userService = new ExternalRegistrationUserService(); //var userService = new EulaAtLoginUserService(); //var userService = new LocalRegistrationUserService(); factory.UserService = Registration.RegisterFactory <IUserService>(() => userService); var options = new IdentityServerOptions { IssuerUri = "https://idsrv3.com", SiteName = "Thinktecture IdentityServer v3 - CustomUserService", SigningCertificate = Certificate.Get(), Factory = factory, CorsPolicy = CorsPolicy.AllowAll, AuthenticationOptions = new AuthenticationOptions { IdentityProviders = ConfigureAdditionalIdentityProviders, LoginPageLinks = new LoginPageLink[] { new LoginPageLink { Text = "Register", //Href = "~/localregistration" Href = "localregistration" } } } }; coreApp.UseIdentityServer(options); }); }
public void Configuration(IAppBuilder app) { log4net.Config.XmlConfigurator.Configure(); var certificate = CertLoader.LoadCertificate(); app.Map("/identity", idsrvApp => { idsrvApp.UseIdentityServer(new IdentityServerOptions { SiteName = ConfigManager.AppSettings["idsvr:siteName"], SigningCertificate = certificate, Factory = ServiceFactory.Build(), AuthenticationOptions = AuthenticationOptionsFactory.Build(), LoggingOptions = LoggingOptionsFactory.BuildLoggingOptions(), EventsOptions = LoggingOptionsFactory.BuildEventsOptions(), DataProtector = new X509CertificateDataProtector(certificate) }); }); }
public void Configuration(IAppBuilder app) { app.UseErrorPage(); app.Map("/signalr", map => { map.UseCors(_corsOptions.Value) .RunSignalR(new HubConfiguration { // Enable JSONP to support cross-domain from IE <10 but be aware it's less secure than CORS //EnableJSONP = true }); }); // Turn tracing on programmatically GlobalHost.TraceManager.Switch.Level = SourceLevels.Information; app.UseWelcomePage(); }
public void Configuration(IAppBuilder app) { var config = new HttpConfiguration(); WebApiConfig.Register(config); //app.MapSignalR(); app.Map("/signalr", map => { map.UseCors(CorsOptions.AllowAll); var hubConfiguration = new HubConfiguration(); map.RunSignalR(hubConfiguration); }); app.UseCors(CorsOptions.AllowAll); ConfigureAuth(app); app.UseWebApi(config); }
public void Configuration(IAppBuilder app) { var pathsToIgnore = new[] { "/authentication/**", "/authentication", }; app.Map("/api", site => { site.RequiresStatelessAuth(new SecureTokenValidator(ConfigurationManager.AppSettings["jwt_secret"]), new StatelessAuthOptions { IgnorePaths = pathsToIgnore, PassThroughUnauthorizedRequests = true }); site.UseNancy(); site.UseStageMarker(PipelineStage.MapHandler); }); }
/// <summary> /// Adds the <see cref="SamlAuthenticationMiddleware"/> into the OWIN runtime. /// </summary> /// <param name="app">The <see cref="IAppBuilder"/> passed to the configuration method</param> /// <param name="options">Saml2Configuration configuration options</param> /// <returns>The updated <see cref="IAppBuilder"/></returns> public static IAppBuilder UseSamlAuthentication(this IAppBuilder app, SamlAuthenticationOptions options) { if (app == null) { throw new ArgumentNullException(nameof(app)); } if (options == null) { throw new ArgumentNullException(nameof(options)); } SAML2.Logging.LoggerProvider.Configuration = SAML2.Logging.LoggerProvider.Configuration ?? options.Configuration; app.Map(options.MetadataPath, metadataapp => { metadataapp.Run(new SamlMetadataWriter(options.Configuration).WriteMetadataDocument); }); return(app.Use <SamlAuthenticationMiddleware>(app, options)); }
public void Configuration(IAppBuilder app) { ConfigureAuth(app); app.Map("/idm", idm => { var factory = new IdentityManagerServiceFactory(); factory.IdentityManagerService = new Registration <IIdentityManagerService, ApplicationIdentityMangaerService>(); factory.Register(new Registration <ApplicationUserManager>()); factory.Register(new Registration <ApplicationUserStore>()); factory.Register(new Registration <ApplicationRoleManager>()); factory.Register(new Registration <ApplicationRoleStore>()); factory.Register(new Registration <ApplicationDbContext>()); idm.UseIdentityManager(new IdentityManager.Configuration.IdentityManagerOptions { Factory = factory }); }); }
public void Configuration(IAppBuilder app) { Log.Logger = new LoggerConfiguration() .MinimumLevel.Verbose() .WriteTo.LiterateConsole() .CreateLogger(); Log.Information("Test Serilog message."); //.MinimumLevel.Debug() //.WriteTo.Trace() //.CreateLogger(); // Log.Logger = new LoggerConfiguration() //.MinimumLevel.Debug() //.WriteTo.LiterateConsole() //.CreateLogger(); //Log.Logger = new LoggerConfiguration() // .WriteTo // .Console(outputTemplate: "{Timestamp:HH:MM} [{Level}] ({Name:l}){NewLine} {Message}{NewLine}{Exception}") // .CreateLogger(); app.Map("/identity", idsrvApp => { var idServerServiceFactory = new IdentityServerServiceFactory() .UseInMemoryClients(Clients.Get()) .UseInMemoryScopes(Scopes.Get()) .UseInMemoryUsers(Users.Get()); var options = new IdentityServerOptions { Factory = idServerServiceFactory, SiteName = "Trip Company Security Token Service", IssuerUri = Constants.TripGalleryIssuerUri, PublicOrigin = Constants.TripGallerySTSOrigin, //SigningCertificate = Certificate.Load(), RequireSsl = false }; idsrvApp.UseIdentityServer(options); }); }
public virtual void UseWebApiOData(IAppBuilder owinApp, HttpServer server) { if (owinApp == null) { throw new ArgumentNullException(nameof(owinApp)); } if (server == null) { throw new ArgumentNullException(nameof(server)); } owinApp.Map("/api", innerApp => { innerApp.Use <AddAcceptCharsetToRequestHeadersIfNotAnyMiddleware>(); innerApp.UseXContentTypeOptions(); innerApp.UseWebApi(server); }); }
public void Configuration(IAppBuilder app) { var container = ContainerConfig.Container; string virtualPath = ConfigurationManager.AppSettings["virtualPathFolderName"] ?? string.Empty; app.Map(new PathString(""), webApiApp => { var webApiConfig = new HttpConfiguration() .ConfigureWebApi(container); webApiApp.Use(async(ctx, next) => { if (ctx.Request.Path.Value == "/") { ctx.Response.Redirect($"{virtualPath}/swagger/ui/index"); return; } await next(); }); webApiConfig .EnableSwagger(c => { c.RootUrl(req => SwaggerDocsConfig.DefaultRootUrlResolver(req) + virtualPath); c.SingleApiVersion("v1", ConfigurationManager.AppSettings.Get("ProductName")); var xmlPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"bin\Documentation.XML"); c.IncludeXmlComments(xmlPath); c.ResolveConflictingActions(x => x.First()); }) .EnableSwaggerUi(c => { c.EnableDiscoveryUrlSelector(); c.InjectJavaScript(typeof(ApiStartupConfig).Assembly, "Api.Setup.SwaggerExtensions.auth.js"); }); webApiApp.UseCors(CorsOptions.AllowAll); webApiApp.UseWebApi(webApiConfig); }); container.Resolve <ILogger>().Info("WebAPI Application started"); }