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