private void ConfigureTwoFactorAuthentication(object sender, OwinMiddlewareConfiguredEventArgs args) { var app = args.AppBuilder; var applicationContext = ApplicationContext.Current; app.SetUmbracoLoggerFactory(); app.UseTwoFactorSignInCookie(Umbraco.Core.Constants.Security.BackOfficeTwoFactorAuthenticationType, TimeSpan.FromMinutes(5)); // We need to set these values again after our custom changes. Otherwise preview doesn't work. app.UseUmbracoBackOfficeCookieAuthentication(applicationContext) .UseUmbracoBackOfficeExternalCookieAuthentication(applicationContext) .UseUmbracoPreviewAuthentication(applicationContext); app.ConfigureUserManagerForUmbracoBackOffice <TwoFactorBackOfficeUserManager, BackOfficeIdentityUser>( applicationContext, (options, context) => { var membershipProvider = MembershipProviderExtensions.GetUsersMembershipProvider().AsUmbracoMembershipProvider(); var userManager = TwoFactorBackOfficeUserManager.Create(options, applicationContext.Services.UserService, applicationContext.Services.EntityService, applicationContext.Services.ExternalLoginService, membershipProvider); return(userManager); }); }
private void UmbracoDefaultOwinStartup_MiddlewareConfigured(object sender, OwinMiddlewareConfiguredEventArgs e) { StartHangfireServer(e.AppBuilder); // Raise event for use by hangfire jobs OnHangfireStarted(new HangfireStartedArgs(e.AppBuilder)); }
/// <summary> /// Setups the owin middleware. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="OwinMiddlewareConfiguredEventArgs"/> instance containing the event data.</param> private void SetupOwinMiddleware(object sender, OwinMiddlewareConfiguredEventArgs e) { GlobalConfiguration.Configuration.UseActivator(this.umbracoJobActivator); e.AppBuilder.UseHangfireDashboard("/hangfire", new DashboardOptions { Authorization = new[] { new UmbracoAuthorizationFilter() }, }); e.AppBuilder.UseHangfireServer(); }
private void ConfigureTwoFactorAuthentication(object sender, OwinMiddlewareConfiguredEventArgs args) { var app = args.AppBuilder; var applicationContext = Umbraco.Core.Composing.Current.Services; IGlobalSettings GlobalSettings = Umbraco.Core.Composing.Current.Configs.Global(); IUmbracoSettingsSection UmbracoSettings = Umbraco.Core.Composing.Current.Configs.Settings(); UmbracoMapper umbracoMapper = Umbraco.Core.Composing.Current.Mapper; //netser///////////////////////// /* var oAuthServerOptions = new OAuthAuthorizationServerOptions * * { * AllowInsecureHttp = true, * TokenEndpointPath = new PathString("/token"), * AccessTokenExpireTimeSpan = TimeSpan.FromDays(1) * }; * // Token Generation * app.UseOAuthAuthorizationServer(oAuthServerOptions); * app.UseOAuthBearerAuthentication(new OAuthBearerAuthenticationOptions());*/ ////////////////////end netser app.SetUmbracoLoggerFactory(); app.UseTwoFactorSignInCookie(Umbraco.Core.Constants.Security.BackOfficeTwoFactorAuthenticationType, TimeSpan.FromMinutes(5)); // app.UseOAuthAuthorizationServer(options); // app.UseOAuthBearerAuthentication(new OAuthBearerAuthenticationOptions()); // We need to set these values again after our custom changes. Otherwise preview doesn't work. // Gunni: Apparently we don't need this for preview to work and the following code breaks other Identity providers //app.UseUmbracoBackOfficeCookieAuthentication(umbracoContextAccessor, Umbraco.Web.Composing.Current.RuntimeState, applicationContext.UserService, GlobalSettings, securitySection) // .UseUmbracoBackOfficeExternalCookieAuthentication(umbracoContextAccessor, runtimeState, GlobalSettings) // .UseUmbracoPreviewAuthentication(umbracoContextAccessor, runtimeState, globalSettings, securitySection); app.ConfigureUserManagerForUmbracoBackOffice <TwoFactorBackOfficeUserManager, BackOfficeIdentityUser>( Umbraco.Web.Composing.Current.RuntimeState, GlobalSettings, (options, context) => { var membershipProvider = MembershipProviderExtensions.GetUsersMembershipProvider().AsUmbracoMembershipProvider(); var userManager = TwoFactorBackOfficeUserManager.Create(options, applicationContext.UserService, applicationContext.MemberTypeService, applicationContext.EntityService, applicationContext.ExternalLoginService, membershipProvider, GlobalSettings, umbracoMapper); return(userManager); }); }
private void ConfigureActiveDirectoryMiddleware(object sender, OwinMiddlewareConfiguredEventArgs args) { var app = args.AppBuilder; app.AuthenticateFrontEndWithActiveDirectory(_clientId, _redirectUrl, _tenantId, _openIdAuthorizeUrl); app.UseUmbracoBackOfficeCookieAuthentication(_umbracoContextAccessor, _runtimeState, _userService, _globalSettings, _securitySection, PipelineStage.Authenticate) .UseUmbracoBackOfficeExternalCookieAuthentication(_umbracoContextAccessor, _runtimeState, _globalSettings, PipelineStage.Authenticate); app.ConfigureBackOfficeAzureActiveDirectoryAuth( tenant: _tenantId, clientId: _clientId, postLoginRedirectUri: _redirectUrl, issuerId: new Guid(_tenantId)); app.UseUmbracoPreviewAuthentication(_umbracoContextAccessor, _runtimeState, _globalSettings, _securitySection, PipelineStage.PostAuthenticate); }
private void ConfigureTwoFactorAuthentication(object sender, OwinMiddlewareConfiguredEventArgs args) { var app = args.AppBuilder; var applicationContext = ApplicationContext.Current; //netser///////////////////////// /* var oAuthServerOptions = new OAuthAuthorizationServerOptions * * { * AllowInsecureHttp = true, * TokenEndpointPath = new PathString("/token"), * AccessTokenExpireTimeSpan = TimeSpan.FromDays(1) * }; * // Token Generation * app.UseOAuthAuthorizationServer(oAuthServerOptions); * app.UseOAuthBearerAuthentication(new OAuthBearerAuthenticationOptions());*/ ////////////////////end netser app.SetUmbracoLoggerFactory(); app.UseTwoFactorSignInCookie(Umbraco.Core.Constants.Security.BackOfficeTwoFactorAuthenticationType, TimeSpan.FromMinutes(5)); // app.UseOAuthAuthorizationServer(options); // app.UseOAuthBearerAuthentication(new OAuthBearerAuthenticationOptions()); // We need to set these values again after our custom changes. Otherwise preview doesn't work. app.UseUmbracoBackOfficeCookieAuthentication(applicationContext) .UseUmbracoBackOfficeExternalCookieAuthentication(applicationContext) .UseUmbracoPreviewAuthentication(applicationContext); /**/ app.ConfigureUserManagerForUmbracoBackOffice <TwoFactorBackOfficeUserManager, BackOfficeIdentityUser>( applicationContext, (options, context) => { var membershipProvider = MembershipProviderExtensions.GetUsersMembershipProvider().AsUmbracoMembershipProvider(); var userManager = TwoFactorBackOfficeUserManager.Create(options, applicationContext.Services.UserService, applicationContext.Services.EntityService, applicationContext.Services.ExternalLoginService, membershipProvider); return(userManager); }); }
private void UmbracoDefaultOwinStartup_MiddlewareConfigured(object sender, OwinMiddlewareConfiguredEventArgs e) => Configure(e.AppBuilder);