Hi,
I have implemented two factor auth on my Umbraco site but the Component for this seems to make the Umbraco backoffice useless. Can’t do anything that do changes to the database (Add/remove treenodes, doctypes and so on).
If I remove the Composer implementation of the Component everything seems to be ok.
Any help here would be really helpful.
My Component for the Two factor implementation:
public class AuthenticationComponent : IComponent
{
private readonly IUmbracoContextAccessor umbracoContextAccessor;
private readonly IRuntimeState runtimeState;
private readonly IUserService userService;
private readonly IGlobalSettings globalSettings;
private readonly ISecuritySection securitySection;
private readonly IEntityService entityService;
private readonly IExternalLoginService externalLoginService;
private readonly IMemberTypeService memberTypeService;
private readonly UmbracoMapper umbracoMapper;
public AuthenticationComponent(
IUmbracoContextAccessor umbracoContextAccessor,
IRuntimeState runtimeState,
IUserService userService,
IGlobalSettings globalSettings,
ISecuritySection securitySection,
IEntityService entityService,
IExternalLoginService externalLoginService,
IMemberTypeService memberTypeService,
UmbracoMapper umbracoMapper)
{
this.umbracoContextAccessor = umbracoContextAccessor;
this.runtimeState = runtimeState;
this.userService = userService;
this.globalSettings = globalSettings;
this.securitySection = securitySection;
this.entityService = entityService;
this.externalLoginService = externalLoginService;
this.memberTypeService = memberTypeService;
this.umbracoMapper = umbracoMapper;
}
public void Initialize()
{
UmbracoDefaultOwinStartup.MiddlewareConfigured += ConfigureTwoFactorAuthentication;
}
public void Terminate()
{
throw new NotImplementedException();
}
private void ConfigureTwoFactorAuthentication(object sender, OwinMiddlewareConfiguredEventArgs args)
{
var app = args.AppBuilder;
app.SetUmbracoLoggerFactory();
app.UseTwoFactorSignInCookie(Umbraco.Core.Constants.Security.BackOfficeTwoFactorAuthenticationType, TimeSpan.FromMinutes(5));
app.UseUmbracoBackOfficeCookieAuthentication(umbracoContextAccessor, runtimeState, userService, globalSettings, securitySection)
.UseUmbracoBackOfficeExternalCookieAuthentication(umbracoContextAccessor, runtimeState, globalSettings);
app.ConfigureUserManagerForUmbracoBackOffice<TwoFactorBackOfficeUserManager, BackOfficeIdentityUser>(runtimeState, globalSettings,
(options, context) =>
{
var membershipProvider = MembershipProviderExtensions.GetUsersMembershipProvider().AsUmbracoMembershipProvider();
var userManager = TwoFactorBackOfficeUserManager.Create(options,
userService,
entityService,
externalLoginService,
membershipProvider,
globalSettings,
umbracoMapper,
memberTypeService);
return userManager;
});
app.UseUmbracoPreviewAuthentication(umbracoContextAccessor, runtimeState, globalSettings, securitySection);
}
This is a companion discussion topic for the original entry at https://our.umbraco.com/forum/98440-cant-do-anything-in-umbraco-when-implementing-two-factor-authentication