public List <TwoFactorProvider> GetSupportedTwoFactorProviders() { var providers = new List <TwoFactorProvider>(); if (TwoFactorProvidersData == null) { return(providers); } if (TwoFactorProvidersData.ContainsKey(TwoFactorProviderType.OrganizationDuo) && _platformUtilsService.SupportsDuo()) { providers.Add(TwoFactorProviders[TwoFactorProviderType.OrganizationDuo]); } if (TwoFactorProvidersData.ContainsKey(TwoFactorProviderType.Authenticator)) { providers.Add(TwoFactorProviders[TwoFactorProviderType.Authenticator]); } if (TwoFactorProvidersData.ContainsKey(TwoFactorProviderType.YubiKey)) { providers.Add(TwoFactorProviders[TwoFactorProviderType.YubiKey]); } if (TwoFactorProvidersData.ContainsKey(TwoFactorProviderType.Duo) && _platformUtilsService.SupportsDuo()) { providers.Add(TwoFactorProviders[TwoFactorProviderType.Duo]); } if (TwoFactorProvidersData.ContainsKey(TwoFactorProviderType.U2f) && _platformUtilsService.SupportsU2f()) { providers.Add(TwoFactorProviders[TwoFactorProviderType.U2f]); } if (TwoFactorProvidersData.ContainsKey(TwoFactorProviderType.Email)) { providers.Add(TwoFactorProviders[TwoFactorProviderType.Email]); } return(providers); }
public TwoFactorProviderType?GetDefaultTwoFactorProvider(bool u2fSupported) { if (TwoFactorProvidersData == null) { return(null); } if (SelectedTwoFactorProviderType != null && TwoFactorProvidersData.ContainsKey(SelectedTwoFactorProviderType.Value)) { return(SelectedTwoFactorProviderType.Value); } TwoFactorProviderType?providerType = null; var providerPriority = -1; foreach (var providerKvp in TwoFactorProvidersData) { if (TwoFactorProviders.ContainsKey(providerKvp.Key)) { var provider = TwoFactorProviders[providerKvp.Key]; if (provider.Priority > providerPriority) { if (providerKvp.Key == TwoFactorProviderType.U2f && !u2fSupported) { continue; } providerType = providerKvp.Key; providerPriority = provider.Priority; } } } return(providerType); }
public List <TwoFactorProvider> GetSupportedTwoFactorProviders() { var providers = new List <TwoFactorProvider>(); if (TwoFactorProvidersData == null) { return(providers); } if (TwoFactorProvidersData.ContainsKey(TwoFactorProviderType.OrganizationDuo) && _platformUtilsService.SupportsDuo()) { providers.Add(TwoFactorProviders[TwoFactorProviderType.OrganizationDuo]); } if (TwoFactorProvidersData.ContainsKey(TwoFactorProviderType.Authenticator)) { providers.Add(TwoFactorProviders[TwoFactorProviderType.Authenticator]); } if (TwoFactorProvidersData.ContainsKey(TwoFactorProviderType.YubiKey)) { providers.Add(TwoFactorProviders[TwoFactorProviderType.YubiKey]); } if (TwoFactorProvidersData.ContainsKey(TwoFactorProviderType.Duo) && _platformUtilsService.SupportsDuo()) { providers.Add(TwoFactorProviders[TwoFactorProviderType.Duo]); } if (TwoFactorProvidersData.ContainsKey(TwoFactorProviderType.U2f) && _platformUtilsService.SupportsU2f()) { providers.Add(TwoFactorProviders[TwoFactorProviderType.U2f]); } if (TwoFactorProvidersData.ContainsKey(TwoFactorProviderType.Fido2) && _platformUtilsService.SupportsFido2()) { // add FIDO2 to the allowed two-factor if is supported and if exists on the user account providers.Add(TwoFactorProviders[TwoFactorProviderType.Fido2]); } if (TwoFactorProvidersData.ContainsKey(TwoFactorProviderType.Email)) { providers.Add(TwoFactorProviders[TwoFactorProviderType.Email]); } return(providers); }