예제 #1
0
 public void Configuration(Owin.IAppBuilder app)
 {
     app.UseErrorPage();
     app.UseLightNode(
         new LightNodeOptions(AcceptVerbs.Get | AcceptVerbs.Post,
                              new JavaScriptContentFormatter()));
 }
 public static IApplicationBuilder UseGraphQL(
     this IApplicationBuilder applicationBuilder,
     IServiceProvider serviceProvider)
 {
     return(applicationBuilder
            .UseGraphQL(serviceProvider, new QueryMiddlewareOptions()));
 }
        public static IApplicationBuilder UseGraphQL(
            this IApplicationBuilder applicationBuilder,
            IServiceProvider serviceProvider,
            QueryMiddlewareOptions options)
        {
            if (applicationBuilder == null)
            {
                throw new ArgumentNullException(nameof(applicationBuilder));
            }

            if (serviceProvider == null)
            {
                throw new ArgumentNullException(nameof(serviceProvider));
            }

            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            var executer = (IQueryExecuter)serviceProvider
                           .GetService(typeof(IQueryExecuter));

            return(applicationBuilder
                   .Use <PostQueryMiddleware>(executer, options)
                   .Use <GetQueryMiddleware>(executer, options));
            //.Use<SubscriptionMiddleware>(executer, options);
        }
예제 #4
0
        public void Configuration(Owin.IAppBuilder app)
        {
            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                LoginPath          = new Microsoft.Owin.PathString("/Account/SignIn")
            });

            app.CreatePerOwinContext(() =>
            {
                UserStore <IdentityUser> store     = new UserStore <IdentityUser>();
                UserManager <IdentityUser> manager = new UserManager <IdentityUser>(store);
                manager.UserTokenProvider          = new EmailTokenProvider <IdentityUser>();
                manager.PasswordValidator          = new PasswordValidator
                {
                    RequiredLength          = 4,
                    RequireDigit            = false,
                    RequireUppercase        = false,
                    RequireLowercase        = false,
                    RequireNonLetterOrDigit = false
                };
                manager.EmailService = new LawDoggsEmailService();

                return(manager);
            });
        }
예제 #5
0
        public static IAppBuilder UseMapDashboard <T>(
            this IAppBuilder app,
            string pathMatch       = "/dashboard",
            T options              = default(T),
            RouteCollection routes = null,
            IEnumerable <IDashboardAuthorizationFilter> authorization = null
            ) where T : class, new()
        {
            if (app == null)
            {
                throw new ArgumentNullException(nameof(app));
            }
            if (pathMatch == null)
            {
                throw new ArgumentNullException(nameof(pathMatch));
            }

#if !NETFULL
            var services = app.ApplicationServices;

            options       = options ?? services.GetService <T>() ?? new T();
            routes        = routes ?? services.GetRequiredService <RouteCollection>();
            authorization = authorization ?? services.GetServices <IDashboardAuthorizationFilter>();

            app.Map(new PathString(pathMatch), x => x.UseMiddleware <AspNetCoreFileManagerMiddleware <T> >(options, authorization, routes));
#else
            if (routes == null)
            {
                throw new ArgumentNullException(nameof(routes));
            }
            authorization = authorization ?? new IDashboardAuthorizationFilter[] { };
            app.Map(new PathString(pathMatch), x => x.Use <AspNetCoreFileManagerMiddlewareOwin <T> >(options, authorization, routes));
#endif
            return(app);
        }
예제 #6
0
 public void Configuration(Owin.IAppBuilder app)
 {
     ConfigureOAuth(app);
     //Rest of code is here;
     //app.CreatePerOwinContext<TurnKeyBrokerSignUpDataContext>(() => new TurnKeyBrokerSignUpDataContext());
     //app.CreatePerOwinContext<UserManager<Identity>>(CreateManager);
 }
예제 #7
0
        public void Configuration(Owin.IAppBuilder app)
        {
            // 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 Microsoft.AspNet.SignalR.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);
            });
        }
예제 #8
0
        public void Configuration(Owin.IAppBuilder app)
        {
            HttpConfiguration config = new HttpConfiguration();

            config.Routes.MapHttpRoute("htt", "{controller}/{action}");
            config.AddVersionedApiExplorer();
            app.UseWebApi(config);
        }
