public void Configure(IAppBuilder builder, IOwinHostingContext context)
        {
            // Домен для создания cookie
            var cookieDomain = _settings.CookieDomain;

            // Шифрование данных по умолчанию (работает также в Linux/Mono)
            builder.SetDataProtectionProvider(new AesDataProtectionProvider());

            // Разрешение использования cookie для входа в систему через внутренний провайдер

            var cookieAuthOptions = new CookieAuthenticationOptions
            {
                AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                LoginPath          = new PathString("/Auth/SignInInternal"),
                LogoutPath         = new PathString("/Auth/SignOut"),
                ExpireTimeSpan     = TimeSpan.FromDays(1),
                SlidingExpiration  = true
            };

            if (!string.IsNullOrWhiteSpace(cookieDomain))
            {
                cookieAuthOptions.CookieDomain = cookieDomain;
            }

            if (Uri.UriSchemeHttps.Equals(context.Configuration.Scheme, StringComparison.OrdinalIgnoreCase))
            {
                cookieAuthOptions.CookieSecure = CookieSecureOption.Always;
            }

            builder.UseCookieAuthentication(cookieAuthOptions);

            // Разрешение использования cookie для входа в систему через внешние провайдеры
            builder.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);
        }
 public void Configure(IAppBuilder builder, IOwinHostingContext context)
 {
     builder.UseNancy(new NancyOptions
     {
         Bootstrapper = _nancyBootstrapper
     });
 }
        public void Configure(IAppBuilder builder, IOwinHostingContext context)
        {
            var config = new HubConfiguration
            {
                EnableDetailedErrors = true,
                Resolver             = SignalRGlobalHost.Resolver
            };

            builder.MapSignalR(config);
        }
Esempio n. 4
0
 public void Configure(IAppBuilder builder, IOwinHostingContext context)
 {
     if (_settings.Enable)
     {
         builder.UseVkontakteAuthentication(new VkAuthenticationOptions
         {
             AppId     = _settings.ClientId,
             AppSecret = _settings.ClientSecret
         });
     }
 }
Esempio n. 5
0
 public void Configure(IAppBuilder builder, IOwinHostingContext context)
 {
     if (_settings.Enable)
     {
         builder.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions
         {
             ClientId     = _settings.ClientId,
             ClientSecret = _settings.ClientSecret
         });
     }
 }
Esempio n. 6
0
        public void Configure(IAppBuilder builder, IOwinHostingContext context)
        {
            // Регистрация метода для создания менеджера управления пользователями
            builder.CreatePerOwinContext(() => context.ContainerResolver.Resolve <UserManager <IdentityApplicationUser> >());

            // Прослойка для установки информации об идентификационных данных текущего пользователя
            builder.Use((owinContext, nextOwinMiddleware) =>
            {
                UserIdentityProvider.SetRequestUser(owinContext.Request.User);
                return(nextOwinMiddleware.Invoke());
            });
        }
 public void Configure(IAppBuilder builder, IOwinHostingContext context)
 {
     if (_settings.Enable)
     {
         builder.UseWsFederationAuthentication(new WsFederationAuthenticationOptions
         {
             Caption            = WsFederationAuthenticationDefaults.Caption,
             AuthenticationType = WsFederationAuthenticationDefaults.AuthenticationType,
             AuthenticationMode = AuthenticationMode.Passive,
             MetadataAddress    = string.Format(MetadataUri, _settings.Server),
             Wtrealm            = _settings.ResourceUri
         });
     }
 }
        public OwinHostingServiceFactory(IOwinHostingContext hostingContext)
        {
            // Создание сервиса хостинга приложения на базе OWIN
            var hostingService = new OwinHostingService(hostingContext);

            // Получение списка обработчиков событий приложения
            var appEventHandlers = hostingContext.ContainerResolver.Resolve <IEnumerable <IApplicationEventHandler> >();

            if (appEventHandlers != null)
            {
                hostingService.OnBeforeStart += (s, e) => InvokeAppHandlers(appEventHandlers, h => h.OnBeforeStart());
                hostingService.OnAfterStart  += (s, e) => InvokeAppHandlers(appEventHandlers, h => h.OnAfterStart());
                hostingService.OnBeforeStop  += (s, e) => InvokeAppHandlers(appEventHandlers, h => h.OnBeforeStop());
                hostingService.OnAfterStop   += (s, e) => InvokeAppHandlers(appEventHandlers, h => h.OnAfterStop());
            }

            _hostingService = hostingService;
        }
