mirror of
https://github.com/bitwarden/mobile
synced 2025-12-28 14:13:25 +00:00
add support for Duo Organization 2FA
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
Duo = 2,
|
||||
YubiKey = 3,
|
||||
U2f = 4,
|
||||
Remember = 5
|
||||
Remember = 5,
|
||||
OrganizationDuo = 6
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,10 +31,12 @@ namespace Bit.App.Pages
|
||||
private readonly Dictionary<TwoFactorProviderType, Dictionary<string, object>> _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<IDeviceInfoService>();
|
||||
|
||||
_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<string>();
|
||||
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;
|
||||
}
|
||||
|
||||
9
src/App/Resources/AppResources.Designer.cs
generated
9
src/App/Resources/AppResources.Designer.cs
generated
@@ -2364,6 +2364,15 @@ namespace Bit.App.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Organization.
|
||||
/// </summary>
|
||||
public static string Organization {
|
||||
get {
|
||||
return ResourceManager.GetString("Organization", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Other.
|
||||
/// </summary>
|
||||
|
||||
@@ -1289,4 +1289,8 @@
|
||||
<data name="AutofillAndSave" xml:space="preserve">
|
||||
<value>Auto-fill and save</value>
|
||||
</data>
|
||||
<data name="Organization" xml:space="preserve">
|
||||
<value>Organization</value>
|
||||
<comment>An entity of multiple related people (ex. a team or business organization).</comment>
|
||||
</data>
|
||||
</root>
|
||||
Reference in New Issue
Block a user