mirror of
https://github.com/bitwarden/server
synced 2025-12-20 02:03:46 +00:00
organization 2fa apis
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
using Bit.Core.Models.Table;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace Bit.Core.Models.Api
|
||||
@@ -76,6 +75,32 @@ namespace Bit.Core.Models.Api
|
||||
return extistingUser;
|
||||
}
|
||||
|
||||
public Organization ToOrganization(Organization extistingOrg)
|
||||
{
|
||||
var providers = extistingOrg.GetTwoFactorProviders();
|
||||
if(providers == null)
|
||||
{
|
||||
providers = new Dictionary<TwoFactorProviderType, TwoFactorProvider>();
|
||||
}
|
||||
else if(providers.ContainsKey(TwoFactorProviderType.OrganizationDuo))
|
||||
{
|
||||
providers.Remove(TwoFactorProviderType.OrganizationDuo);
|
||||
}
|
||||
|
||||
providers.Add(TwoFactorProviderType.OrganizationDuo, new TwoFactorProvider
|
||||
{
|
||||
MetaData = new Dictionary<string, object>
|
||||
{
|
||||
["SKey"] = SecretKey,
|
||||
["IKey"] = IntegrationKey,
|
||||
["Host"] = Host
|
||||
},
|
||||
Enabled = true
|
||||
});
|
||||
extistingOrg.SetTwoFactorProviders(providers);
|
||||
return extistingOrg;
|
||||
}
|
||||
|
||||
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
|
||||
{
|
||||
if(!Host.StartsWith("api-") || !Host.EndsWith(".duosecurity.com") || Host.Count(s => s == '.') != 2)
|
||||
@@ -214,7 +239,7 @@ namespace Bit.Core.Models.Api
|
||||
public class TwoFactorProviderRequestModel : TwoFactorRequestModel
|
||||
{
|
||||
[Required]
|
||||
public Enums.TwoFactorProviderType? Type { get; set; }
|
||||
public TwoFactorProviderType? Type { get; set; }
|
||||
}
|
||||
|
||||
public class TwoFactorRequestModel
|
||||
|
||||
Reference in New Issue
Block a user