예제 #9
0
        private static void configureAuth(Owin.IAppBuilder app)
        {
            WebMarket.IocConfig.SampleObjectFactory.Container.Configure(config =>
            {
                config.For <Microsoft.Owin.Security.DataProtection.IDataProtectionProvider>()
                .HybridHttpOrThreadLocalScoped()
                .Use(() => app.GetDataProtectionProvider());
            });

            WebMarket.IocConfig.SampleObjectFactory.Container.GetInstance <WebMarket.ServiceLayer.Interfaces.IApplicationUserManager>().SeedDatabase();

            // 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 Microsoft.Owin.Security.Cookies.CookieAuthenticationOptions
            {
                AuthenticationType = Microsoft.AspNet.Identity.DefaultAuthenticationTypes.ApplicationCookie,
                LoginPath          = new Microsoft.Owin.PathString("/Account/Login"),
                Provider           = new Microsoft.Owin.Security.Cookies.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 = WebMarket.IocConfig.SampleObjectFactory.Container.GetInstance <WebMarket.ServiceLayer.Interfaces.IApplicationUserManager>().OnValidateIdentity()
                },
                CookieName = "Iris_Store",
            });

            app.UseExternalSignInCookie(Microsoft.AspNet.Identity.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(Microsoft.AspNet.Identity.DefaultAuthenticationTypes.TwoFactorCookie, System.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(Microsoft.AspNet.Identity.DefaultAuthenticationTypes.TwoFactorRememberBrowserCookie);

            app.CreatePerOwinContext(
                () => WebMarket.IocConfig.SampleObjectFactory.Container.GetInstance <WebMarket.ServiceLayer.Interfaces.IApplicationUserManager>());

            // Uncomment the following lines to enable logging in with third party login providers
            //app.UseMicrosoftAccountAuthentication(
            //    clientId: "",
            //    clientSecret: "");

            //app.UseTwitterAuthentication(
            //   consumerKey: "",
            //   consumerSecret: "");

            //app.UseFacebookAuthentication(
            //   appId: "",
            //   appSecret: "");

            //app.UseGoogleAuthentication(
            //    clientId: "",
            //    clientSecret: "");
        }
예제 #10
0
        // This code configures Web API. The Startup class is specified as a type
        // parameter in the WebApp.Start method.
        public void Configuration(Owin.IAppBuilder appBuilder)
        {
            // Configure Web API for self-host.
            HttpConfiguration config = new HttpConfiguration();

            MaintenanceService.WebApiConfig.Register(config);

            appBuilder.UseWebApi(config);
        }
예제 #11
0
        public static void GetConfiguration(Owin.IAppBuilder app)
        {
            HttpConfiguration config = new HttpConfiguration();

            config.Filters.Add(new ExceptionHandlingAttribute());
            config.Filters.Add(new ActionHandlingFilter());

            config.Services.Replace(typeof(IAssembliesResolver), new ExtendedDefaultAssembliesResolver());
            config.Routes.MapHttpRoute(
                name: "DefaultAPi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
                );

            //config.Formatters.JsonFormatter.UseDataContractJsonSerializer = true;
            //config.Formatters.Remove(config.Formatters.XmlFormatter);
            //config.Formatters.JsonFormatter.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore;

            config.Formatters.XmlFormatter.UseXmlSerializer = true;
            config.Formatters.Remove(config.Formatters.JsonFormatter);

            var builder = new ContainerBuilder();

            //builder.RegisterApiControllers(Assembly.GetExecutingAssembly());
            //var types = config.Services.GetAssembliesResolver().GetAssemblies().SelectMany(c => c.GetTypes());
            //var type = typeof(ApiController);
            //var list = types.Where(c => type.IsAssignableFrom(type) && c.IsClass && !c.IsAbstract);
            //builder.RegisterApiControllers(list.ToArray());

            //var assemblies = config.Services.GetAssembliesResolver().GetAssemblies();

            foreach (var item in config.Services.GetAssembliesResolver().GetAssemblies())
            {
                if (item.FullName.IndexOf(".Controller", StringComparison.OrdinalIgnoreCase) > -1)
                {
                    builder.RegisterApiControllers(item);
                }
            }

            //builder.RegisterApiControllers(config.Services.GetAssembliesResolver().GetAssemblies())
            builder.RegisterWebApiFilterProvider(config);
            //builder.RegisterType<CustomActionFilter>()
            //    .AsWebApiActionFilterFor<TestController>()
            //    .InstancePerRequest();
            builder.Register(c => new Logger()).As <ILogger>().InstancePerRequest();
            //builder.Register(c=>c.)


            // Create and assign a dependency resolver for Web API to use.
            var container = builder.Build();

            config.DependencyResolver = new AutofacWebApiDependencyResolver(container);
            app.UseAutofacMiddleware(container);
            app.UseAutofacWebApi(config);
            app.UseWebApi(config);
        }
예제 #12
0
        public void InitializeOwinStartup(Owin.IAppBuilder app)
        {
            HubConfiguration hubConfig = new HubConfiguration();

#if DEBUG
            hubConfig.EnableDetailedErrors = true;
#endif
            hubConfig.EnableJavaScriptProxies = false;
            app.MapSignalR(SignalR.SignalRUrl, hubConfig);
        }
 public static IApplicationBuilder UseGraphiQL(
     this IApplicationBuilder applicationBuilder,
     PathString queryPath)
 {
     return(applicationBuilder.UseGraphiQL(new GraphiQLOptions
     {
         QueryPath = queryPath,
         Path = queryPath + new PathString("/graphiql")
     }));
 }
 public static IApplicationBuilder UsePlayground(
     this IApplicationBuilder applicationBuilder,
     PathString queryPath)
 {
     return(applicationBuilder.UsePlayground(new PlaygroundOptions
     {
         QueryPath = queryPath,
         Path = queryPath + new PathString("/playground")
     }));
 }
 public void Configuration(Owin.IAppBuilder app)
 {
     //TODO: add stuff to "app" to set up login / authentication
     // Enable the application to use a cookie to store information for the signed in user
     app.UseCookieAuthentication(new CookieAuthenticationOptions
     {
         AuthenticationType = Microsoft.AspNet.Identity.DefaultAuthenticationTypes.ApplicationCookie,
         LoginPath          = new Microsoft.Owin.PathString("/Account/LogOn")
     });
 }
 public static IApplicationBuilder UseVoyager(
     this IApplicationBuilder applicationBuilder,
     PathString queryPath)
 {
     return(applicationBuilder.UseVoyager(new VoyagerOptions
     {
         QueryPath = queryPath,
         Path = queryPath + new PathString("/voyager")
     }));
 }
예제 #17
0
    public void Configuration(Owin.IAppBuilder host)
    {
        host.MapAndLog("/_ws/connect", (app) =>
        {
            app.Run((IOwinContext ctx) => { return(_Owin.CatchAll(ctx, System.Web.WebSocks.Connect)); });
        });

        UseAuth(host);
        UseGames(host);
        UseLogs(host);
    }
        public static IApplicationBuilder UseGraphQL(
            this IApplicationBuilder applicationBuilder,
            PathString path)
        {
            var options = new QueryMiddlewareOptions
            {
                Path = path.HasValue ? path : new PathString("/")
            };

            return(applicationBuilder
                   .UseGraphQL(options));
        }
        private static IApplicationBuilder UsePlaygroundSettingsMiddleware(
            this IApplicationBuilder applicationBuilder,
            PlaygroundOptions options)
        {
            return(applicationBuilder.Map(
                       options.Path.Add(new PathString("/settings.js")),
#if ASPNETCLASSIC
                       app => app.Use <SettingsMiddleware>(options)));
#else
                       app => app.UseMiddleware <SettingsMiddleware>(options));
#endif
        }
