From ddeae3b5ba4ddc9a20fd61397d353036ae5ee75b Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Tue, 3 Apr 2018 15:59:58 -0400 Subject: [PATCH] add support for Duo Organization 2FA --- src/Android/Resources/Resource.Designer.cs | 33 ++++------------------ src/App/Enums/TwoFactorProviderType.cs | 3 +- src/App/Pages/LoginTwoFactorPage.cs | 31 ++++++++++++++++---- src/App/Resources/AppResources.Designer.cs | 9 ++++++ src/App/Resources/AppResources.resx | 4 +++ 5 files changed, 47 insertions(+), 33 deletions(-) diff --git a/src/Android/Resources/Resource.Designer.cs b/src/Android/Resources/Resource.Designer.cs index 81cb43c92..0b96097c2 100644 --- a/src/Android/Resources/Resource.Designer.cs +++ b/src/Android/Resources/Resource.Designer.cs @@ -6506,17 +6506,17 @@ namespace Bit.Android // aapt resource value: 0x7f0a0051 public const int ApplicationName = 2131361873; - // aapt resource value: 0x7f0a00b2 - public const int AutoFillServiceDescription = 2131361970; + // aapt resource value: 0x7f0a00ab + public const int AutoFillServiceDescription = 2131361963; - // aapt resource value: 0x7f0a00b1 - public const int AutoFillServiceSummary = 2131361969; + // aapt resource value: 0x7f0a00aa + public const int AutoFillServiceSummary = 2131361962; // aapt resource value: 0x7f0a0050 public const int Hello = 2131361872; - // aapt resource value: 0x7f0a00b3 - public const int MyVault = 2131361971; + // aapt resource value: 0x7f0a00ac + public const int MyVault = 2131361964; // aapt resource value: 0x7f0a0027 public const int abc_action_bar_home_description = 2131361831; @@ -6671,27 +6671,6 @@ namespace Bit.Android // aapt resource value: 0x7f0a000f public const int common_signin_button_text_long = 2131361807; - // aapt resource value: 0x7f0a00ac - public const int default_web_client_id = 2131361964; - - // aapt resource value: 0x7f0a00ad - public const int firebase_database_url = 2131361965; - - // aapt resource value: 0x7f0a00aa - public const int gcm_defaultSenderId = 2131361962; - - // aapt resource value: 0x7f0a00ae - public const int google_api_key = 2131361966; - - // aapt resource value: 0x7f0a00ab - public const int google_app_id = 2131361963; - - // aapt resource value: 0x7f0a00af - public const int google_crash_reporting_api_key = 2131361967; - - // aapt resource value: 0x7f0a00b0 - public const int google_storage_bucket = 2131361968; - // aapt resource value: 0x7f0a0052 public const int hockeyapp_crash_dialog_app_name_fallback = 2131361874; diff --git a/src/App/Enums/TwoFactorProviderType.cs b/src/App/Enums/TwoFactorProviderType.cs index 10a741a32..38798bdbf 100644 --- a/src/App/Enums/TwoFactorProviderType.cs +++ b/src/App/Enums/TwoFactorProviderType.cs @@ -7,6 +7,7 @@ Duo = 2, YubiKey = 3, U2f = 4, - Remember = 5 + Remember = 5, + OrganizationDuo = 6 } } diff --git a/src/App/Pages/LoginTwoFactorPage.cs b/src/App/Pages/LoginTwoFactorPage.cs index 606fb50e2..b5af0635d 100644 --- a/src/App/Pages/LoginTwoFactorPage.cs +++ b/src/App/Pages/LoginTwoFactorPage.cs @@ -31,10 +31,12 @@ namespace Bit.App.Pages private readonly Dictionary> _providers; private TwoFactorProviderType? _providerType; private readonly FullLoginResult _result; + private readonly string _duoOrgTitle; public LoginTwoFactorPage(string email, FullLoginResult result, TwoFactorProviderType? type = null) : base(updateActivity: false, requireAuth: false) { + _duoOrgTitle = $"Duo ({AppResources.Organization})"; _deviceInfoService = Resolver.Resolve(); _email = email; @@ -180,9 +182,10 @@ namespace Bit.App.Pages Content = scrollView; TokenCell.Entry.FocusWithDelay(); } - else if(_providerType == TwoFactorProviderType.Duo) + else if(_providerType == TwoFactorProviderType.Duo || + _providerType == TwoFactorProviderType.OrganizationDuo) { - var duoParams = _providers[TwoFactorProviderType.Duo]; + var duoParams = _providers[_providerType.Value]; var host = WebUtility.UrlEncode(duoParams["Host"].ToString()); var req = WebUtility.UrlEncode(duoParams["Signature"].ToString()); @@ -224,7 +227,7 @@ namespace Bit.App.Pages table.WrappingStackLayout = () => layout; scrollView.Content = layout; - Title = "Duo"; + Title = _providerType == TwoFactorProviderType.Duo ? "Duo" : _duoOrgTitle; Content = scrollView; } else if(_providerType == TwoFactorProviderType.YubiKey) @@ -312,6 +315,11 @@ namespace Bit.App.Pages var beforeProviderType = _providerType; var options = new List(); + if(_providers.ContainsKey(TwoFactorProviderType.OrganizationDuo)) + { + options.Add(_duoOrgTitle); + } + if(_providers.ContainsKey(TwoFactorProviderType.Authenticator)) { options.Add(AppResources.AuthenticatorAppTitle); @@ -349,6 +357,10 @@ namespace Bit.App.Pages { _providerType = TwoFactorProviderType.Duo; } + else if(selection == _duoOrgTitle) + { + _providerType = TwoFactorProviderType.OrganizationDuo; + } else if(selection == AppResources.YubiKeyTitle) { _providerType = TwoFactorProviderType.YubiKey; @@ -448,7 +460,8 @@ namespace Bit.App.Pages switch(p.Key) { case TwoFactorProviderType.Authenticator: - if(provider == TwoFactorProviderType.Duo || provider == TwoFactorProviderType.YubiKey) + if(provider == TwoFactorProviderType.Duo || provider == TwoFactorProviderType.YubiKey || + provider == TwoFactorProviderType.OrganizationDuo) { continue; } @@ -460,18 +473,26 @@ namespace Bit.App.Pages } break; case TwoFactorProviderType.Duo: - if(provider == TwoFactorProviderType.YubiKey) + if(provider == TwoFactorProviderType.YubiKey || + provider == TwoFactorProviderType.OrganizationDuo) { continue; } break; case TwoFactorProviderType.YubiKey: + if(provider == TwoFactorProviderType.OrganizationDuo) + { + continue; + } + var nfcKey = p.Value.ContainsKey("Nfc") && (bool)p.Value["Nfc"]; if((!_deviceInfoService.NfcEnabled || !nfcKey) && Device.RuntimePlatform != Device.UWP) { continue; } break; + case TwoFactorProviderType.OrganizationDuo: + break; default: continue; } diff --git a/src/App/Resources/AppResources.Designer.cs b/src/App/Resources/AppResources.Designer.cs index 2f419a5ad..b8266c157 100644 --- a/src/App/Resources/AppResources.Designer.cs +++ b/src/App/Resources/AppResources.Designer.cs @@ -2364,6 +2364,15 @@ namespace Bit.App.Resources { } } + /// + /// Looks up a localized string similar to Organization. + /// + public static string Organization { + get { + return ResourceManager.GetString("Organization", resourceCulture); + } + } + /// /// Looks up a localized string similar to Other. /// diff --git a/src/App/Resources/AppResources.resx b/src/App/Resources/AppResources.resx index 514690cc1..c2631f29c 100644 --- a/src/App/Resources/AppResources.resx +++ b/src/App/Resources/AppResources.resx @@ -1289,4 +1289,8 @@ Auto-fill and save + + Organization + An entity of multiple related people (ex. a team or business organization). + \ No newline at end of file