Esempio n. 9
0
        /// <summary>
        /// Конструктор.
        /// </summary>
        /// <param name="hostingContext">Контекст подсистемы хостинга на базе OWIN.</param>
        /// <exception cref="ArgumentNullException"></exception>
        /// <exception cref="ArgumentOutOfRangeException"></exception>
        public OwinHostingService(IOwinHostingContext hostingContext)
        {
            if (hostingContext == null)
            {
                throw new ArgumentNullException(nameof(hostingContext));
            }

            // Проверка наличия конфигурации

            if (hostingContext.Configuration == null)
            {
                throw new ArgumentNullException(Resources.ServerConfigurationCannotBeNull);
            }

            // Имя схемы протокола сервера

            var scheme = hostingContext.Configuration.Scheme;

            if (string.IsNullOrWhiteSpace(scheme))
            {
                throw new ArgumentNullException(Resources.ServerSchemeCannotBeNullOrWhiteSpace);
            }

            if (!Uri.UriSchemeHttp.Equals(scheme, StringComparison.OrdinalIgnoreCase) &&
                !Uri.UriSchemeHttps.Equals(scheme, StringComparison.OrdinalIgnoreCase))
            {
                throw new ArgumentOutOfRangeException(string.Format(Resources.ServerSchemeIsNotSupported, scheme));
            }

            // Адрес или имя сервера

            var server = hostingContext.Configuration.Name;

            if (string.IsNullOrWhiteSpace(server))
            {
                throw new ArgumentNullException(Resources.ServerNameCannotBeNullOrWhiteSpace);
            }

            if (!server.IsLocalAddress(out server))
            {
                throw new ArgumentOutOfRangeException(string.Format(Resources.ServerNameIsNotLocal, server));
            }

            // Номер порта сервера

            var port = hostingContext.Configuration.Port;

            if (port <= 0)
            {
                throw new ArgumentOutOfRangeException(string.Format(Resources.ServerPortIsIncorrect, port));
            }

            // Отпечаток сертификата

            var certificate = hostingContext.Configuration.Certificate;

            if (Uri.UriSchemeHttps.Equals(scheme, StringComparison.OrdinalIgnoreCase) && string.IsNullOrWhiteSpace(certificate))
            {
                throw new ArgumentNullException(Resources.ServerCertificateCannotBeNullOrWhiteSpace);
            }


            _hostingContext = hostingContext;

            _baseAddress    = $"{scheme}://{server}:{port}/";
            _hostingModules = hostingContext.ContainerResolver.Resolve <IEnumerable <IOwinHostingModule> >().OrderBy(m => m.ModuleType);
        }
 public void Configure(IAppBuilder builder, IOwinHostingContext context)
 {
     builder.Use(typeof(FakeOwinHandler));
 }
 public void Configure(IAppBuilder builder, IOwinHostingContext context)
 {
     builder.Use(typeof(AutofacRequestLifetimeScopeOwinMiddleware), _container);
 }
 public void Configure(IAppBuilder builder, IOwinHostingContext context)
 {
     builder.Use(context.OwinMiddlewareResolver.ResolveType <ErrorHandlingOwinMiddleware>());
 }
        public void Configure(IAppBuilder builder, IOwinHostingContext context)
        {
            // TODO: Добавить правила CORS проверки из конфигурации

            builder.UseCors(CorsOptions.AllowAll);
        }