예제 #20
0
        public static IAppBuilder UseMapDashboard(
            this IAppBuilder app,
            string pathMatch = "/dashboard",
            System.Action <RouteCollection> routes = null,
            IEnumerable <IDashboardAuthorizationFilter> authorization = null
            )
        {
            var _routes = new AspNetCoreDashboard.Dashboard.RouteCollection();

            routes(_routes);
            return(UseMapDashboard(app, pathMatch, _routes, authorization));
        }
        public static IApplicationBuilder UsePlayground(
            this IApplicationBuilder applicationBuilder,
            PlaygroundOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            return(applicationBuilder
                   .UsePlaygroundSettingsMiddleware(options)
                   .UsePlaygroundFileServer(options.Path));
        }
예제 #22
0
        //private static UserManager<Identity> CreateManager(IdentityFactoryOptions<UserManager<IdentityUser>> options, IOwinContext context)
        //{
        //    var userStore = new UserStore<IdentityUser>(context.Get<System.Data.Linq.DataContext>());
        //    var owinManager = new UserManager<IdentityUser>(userStore);
        //    return owinManager;
        //}
        public void ConfigureOAuth(Owin.IAppBuilder app)
        {
            Microsoft.Owin.Security.OAuth.OAuthAuthorizationServerOptions OAuthOptions = new Microsoft.Owin.Security.OAuth.OAuthAuthorizationServerOptions()
            {
                AllowInsecureHttp         = true,
                TokenEndpointPath         = new PathString("/token"),
                AccessTokenExpireTimeSpan = TimeSpan.FromHours(8),
                Provider = new ApplicationOAuthProvider()
            };

            app.UseOAuthAuthorizationServer(OAuthOptions);
            app.UseOAuthBearerAuthentication(new OAuthBearerAuthenticationOptions());
        }
        public static IApplicationBuilder UseGraphiQL(
            this IApplicationBuilder applicationBuilder,
            GraphiQLOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            return(applicationBuilder
                   .UseGraphiQLSettingsMiddleware(options)
                   .UseGraphiQLFileServer(options.Path));
        }
