public SessionController( ILoggerFactory loggerFactory, IUserRepository userRepository, ICtfConfigurationLoader ctfConfigurationLoader, UserPreviewRepository userPreviewRepository, OAuthProviderSelector oAuthSelector, JwtHandler jwt, ActionTokenPairHandler actionTokenPairHandler, PasswordHandler pwdHandler, IOAuthStateRepository oAuthStateRepository, IMfaStateRepository mfaStateRepository, LoginSettingsRepository loginSettingsRepository, MfaValidatorService mfaValidator, IMfaRepository mfaRepository) : base(loggerFactory, userRepository, userPreviewRepository, ctfConfigurationLoader) { this.OAuthSelector = oAuthSelector; this.Jwt = jwt; this.ActionTokenPairHandler = actionTokenPairHandler; this.Password = pwdHandler; this.OAuthStateRepository = oAuthStateRepository; this.MfaStateRepository = mfaStateRepository; this.LoginSettingsRepository = loginSettingsRepository; this.MfaValidator = mfaValidator; this.MfaRepository = mfaRepository; }
public async Task <IMultiFactorSettings> GenerateMfaAsync(IMfaRepository mfaRepository, long userId, bool generateAdditional, CancellationToken cancellationToken = default) { var recbase = 0L; using (var rng = new SecureRandom()) recbase = rng.GetInt64(); var totp = TotpGeneratorSettings.GenerateGoogleAuthenticator(null, null); return(await mfaRepository.ConfigureMfaAsync(userId, totp.Secret.ToArray(), totp.Digits, (MultiFactorHmac)totp.Algorithm, totp.Period, MultiFactorType.Google, null, recbase, cancellationToken)); }