Ejemplo n.º 1
0
        /// <summary>
        /// Creates the kernel that will manage your application.
        /// </summary>
        /// <returns>The created kernel.</returns>
        private static IKernel CreateKernel()
        {
            var kernel = NinjectResolver.BuildKernel();

            try
            {
                kernel.Bind <Func <IKernel> >().ToMethod(ctx => () => new Bootstrapper().Kernel);
                kernel.Bind <IHttpModule>().To <HttpApplicationInitializationHttpModule>();

                RegisterServices(kernel);
                return(kernel);
            }
            catch
            {
                kernel.Dispose();
                throw;
            }
        }
Ejemplo n.º 2
0
        internal static void ConfigureIdentityServer(IAppBuilder app)
        {
            _kernel = NinjectResolver.BuildKernel();

            var userService = _kernel.Get <IUserService>();
            var scopeStore  = _kernel.Get <IScopeStore>();
            var clientStore = _kernel.Get <IClientStore>();

            var factory = new IdentityServerServiceFactory
            {
                ScopeStore        = new Registration <IScopeStore>(scopeStore),
                ClientStore       = new Registration <IClientStore>(clientStore),
                UserService       = new Registration <IUserService>(userService),
                CorsPolicyService = new Registration <ICorsPolicyService>(new DefaultCorsPolicyService
                {
                    AllowAll = true,
                })
            };

            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));

            app.Map("/core", idsrvApp =>
            {
                idsrvApp.UseIdentityServer(new IdentityServerOptions
                {
                    Factory            = factory,
                    SigningCertificate = LoadCertificate(),
                    SiteName           = "Photograph.IdentityServer",
                    RequireSsl         = false
                });
            });
        }