예제 #24
0
 public void Configuration(Owin.IAppBuilder app)
 {
     app.Map("/api", builder =>
     {
         builder.UseLightNode(new LightNodeOptions(AcceptVerbs.Get | AcceptVerbs.Post, new JsonNetContentFormatter())
         {
             StreamWriteOption = StreamWriteOption.BufferAndWrite,
             ParameterEnumAllowsFieldNameParse = true,
             ErrorHandlingPolicy            = ErrorHandlingPolicy.ReturnInternalServerErrorIncludeErrorDetails,
             OperationMissingHandlingPolicy = OperationMissingHandlingPolicy.ReturnErrorStatusCodeIncludeErrorDetails,
         });
     });
 }
예제 #25
0
        public static IAppBuilder UseMapDashboard <T>(
            this IAppBuilder app,
            string pathMatch = "/dashboard",
            T options        = default(T),
            System.Action <RouteCollection> routes = null,
            IEnumerable <IDashboardAuthorizationFilter> authorization = null
            ) where T : class, new()
        {
            var _routes = new AspNetCoreDashboard.Dashboard.RouteCollection();

            routes(_routes);
            return(UseMapDashboard <T>(app, pathMatch, options, _routes, authorization));
        }
예제 #26
0
        public void Configuration(Owin.IAppBuilder app)
        {
            HttpConfiguration config = new HttpConfiguration();

            ConfigureOAuth(app);


            WebApiConfig.Register(config);
            app.UseCors(Microsoft.Owin.Cors.CorsOptions.AllowAll);

            config.DependencyResolver = new UnityDependencyResolver(UnityConfig.GetConfiguredContainer());

            app.UseWebApi(config);
        }
예제 #27
0
        public void Configuration(Owin.IAppBuilder app)
        {
            app.CreatePerOwinContext(() => new HeroModelDBContext());
            app.CreatePerOwinContext <AppUserManager>(AppUserManager.Create);
            app.CreatePerOwinContext <RoleManager <ApplicationRoles> >((options, context) =>
                                                                       new RoleManager <ApplicationRoles>(
                                                                           new RoleStore <ApplicationRoles>(context.Get <HeroModelDBContext>())));

            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                LoginPath          = new PathString("/Dashboard/Login"),
            });
        }
예제 #28
0
        public void Configuration(Owin.IAppBuilder app)
        {
            app.CreatePerOwinContext(() => new Models.SPM());
            app.CreatePerOwinContext <SPMUserManager>(SPMUserManager.Create);
            app.CreatePerOwinContext <RoleManager <SPMRole> >((options, context) =>
                                                              new RoleManager <SPMRole>(
                                                                  new RoleStore <SPMRole>(context.Get <MOE.Common.Models.SPM>())));

            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                LoginPath          = new PathString("/Home/Login"),
            });
        }
예제 #29
0
        public void Configuration(Owin.IAppBuilder app)
        {
            app.Map("/signalr", map =>
            {
                map.UseCors(CorsOptions.AllowAll);
                var hubConfiguration = new HubConfiguration
                {
                    EnableJSONP = true
                };

                hubConfiguration.EnableDetailedErrors = true;
                map.RunSignalR(hubConfiguration);
            });
        }
예제 #30
0
        public void Configuration(Owin.IAppBuilder app)
        {
            var container = ConfigureSimpleInjector(app);

            ConfigureOAuth(app, container);

            HttpConfiguration config = new HttpConfiguration
            {
                DependencyResolver = new SimpleInjectorWebApiDependencyResolver(container)
            };

            WebApiConfig.Register(config);
            app.UseCors(CorsOptions.AllowAll);
            app.UseWebApi(config);
        }