mirror of
https://github.com/bitwarden/server.git
synced 2025-07-05 18:12:48 -05:00
Revert filescoped (#2227)
* Revert "Add git blame entry (#2226)" This reverts commit239286737d
. * Revert "Turn on file scoped namespaces (#2225)" This reverts commit34fb4cca2a
.
This commit is contained in:
@ -1,32 +1,33 @@
|
||||
using Bit.Core.Entities;
|
||||
using Bit.Core.Models.Api;
|
||||
|
||||
namespace Bit.Api.Models.Response;
|
||||
|
||||
public class ApiKeyResponseModel : ResponseModel
|
||||
namespace Bit.Api.Models.Response
|
||||
{
|
||||
public ApiKeyResponseModel(OrganizationApiKey organizationApiKey, string obj = "apiKey")
|
||||
: base(obj)
|
||||
public class ApiKeyResponseModel : ResponseModel
|
||||
{
|
||||
if (organizationApiKey == null)
|
||||
public ApiKeyResponseModel(OrganizationApiKey organizationApiKey, string obj = "apiKey")
|
||||
: base(obj)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(organizationApiKey));
|
||||
if (organizationApiKey == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(organizationApiKey));
|
||||
}
|
||||
ApiKey = organizationApiKey.ApiKey;
|
||||
RevisionDate = organizationApiKey.RevisionDate;
|
||||
}
|
||||
ApiKey = organizationApiKey.ApiKey;
|
||||
RevisionDate = organizationApiKey.RevisionDate;
|
||||
}
|
||||
|
||||
public ApiKeyResponseModel(User user, string obj = "apiKey")
|
||||
: base(obj)
|
||||
{
|
||||
if (user == null)
|
||||
public ApiKeyResponseModel(User user, string obj = "apiKey")
|
||||
: base(obj)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(user));
|
||||
if (user == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(user));
|
||||
}
|
||||
ApiKey = user.ApiKey;
|
||||
RevisionDate = user.RevisionDate;
|
||||
}
|
||||
ApiKey = user.ApiKey;
|
||||
RevisionDate = user.RevisionDate;
|
||||
}
|
||||
|
||||
public string ApiKey { get; set; }
|
||||
public DateTime RevisionDate { get; set; }
|
||||
public string ApiKey { get; set; }
|
||||
public DateTime RevisionDate { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -5,48 +5,49 @@ using Bit.Core.Models.Data;
|
||||
using Bit.Core.Settings;
|
||||
using Bit.Core.Utilities;
|
||||
|
||||
namespace Bit.Api.Models.Response;
|
||||
|
||||
public class AttachmentResponseModel : ResponseModel
|
||||
namespace Bit.Api.Models.Response
|
||||
{
|
||||
public AttachmentResponseModel(AttachmentResponseData data) : base("attachment")
|
||||
public class AttachmentResponseModel : ResponseModel
|
||||
{
|
||||
Id = data.Id;
|
||||
Url = data.Url;
|
||||
FileName = data.Data.FileName;
|
||||
Key = data.Data.Key;
|
||||
Size = data.Data.Size;
|
||||
SizeName = CoreHelpers.ReadableBytesSize(data.Data.Size);
|
||||
}
|
||||
|
||||
public AttachmentResponseModel(string id, CipherAttachment.MetaData data, Cipher cipher,
|
||||
IGlobalSettings globalSettings)
|
||||
: base("attachment")
|
||||
{
|
||||
Id = id;
|
||||
Url = $"{globalSettings.Attachment.BaseUrl}/{cipher.Id}/{id}";
|
||||
FileName = data.FileName;
|
||||
Key = data.Key;
|
||||
Size = data.Size;
|
||||
SizeName = CoreHelpers.ReadableBytesSize(data.Size);
|
||||
}
|
||||
|
||||
public string Id { get; set; }
|
||||
public string Url { get; set; }
|
||||
public string FileName { get; set; }
|
||||
public string Key { get; set; }
|
||||
[JsonNumberHandling(JsonNumberHandling.AllowReadingFromString | JsonNumberHandling.WriteAsString)]
|
||||
public long Size { get; set; }
|
||||
public string SizeName { get; set; }
|
||||
|
||||
public static IEnumerable<AttachmentResponseModel> FromCipher(Cipher cipher, IGlobalSettings globalSettings)
|
||||
{
|
||||
var attachments = cipher.GetAttachments();
|
||||
if (attachments == null)
|
||||
public AttachmentResponseModel(AttachmentResponseData data) : base("attachment")
|
||||
{
|
||||
return null;
|
||||
Id = data.Id;
|
||||
Url = data.Url;
|
||||
FileName = data.Data.FileName;
|
||||
Key = data.Data.Key;
|
||||
Size = data.Data.Size;
|
||||
SizeName = CoreHelpers.ReadableBytesSize(data.Data.Size);
|
||||
}
|
||||
|
||||
return attachments.Select(a => new AttachmentResponseModel(a.Key, a.Value, cipher, globalSettings));
|
||||
public AttachmentResponseModel(string id, CipherAttachment.MetaData data, Cipher cipher,
|
||||
IGlobalSettings globalSettings)
|
||||
: base("attachment")
|
||||
{
|
||||
Id = id;
|
||||
Url = $"{globalSettings.Attachment.BaseUrl}/{cipher.Id}/{id}";
|
||||
FileName = data.FileName;
|
||||
Key = data.Key;
|
||||
Size = data.Size;
|
||||
SizeName = CoreHelpers.ReadableBytesSize(data.Size);
|
||||
}
|
||||
|
||||
public string Id { get; set; }
|
||||
public string Url { get; set; }
|
||||
public string FileName { get; set; }
|
||||
public string Key { get; set; }
|
||||
[JsonNumberHandling(JsonNumberHandling.AllowReadingFromString | JsonNumberHandling.WriteAsString)]
|
||||
public long Size { get; set; }
|
||||
public string SizeName { get; set; }
|
||||
|
||||
public static IEnumerable<AttachmentResponseModel> FromCipher(Cipher cipher, IGlobalSettings globalSettings)
|
||||
{
|
||||
var attachments = cipher.GetAttachments();
|
||||
if (attachments == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return attachments.Select(a => new AttachmentResponseModel(a.Key, a.Value, cipher, globalSettings));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,16 @@
|
||||
using Bit.Core.Enums;
|
||||
using Bit.Core.Models.Api;
|
||||
|
||||
namespace Bit.Api.Models.Response;
|
||||
|
||||
public class AttachmentUploadDataResponseModel : ResponseModel
|
||||
namespace Bit.Api.Models.Response
|
||||
{
|
||||
public string AttachmentId { get; set; }
|
||||
public string Url { get; set; }
|
||||
public FileUploadType FileUploadType { get; set; }
|
||||
public CipherResponseModel CipherResponse { get; set; }
|
||||
public CipherMiniResponseModel CipherMiniResponse { get; set; }
|
||||
public class AttachmentUploadDataResponseModel : ResponseModel
|
||||
{
|
||||
public string AttachmentId { get; set; }
|
||||
public string Url { get; set; }
|
||||
public FileUploadType FileUploadType { get; set; }
|
||||
public CipherResponseModel CipherResponse { get; set; }
|
||||
public CipherMiniResponseModel CipherMiniResponse { get; set; }
|
||||
|
||||
public AttachmentUploadDataResponseModel() : base("attachment-fileUpload") { }
|
||||
public AttachmentUploadDataResponseModel() : base("attachment-fileUpload") { }
|
||||
}
|
||||
}
|
||||
|
@ -1,16 +1,17 @@
|
||||
using Bit.Core.Models.Api;
|
||||
using Bit.Core.Models.Business;
|
||||
|
||||
namespace Bit.Api.Models.Response;
|
||||
|
||||
public class BillingHistoryResponseModel : ResponseModel
|
||||
namespace Bit.Api.Models.Response
|
||||
{
|
||||
public BillingHistoryResponseModel(BillingInfo billing)
|
||||
: base("billingHistory")
|
||||
public class BillingHistoryResponseModel : ResponseModel
|
||||
{
|
||||
Transactions = billing.Transactions?.Select(t => new BillingTransaction(t));
|
||||
Invoices = billing.Invoices?.Select(i => new BillingInvoice(i));
|
||||
public BillingHistoryResponseModel(BillingInfo billing)
|
||||
: base("billingHistory")
|
||||
{
|
||||
Transactions = billing.Transactions?.Select(t => new BillingTransaction(t));
|
||||
Invoices = billing.Invoices?.Select(i => new BillingInvoice(i));
|
||||
}
|
||||
public IEnumerable<BillingInvoice> Invoices { get; set; }
|
||||
public IEnumerable<BillingTransaction> Transactions { get; set; }
|
||||
}
|
||||
public IEnumerable<BillingInvoice> Invoices { get; set; }
|
||||
public IEnumerable<BillingTransaction> Transactions { get; set; }
|
||||
}
|
||||
|
@ -1,17 +1,18 @@
|
||||
using Bit.Core.Models.Api;
|
||||
using Bit.Core.Models.Business;
|
||||
|
||||
namespace Bit.Api.Models.Response;
|
||||
|
||||
public class BillingPaymentResponseModel : ResponseModel
|
||||
namespace Bit.Api.Models.Response
|
||||
{
|
||||
public BillingPaymentResponseModel(BillingInfo billing)
|
||||
: base("billingPayment")
|
||||
public class BillingPaymentResponseModel : ResponseModel
|
||||
{
|
||||
Balance = billing.Balance;
|
||||
PaymentSource = billing.PaymentSource != null ? new BillingSource(billing.PaymentSource) : null;
|
||||
}
|
||||
public BillingPaymentResponseModel(BillingInfo billing)
|
||||
: base("billingPayment")
|
||||
{
|
||||
Balance = billing.Balance;
|
||||
PaymentSource = billing.PaymentSource != null ? new BillingSource(billing.PaymentSource) : null;
|
||||
}
|
||||
|
||||
public decimal Balance { get; set; }
|
||||
public BillingSource PaymentSource { get; set; }
|
||||
public decimal Balance { get; set; }
|
||||
public BillingSource PaymentSource { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -2,81 +2,82 @@
|
||||
using Bit.Core.Models.Api;
|
||||
using Bit.Core.Models.Business;
|
||||
|
||||
namespace Bit.Api.Models.Response;
|
||||
|
||||
public class BillingResponseModel : ResponseModel
|
||||
namespace Bit.Api.Models.Response
|
||||
{
|
||||
public BillingResponseModel(BillingInfo billing)
|
||||
: base("billing")
|
||||
public class BillingResponseModel : ResponseModel
|
||||
{
|
||||
Balance = billing.Balance;
|
||||
PaymentSource = billing.PaymentSource != null ? new BillingSource(billing.PaymentSource) : null;
|
||||
Transactions = billing.Transactions?.Select(t => new BillingTransaction(t));
|
||||
Invoices = billing.Invoices?.Select(i => new BillingInvoice(i));
|
||||
public BillingResponseModel(BillingInfo billing)
|
||||
: base("billing")
|
||||
{
|
||||
Balance = billing.Balance;
|
||||
PaymentSource = billing.PaymentSource != null ? new BillingSource(billing.PaymentSource) : null;
|
||||
Transactions = billing.Transactions?.Select(t => new BillingTransaction(t));
|
||||
Invoices = billing.Invoices?.Select(i => new BillingInvoice(i));
|
||||
}
|
||||
|
||||
public decimal Balance { get; set; }
|
||||
public BillingSource PaymentSource { get; set; }
|
||||
public IEnumerable<BillingInvoice> Invoices { get; set; }
|
||||
public IEnumerable<BillingTransaction> Transactions { get; set; }
|
||||
}
|
||||
|
||||
public decimal Balance { get; set; }
|
||||
public BillingSource PaymentSource { get; set; }
|
||||
public IEnumerable<BillingInvoice> Invoices { get; set; }
|
||||
public IEnumerable<BillingTransaction> Transactions { get; set; }
|
||||
}
|
||||
|
||||
public class BillingSource
|
||||
{
|
||||
public BillingSource(BillingInfo.BillingSource source)
|
||||
public class BillingSource
|
||||
{
|
||||
Type = source.Type;
|
||||
CardBrand = source.CardBrand;
|
||||
Description = source.Description;
|
||||
NeedsVerification = source.NeedsVerification;
|
||||
public BillingSource(BillingInfo.BillingSource source)
|
||||
{
|
||||
Type = source.Type;
|
||||
CardBrand = source.CardBrand;
|
||||
Description = source.Description;
|
||||
NeedsVerification = source.NeedsVerification;
|
||||
}
|
||||
|
||||
public PaymentMethodType Type { get; set; }
|
||||
public string CardBrand { get; set; }
|
||||
public string Description { get; set; }
|
||||
public bool NeedsVerification { get; set; }
|
||||
}
|
||||
|
||||
public PaymentMethodType Type { get; set; }
|
||||
public string CardBrand { get; set; }
|
||||
public string Description { get; set; }
|
||||
public bool NeedsVerification { get; set; }
|
||||
}
|
||||
|
||||
public class BillingInvoice
|
||||
{
|
||||
public BillingInvoice(BillingInfo.BillingInvoice inv)
|
||||
public class BillingInvoice
|
||||
{
|
||||
Amount = inv.Amount;
|
||||
Date = inv.Date;
|
||||
Url = inv.Url;
|
||||
PdfUrl = inv.PdfUrl;
|
||||
Number = inv.Number;
|
||||
Paid = inv.Paid;
|
||||
public BillingInvoice(BillingInfo.BillingInvoice inv)
|
||||
{
|
||||
Amount = inv.Amount;
|
||||
Date = inv.Date;
|
||||
Url = inv.Url;
|
||||
PdfUrl = inv.PdfUrl;
|
||||
Number = inv.Number;
|
||||
Paid = inv.Paid;
|
||||
}
|
||||
|
||||
public decimal Amount { get; set; }
|
||||
public DateTime? Date { get; set; }
|
||||
public string Url { get; set; }
|
||||
public string PdfUrl { get; set; }
|
||||
public string Number { get; set; }
|
||||
public bool Paid { get; set; }
|
||||
}
|
||||
|
||||
public decimal Amount { get; set; }
|
||||
public DateTime? Date { get; set; }
|
||||
public string Url { get; set; }
|
||||
public string PdfUrl { get; set; }
|
||||
public string Number { get; set; }
|
||||
public bool Paid { get; set; }
|
||||
}
|
||||
|
||||
public class BillingTransaction
|
||||
{
|
||||
public BillingTransaction(BillingInfo.BillingTransaction transaction)
|
||||
public class BillingTransaction
|
||||
{
|
||||
CreatedDate = transaction.CreatedDate;
|
||||
Amount = transaction.Amount;
|
||||
Refunded = transaction.Refunded;
|
||||
RefundedAmount = transaction.RefundedAmount;
|
||||
PartiallyRefunded = transaction.PartiallyRefunded;
|
||||
Type = transaction.Type;
|
||||
PaymentMethodType = transaction.PaymentMethodType;
|
||||
Details = transaction.Details;
|
||||
}
|
||||
public BillingTransaction(BillingInfo.BillingTransaction transaction)
|
||||
{
|
||||
CreatedDate = transaction.CreatedDate;
|
||||
Amount = transaction.Amount;
|
||||
Refunded = transaction.Refunded;
|
||||
RefundedAmount = transaction.RefundedAmount;
|
||||
PartiallyRefunded = transaction.PartiallyRefunded;
|
||||
Type = transaction.Type;
|
||||
PaymentMethodType = transaction.PaymentMethodType;
|
||||
Details = transaction.Details;
|
||||
}
|
||||
|
||||
public DateTime CreatedDate { get; set; }
|
||||
public decimal Amount { get; set; }
|
||||
public bool? Refunded { get; set; }
|
||||
public bool? PartiallyRefunded { get; set; }
|
||||
public decimal? RefundedAmount { get; set; }
|
||||
public TransactionType Type { get; set; }
|
||||
public PaymentMethodType? PaymentMethodType { get; set; }
|
||||
public string Details { get; set; }
|
||||
public DateTime CreatedDate { get; set; }
|
||||
public decimal Amount { get; set; }
|
||||
public bool? Refunded { get; set; }
|
||||
public bool? PartiallyRefunded { get; set; }
|
||||
public decimal? RefundedAmount { get; set; }
|
||||
public TransactionType Type { get; set; }
|
||||
public PaymentMethodType? PaymentMethodType { get; set; }
|
||||
public string Details { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -6,141 +6,142 @@ using Bit.Core.Models.Data;
|
||||
using Bit.Core.Settings;
|
||||
using Core.Models.Data;
|
||||
|
||||
namespace Bit.Api.Models.Response;
|
||||
|
||||
public class CipherMiniResponseModel : ResponseModel
|
||||
namespace Bit.Api.Models.Response
|
||||
{
|
||||
public CipherMiniResponseModel(Cipher cipher, IGlobalSettings globalSettings, bool orgUseTotp, string obj = "cipherMini")
|
||||
: base(obj)
|
||||
public class CipherMiniResponseModel : ResponseModel
|
||||
{
|
||||
if (cipher == null)
|
||||
public CipherMiniResponseModel(Cipher cipher, IGlobalSettings globalSettings, bool orgUseTotp, string obj = "cipherMini")
|
||||
: base(obj)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(cipher));
|
||||
if (cipher == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(cipher));
|
||||
}
|
||||
|
||||
Id = cipher.Id.ToString();
|
||||
Type = cipher.Type;
|
||||
|
||||
CipherData cipherData;
|
||||
switch (cipher.Type)
|
||||
{
|
||||
case CipherType.Login:
|
||||
var loginData = JsonSerializer.Deserialize<CipherLoginData>(cipher.Data);
|
||||
cipherData = loginData;
|
||||
Data = loginData;
|
||||
Login = new CipherLoginModel(loginData);
|
||||
break;
|
||||
case CipherType.SecureNote:
|
||||
var secureNoteData = JsonSerializer.Deserialize<CipherSecureNoteData>(cipher.Data);
|
||||
Data = secureNoteData;
|
||||
cipherData = secureNoteData;
|
||||
SecureNote = new CipherSecureNoteModel(secureNoteData);
|
||||
break;
|
||||
case CipherType.Card:
|
||||
var cardData = JsonSerializer.Deserialize<CipherCardData>(cipher.Data);
|
||||
Data = cardData;
|
||||
cipherData = cardData;
|
||||
Card = new CipherCardModel(cardData);
|
||||
break;
|
||||
case CipherType.Identity:
|
||||
var identityData = JsonSerializer.Deserialize<CipherIdentityData>(cipher.Data);
|
||||
Data = identityData;
|
||||
cipherData = identityData;
|
||||
Identity = new CipherIdentityModel(identityData);
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentException("Unsupported " + nameof(Type) + ".");
|
||||
}
|
||||
|
||||
Name = cipherData.Name;
|
||||
Notes = cipherData.Notes;
|
||||
Fields = cipherData.Fields?.Select(f => new CipherFieldModel(f));
|
||||
PasswordHistory = cipherData.PasswordHistory?.Select(ph => new CipherPasswordHistoryModel(ph));
|
||||
RevisionDate = cipher.RevisionDate;
|
||||
OrganizationId = cipher.OrganizationId?.ToString();
|
||||
Attachments = AttachmentResponseModel.FromCipher(cipher, globalSettings);
|
||||
OrganizationUseTotp = orgUseTotp;
|
||||
DeletedDate = cipher.DeletedDate;
|
||||
Reprompt = cipher.Reprompt.GetValueOrDefault(CipherRepromptType.None);
|
||||
}
|
||||
|
||||
Id = cipher.Id.ToString();
|
||||
Type = cipher.Type;
|
||||
|
||||
CipherData cipherData;
|
||||
switch (cipher.Type)
|
||||
{
|
||||
case CipherType.Login:
|
||||
var loginData = JsonSerializer.Deserialize<CipherLoginData>(cipher.Data);
|
||||
cipherData = loginData;
|
||||
Data = loginData;
|
||||
Login = new CipherLoginModel(loginData);
|
||||
break;
|
||||
case CipherType.SecureNote:
|
||||
var secureNoteData = JsonSerializer.Deserialize<CipherSecureNoteData>(cipher.Data);
|
||||
Data = secureNoteData;
|
||||
cipherData = secureNoteData;
|
||||
SecureNote = new CipherSecureNoteModel(secureNoteData);
|
||||
break;
|
||||
case CipherType.Card:
|
||||
var cardData = JsonSerializer.Deserialize<CipherCardData>(cipher.Data);
|
||||
Data = cardData;
|
||||
cipherData = cardData;
|
||||
Card = new CipherCardModel(cardData);
|
||||
break;
|
||||
case CipherType.Identity:
|
||||
var identityData = JsonSerializer.Deserialize<CipherIdentityData>(cipher.Data);
|
||||
Data = identityData;
|
||||
cipherData = identityData;
|
||||
Identity = new CipherIdentityModel(identityData);
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentException("Unsupported " + nameof(Type) + ".");
|
||||
}
|
||||
|
||||
Name = cipherData.Name;
|
||||
Notes = cipherData.Notes;
|
||||
Fields = cipherData.Fields?.Select(f => new CipherFieldModel(f));
|
||||
PasswordHistory = cipherData.PasswordHistory?.Select(ph => new CipherPasswordHistoryModel(ph));
|
||||
RevisionDate = cipher.RevisionDate;
|
||||
OrganizationId = cipher.OrganizationId?.ToString();
|
||||
Attachments = AttachmentResponseModel.FromCipher(cipher, globalSettings);
|
||||
OrganizationUseTotp = orgUseTotp;
|
||||
DeletedDate = cipher.DeletedDate;
|
||||
Reprompt = cipher.Reprompt.GetValueOrDefault(CipherRepromptType.None);
|
||||
public string Id { get; set; }
|
||||
public string OrganizationId { get; set; }
|
||||
public CipherType Type { get; set; }
|
||||
public dynamic Data { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Notes { get; set; }
|
||||
public CipherLoginModel Login { get; set; }
|
||||
public CipherCardModel Card { get; set; }
|
||||
public CipherIdentityModel Identity { get; set; }
|
||||
public CipherSecureNoteModel SecureNote { get; set; }
|
||||
public IEnumerable<CipherFieldModel> Fields { get; set; }
|
||||
public IEnumerable<CipherPasswordHistoryModel> PasswordHistory { get; set; }
|
||||
public IEnumerable<AttachmentResponseModel> Attachments { get; set; }
|
||||
public bool OrganizationUseTotp { get; set; }
|
||||
public DateTime RevisionDate { get; set; }
|
||||
public DateTime? DeletedDate { get; set; }
|
||||
public CipherRepromptType Reprompt { get; set; }
|
||||
}
|
||||
|
||||
public string Id { get; set; }
|
||||
public string OrganizationId { get; set; }
|
||||
public CipherType Type { get; set; }
|
||||
public dynamic Data { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Notes { get; set; }
|
||||
public CipherLoginModel Login { get; set; }
|
||||
public CipherCardModel Card { get; set; }
|
||||
public CipherIdentityModel Identity { get; set; }
|
||||
public CipherSecureNoteModel SecureNote { get; set; }
|
||||
public IEnumerable<CipherFieldModel> Fields { get; set; }
|
||||
public IEnumerable<CipherPasswordHistoryModel> PasswordHistory { get; set; }
|
||||
public IEnumerable<AttachmentResponseModel> Attachments { get; set; }
|
||||
public bool OrganizationUseTotp { get; set; }
|
||||
public DateTime RevisionDate { get; set; }
|
||||
public DateTime? DeletedDate { get; set; }
|
||||
public CipherRepromptType Reprompt { get; set; }
|
||||
}
|
||||
|
||||
public class CipherResponseModel : CipherMiniResponseModel
|
||||
{
|
||||
public CipherResponseModel(CipherDetails cipher, IGlobalSettings globalSettings, string obj = "cipher")
|
||||
: base(cipher, globalSettings, cipher.OrganizationUseTotp, obj)
|
||||
{
|
||||
FolderId = cipher.FolderId?.ToString();
|
||||
Favorite = cipher.Favorite;
|
||||
Edit = cipher.Edit;
|
||||
ViewPassword = cipher.ViewPassword;
|
||||
}
|
||||
|
||||
public string FolderId { get; set; }
|
||||
public bool Favorite { get; set; }
|
||||
public bool Edit { get; set; }
|
||||
public bool ViewPassword { get; set; }
|
||||
}
|
||||
|
||||
public class CipherDetailsResponseModel : CipherResponseModel
|
||||
{
|
||||
public CipherDetailsResponseModel(CipherDetails cipher, GlobalSettings globalSettings,
|
||||
IDictionary<Guid, IGrouping<Guid, CollectionCipher>> collectionCiphers, string obj = "cipherDetails")
|
||||
: base(cipher, globalSettings, obj)
|
||||
{
|
||||
if (collectionCiphers?.ContainsKey(cipher.Id) ?? false)
|
||||
{
|
||||
CollectionIds = collectionCiphers[cipher.Id].Select(c => c.CollectionId);
|
||||
}
|
||||
else
|
||||
{
|
||||
CollectionIds = new Guid[] { };
|
||||
}
|
||||
}
|
||||
|
||||
public CipherDetailsResponseModel(CipherDetails cipher, GlobalSettings globalSettings,
|
||||
IEnumerable<CollectionCipher> collectionCiphers, string obj = "cipherDetails")
|
||||
: base(cipher, globalSettings, obj)
|
||||
{
|
||||
CollectionIds = collectionCiphers?.Select(c => c.CollectionId) ?? new List<Guid>();
|
||||
}
|
||||
|
||||
public IEnumerable<Guid> CollectionIds { get; set; }
|
||||
}
|
||||
|
||||
public class CipherMiniDetailsResponseModel : CipherMiniResponseModel
|
||||
{
|
||||
public CipherMiniDetailsResponseModel(Cipher cipher, GlobalSettings globalSettings,
|
||||
IDictionary<Guid, IGrouping<Guid, CollectionCipher>> collectionCiphers, bool orgUseTotp, string obj = "cipherMiniDetails")
|
||||
: base(cipher, globalSettings, orgUseTotp, obj)
|
||||
{
|
||||
if (collectionCiphers?.ContainsKey(cipher.Id) ?? false)
|
||||
{
|
||||
CollectionIds = collectionCiphers[cipher.Id].Select(c => c.CollectionId);
|
||||
}
|
||||
else
|
||||
{
|
||||
CollectionIds = new Guid[] { };
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<Guid> CollectionIds { get; set; }
|
||||
public class CipherResponseModel : CipherMiniResponseModel
|
||||
{
|
||||
public CipherResponseModel(CipherDetails cipher, IGlobalSettings globalSettings, string obj = "cipher")
|
||||
: base(cipher, globalSettings, cipher.OrganizationUseTotp, obj)
|
||||
{
|
||||
FolderId = cipher.FolderId?.ToString();
|
||||
Favorite = cipher.Favorite;
|
||||
Edit = cipher.Edit;
|
||||
ViewPassword = cipher.ViewPassword;
|
||||
}
|
||||
|
||||
public string FolderId { get; set; }
|
||||
public bool Favorite { get; set; }
|
||||
public bool Edit { get; set; }
|
||||
public bool ViewPassword { get; set; }
|
||||
}
|
||||
|
||||
public class CipherDetailsResponseModel : CipherResponseModel
|
||||
{
|
||||
public CipherDetailsResponseModel(CipherDetails cipher, GlobalSettings globalSettings,
|
||||
IDictionary<Guid, IGrouping<Guid, CollectionCipher>> collectionCiphers, string obj = "cipherDetails")
|
||||
: base(cipher, globalSettings, obj)
|
||||
{
|
||||
if (collectionCiphers?.ContainsKey(cipher.Id) ?? false)
|
||||
{
|
||||
CollectionIds = collectionCiphers[cipher.Id].Select(c => c.CollectionId);
|
||||
}
|
||||
else
|
||||
{
|
||||
CollectionIds = new Guid[] { };
|
||||
}
|
||||
}
|
||||
|
||||
public CipherDetailsResponseModel(CipherDetails cipher, GlobalSettings globalSettings,
|
||||
IEnumerable<CollectionCipher> collectionCiphers, string obj = "cipherDetails")
|
||||
: base(cipher, globalSettings, obj)
|
||||
{
|
||||
CollectionIds = collectionCiphers?.Select(c => c.CollectionId) ?? new List<Guid>();
|
||||
}
|
||||
|
||||
public IEnumerable<Guid> CollectionIds { get; set; }
|
||||
}
|
||||
|
||||
public class CipherMiniDetailsResponseModel : CipherMiniResponseModel
|
||||
{
|
||||
public CipherMiniDetailsResponseModel(Cipher cipher, GlobalSettings globalSettings,
|
||||
IDictionary<Guid, IGrouping<Guid, CollectionCipher>> collectionCiphers, bool orgUseTotp, string obj = "cipherMiniDetails")
|
||||
: base(cipher, globalSettings, orgUseTotp, obj)
|
||||
{
|
||||
if (collectionCiphers?.ContainsKey(cipher.Id) ?? false)
|
||||
{
|
||||
CollectionIds = collectionCiphers[cipher.Id].Select(c => c.CollectionId);
|
||||
}
|
||||
else
|
||||
{
|
||||
CollectionIds = new Guid[] { };
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<Guid> CollectionIds { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -2,50 +2,51 @@
|
||||
using Bit.Core.Models.Api;
|
||||
using Bit.Core.Models.Data;
|
||||
|
||||
namespace Bit.Api.Models.Response;
|
||||
|
||||
public class CollectionResponseModel : ResponseModel
|
||||
namespace Bit.Api.Models.Response
|
||||
{
|
||||
public CollectionResponseModel(Collection collection, string obj = "collection")
|
||||
: base(obj)
|
||||
public class CollectionResponseModel : ResponseModel
|
||||
{
|
||||
if (collection == null)
|
||||
public CollectionResponseModel(Collection collection, string obj = "collection")
|
||||
: base(obj)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(collection));
|
||||
if (collection == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(collection));
|
||||
}
|
||||
|
||||
Id = collection.Id.ToString();
|
||||
OrganizationId = collection.OrganizationId.ToString();
|
||||
Name = collection.Name;
|
||||
ExternalId = collection.ExternalId;
|
||||
}
|
||||
|
||||
Id = collection.Id.ToString();
|
||||
OrganizationId = collection.OrganizationId.ToString();
|
||||
Name = collection.Name;
|
||||
ExternalId = collection.ExternalId;
|
||||
public string Id { get; set; }
|
||||
public string OrganizationId { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string ExternalId { get; set; }
|
||||
}
|
||||
|
||||
public string Id { get; set; }
|
||||
public string OrganizationId { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string ExternalId { get; set; }
|
||||
}
|
||||
|
||||
public class CollectionDetailsResponseModel : CollectionResponseModel
|
||||
{
|
||||
public CollectionDetailsResponseModel(CollectionDetails collectionDetails)
|
||||
: base(collectionDetails, "collectionDetails")
|
||||
public class CollectionDetailsResponseModel : CollectionResponseModel
|
||||
{
|
||||
ReadOnly = collectionDetails.ReadOnly;
|
||||
HidePasswords = collectionDetails.HidePasswords;
|
||||
public CollectionDetailsResponseModel(CollectionDetails collectionDetails)
|
||||
: base(collectionDetails, "collectionDetails")
|
||||
{
|
||||
ReadOnly = collectionDetails.ReadOnly;
|
||||
HidePasswords = collectionDetails.HidePasswords;
|
||||
}
|
||||
|
||||
public bool ReadOnly { get; set; }
|
||||
public bool HidePasswords { get; set; }
|
||||
}
|
||||
|
||||
public bool ReadOnly { get; set; }
|
||||
public bool HidePasswords { get; set; }
|
||||
}
|
||||
|
||||
public class CollectionGroupDetailsResponseModel : CollectionResponseModel
|
||||
{
|
||||
public CollectionGroupDetailsResponseModel(Collection collection, IEnumerable<SelectionReadOnly> groups)
|
||||
: base(collection, "collectionGroupDetails")
|
||||
public class CollectionGroupDetailsResponseModel : CollectionResponseModel
|
||||
{
|
||||
Groups = groups.Select(g => new SelectionReadOnlyResponseModel(g));
|
||||
}
|
||||
public CollectionGroupDetailsResponseModel(Collection collection, IEnumerable<SelectionReadOnly> groups)
|
||||
: base(collection, "collectionGroupDetails")
|
||||
{
|
||||
Groups = groups.Select(g => new SelectionReadOnlyResponseModel(g));
|
||||
}
|
||||
|
||||
public IEnumerable<SelectionReadOnlyResponseModel> Groups { get; set; }
|
||||
public IEnumerable<SelectionReadOnlyResponseModel> Groups { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -2,28 +2,29 @@
|
||||
using Bit.Core.Enums;
|
||||
using Bit.Core.Models.Api;
|
||||
|
||||
namespace Bit.Api.Models.Response;
|
||||
|
||||
public class DeviceResponseModel : ResponseModel
|
||||
namespace Bit.Api.Models.Response
|
||||
{
|
||||
public DeviceResponseModel(Device device)
|
||||
: base("device")
|
||||
public class DeviceResponseModel : ResponseModel
|
||||
{
|
||||
if (device == null)
|
||||
public DeviceResponseModel(Device device)
|
||||
: base("device")
|
||||
{
|
||||
throw new ArgumentNullException(nameof(device));
|
||||
if (device == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(device));
|
||||
}
|
||||
|
||||
Id = device.Id.ToString();
|
||||
Name = device.Name;
|
||||
Type = device.Type;
|
||||
Identifier = device.Identifier;
|
||||
CreationDate = device.CreationDate;
|
||||
}
|
||||
|
||||
Id = device.Id.ToString();
|
||||
Name = device.Name;
|
||||
Type = device.Type;
|
||||
Identifier = device.Identifier;
|
||||
CreationDate = device.CreationDate;
|
||||
public string Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public DeviceType Type { get; set; }
|
||||
public string Identifier { get; set; }
|
||||
public DateTime CreationDate { get; set; }
|
||||
}
|
||||
|
||||
public string Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public DeviceType Type { get; set; }
|
||||
public string Identifier { get; set; }
|
||||
public DateTime CreationDate { get; set; }
|
||||
}
|
||||
|
@ -1,16 +1,17 @@
|
||||
using Bit.Core.Models.Api;
|
||||
|
||||
namespace Bit.Api.Models.Response;
|
||||
|
||||
public class DeviceVerificationResponseModel : ResponseModel
|
||||
namespace Bit.Api.Models.Response
|
||||
{
|
||||
public DeviceVerificationResponseModel(bool isDeviceVerificationSectionEnabled, bool unknownDeviceVerificationEnabled)
|
||||
: base("deviceVerificationSettings")
|
||||
public class DeviceVerificationResponseModel : ResponseModel
|
||||
{
|
||||
IsDeviceVerificationSectionEnabled = isDeviceVerificationSectionEnabled;
|
||||
UnknownDeviceVerificationEnabled = unknownDeviceVerificationEnabled;
|
||||
}
|
||||
public DeviceVerificationResponseModel(bool isDeviceVerificationSectionEnabled, bool unknownDeviceVerificationEnabled)
|
||||
: base("deviceVerificationSettings")
|
||||
{
|
||||
IsDeviceVerificationSectionEnabled = isDeviceVerificationSectionEnabled;
|
||||
UnknownDeviceVerificationEnabled = unknownDeviceVerificationEnabled;
|
||||
}
|
||||
|
||||
public bool IsDeviceVerificationSectionEnabled { get; }
|
||||
public bool UnknownDeviceVerificationEnabled { get; }
|
||||
public bool IsDeviceVerificationSectionEnabled { get; }
|
||||
public bool UnknownDeviceVerificationEnabled { get; }
|
||||
}
|
||||
}
|
||||
|
@ -3,53 +3,54 @@ using Bit.Core.Entities;
|
||||
using Bit.Core.Enums;
|
||||
using Bit.Core.Models.Api;
|
||||
|
||||
namespace Bit.Api.Models.Response;
|
||||
|
||||
public class DomainsResponseModel : ResponseModel
|
||||
namespace Bit.Api.Models.Response
|
||||
{
|
||||
public DomainsResponseModel(User user, bool excluded = true)
|
||||
: base("domains")
|
||||
public class DomainsResponseModel : ResponseModel
|
||||
{
|
||||
if (user == null)
|
||||
public DomainsResponseModel(User user, bool excluded = true)
|
||||
: base("domains")
|
||||
{
|
||||
throw new ArgumentNullException(nameof(user));
|
||||
if (user == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(user));
|
||||
}
|
||||
|
||||
EquivalentDomains = user.EquivalentDomains != null ?
|
||||
JsonSerializer.Deserialize<List<List<string>>>(user.EquivalentDomains) : null;
|
||||
|
||||
var excludedGlobalEquivalentDomains = user.ExcludedGlobalEquivalentDomains != null ?
|
||||
JsonSerializer.Deserialize<List<GlobalEquivalentDomainsType>>(user.ExcludedGlobalEquivalentDomains) :
|
||||
new List<GlobalEquivalentDomainsType>();
|
||||
var globalDomains = new List<GlobalDomains>();
|
||||
var domainsToInclude = excluded ? Core.Utilities.StaticStore.GlobalDomains :
|
||||
Core.Utilities.StaticStore.GlobalDomains.Where(d => !excludedGlobalEquivalentDomains.Contains(d.Key));
|
||||
foreach (var domain in domainsToInclude)
|
||||
{
|
||||
globalDomains.Add(new GlobalDomains(domain.Key, domain.Value, excludedGlobalEquivalentDomains, excluded));
|
||||
}
|
||||
GlobalEquivalentDomains = !globalDomains.Any() ? null : globalDomains;
|
||||
}
|
||||
|
||||
EquivalentDomains = user.EquivalentDomains != null ?
|
||||
JsonSerializer.Deserialize<List<List<string>>>(user.EquivalentDomains) : null;
|
||||
public IEnumerable<IEnumerable<string>> EquivalentDomains { get; set; }
|
||||
public IEnumerable<GlobalDomains> GlobalEquivalentDomains { get; set; }
|
||||
|
||||
var excludedGlobalEquivalentDomains = user.ExcludedGlobalEquivalentDomains != null ?
|
||||
JsonSerializer.Deserialize<List<GlobalEquivalentDomainsType>>(user.ExcludedGlobalEquivalentDomains) :
|
||||
new List<GlobalEquivalentDomainsType>();
|
||||
var globalDomains = new List<GlobalDomains>();
|
||||
var domainsToInclude = excluded ? Core.Utilities.StaticStore.GlobalDomains :
|
||||
Core.Utilities.StaticStore.GlobalDomains.Where(d => !excludedGlobalEquivalentDomains.Contains(d.Key));
|
||||
foreach (var domain in domainsToInclude)
|
||||
|
||||
public class GlobalDomains
|
||||
{
|
||||
globalDomains.Add(new GlobalDomains(domain.Key, domain.Value, excludedGlobalEquivalentDomains, excluded));
|
||||
public GlobalDomains(
|
||||
GlobalEquivalentDomainsType globalDomain,
|
||||
IEnumerable<string> domains,
|
||||
IEnumerable<GlobalEquivalentDomainsType> excludedDomains,
|
||||
bool excluded)
|
||||
{
|
||||
Type = globalDomain;
|
||||
Domains = domains;
|
||||
Excluded = excluded && (excludedDomains?.Contains(globalDomain) ?? false);
|
||||
}
|
||||
|
||||
public GlobalEquivalentDomainsType Type { get; set; }
|
||||
public IEnumerable<string> Domains { get; set; }
|
||||
public bool Excluded { get; set; }
|
||||
}
|
||||
GlobalEquivalentDomains = !globalDomains.Any() ? null : globalDomains;
|
||||
}
|
||||
|
||||
public IEnumerable<IEnumerable<string>> EquivalentDomains { get; set; }
|
||||
public IEnumerable<GlobalDomains> GlobalEquivalentDomains { get; set; }
|
||||
|
||||
|
||||
public class GlobalDomains
|
||||
{
|
||||
public GlobalDomains(
|
||||
GlobalEquivalentDomainsType globalDomain,
|
||||
IEnumerable<string> domains,
|
||||
IEnumerable<GlobalEquivalentDomainsType> excludedDomains,
|
||||
bool excluded)
|
||||
{
|
||||
Type = globalDomain;
|
||||
Domains = domains;
|
||||
Excluded = excluded && (excludedDomains?.Contains(globalDomain) ?? false);
|
||||
}
|
||||
|
||||
public GlobalEquivalentDomainsType Type { get; set; }
|
||||
public IEnumerable<string> Domains { get; set; }
|
||||
public bool Excluded { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -5,113 +5,114 @@ using Bit.Core.Models.Data;
|
||||
using Bit.Core.Settings;
|
||||
using Core.Models.Data;
|
||||
|
||||
namespace Bit.Api.Models.Response;
|
||||
|
||||
public class EmergencyAccessResponseModel : ResponseModel
|
||||
namespace Bit.Api.Models.Response
|
||||
{
|
||||
public EmergencyAccessResponseModel(EmergencyAccess emergencyAccess, string obj = "emergencyAccess") : base(obj)
|
||||
public class EmergencyAccessResponseModel : ResponseModel
|
||||
{
|
||||
if (emergencyAccess == null)
|
||||
public EmergencyAccessResponseModel(EmergencyAccess emergencyAccess, string obj = "emergencyAccess") : base(obj)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(emergencyAccess));
|
||||
if (emergencyAccess == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(emergencyAccess));
|
||||
}
|
||||
|
||||
Id = emergencyAccess.Id.ToString();
|
||||
Status = emergencyAccess.Status;
|
||||
Type = emergencyAccess.Type;
|
||||
WaitTimeDays = emergencyAccess.WaitTimeDays;
|
||||
}
|
||||
|
||||
Id = emergencyAccess.Id.ToString();
|
||||
Status = emergencyAccess.Status;
|
||||
Type = emergencyAccess.Type;
|
||||
WaitTimeDays = emergencyAccess.WaitTimeDays;
|
||||
}
|
||||
|
||||
public EmergencyAccessResponseModel(EmergencyAccessDetails emergencyAccess, string obj = "emergencyAccess") : base(obj)
|
||||
{
|
||||
if (emergencyAccess == null)
|
||||
public EmergencyAccessResponseModel(EmergencyAccessDetails emergencyAccess, string obj = "emergencyAccess") : base(obj)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(emergencyAccess));
|
||||
if (emergencyAccess == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(emergencyAccess));
|
||||
}
|
||||
|
||||
Id = emergencyAccess.Id.ToString();
|
||||
Status = emergencyAccess.Status;
|
||||
Type = emergencyAccess.Type;
|
||||
WaitTimeDays = emergencyAccess.WaitTimeDays;
|
||||
}
|
||||
|
||||
Id = emergencyAccess.Id.ToString();
|
||||
Status = emergencyAccess.Status;
|
||||
Type = emergencyAccess.Type;
|
||||
WaitTimeDays = emergencyAccess.WaitTimeDays;
|
||||
public string Id { get; private set; }
|
||||
public EmergencyAccessStatusType Status { get; private set; }
|
||||
public EmergencyAccessType Type { get; private set; }
|
||||
public int WaitTimeDays { get; private set; }
|
||||
}
|
||||
|
||||
public string Id { get; private set; }
|
||||
public EmergencyAccessStatusType Status { get; private set; }
|
||||
public EmergencyAccessType Type { get; private set; }
|
||||
public int WaitTimeDays { get; private set; }
|
||||
}
|
||||
|
||||
public class EmergencyAccessGranteeDetailsResponseModel : EmergencyAccessResponseModel
|
||||
{
|
||||
public EmergencyAccessGranteeDetailsResponseModel(EmergencyAccessDetails emergencyAccess)
|
||||
: base(emergencyAccess, "emergencyAccessGranteeDetails")
|
||||
public class EmergencyAccessGranteeDetailsResponseModel : EmergencyAccessResponseModel
|
||||
{
|
||||
if (emergencyAccess == null)
|
||||
public EmergencyAccessGranteeDetailsResponseModel(EmergencyAccessDetails emergencyAccess)
|
||||
: base(emergencyAccess, "emergencyAccessGranteeDetails")
|
||||
{
|
||||
throw new ArgumentNullException(nameof(emergencyAccess));
|
||||
if (emergencyAccess == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(emergencyAccess));
|
||||
}
|
||||
|
||||
GranteeId = emergencyAccess.GranteeId.ToString();
|
||||
Email = emergencyAccess.GranteeEmail;
|
||||
Name = emergencyAccess.GranteeName;
|
||||
}
|
||||
|
||||
GranteeId = emergencyAccess.GranteeId.ToString();
|
||||
Email = emergencyAccess.GranteeEmail;
|
||||
Name = emergencyAccess.GranteeName;
|
||||
public string GranteeId { get; private set; }
|
||||
public string Name { get; private set; }
|
||||
public string Email { get; private set; }
|
||||
}
|
||||
|
||||
public string GranteeId { get; private set; }
|
||||
public string Name { get; private set; }
|
||||
public string Email { get; private set; }
|
||||
}
|
||||
|
||||
public class EmergencyAccessGrantorDetailsResponseModel : EmergencyAccessResponseModel
|
||||
{
|
||||
public EmergencyAccessGrantorDetailsResponseModel(EmergencyAccessDetails emergencyAccess)
|
||||
: base(emergencyAccess, "emergencyAccessGrantorDetails")
|
||||
public class EmergencyAccessGrantorDetailsResponseModel : EmergencyAccessResponseModel
|
||||
{
|
||||
if (emergencyAccess == null)
|
||||
public EmergencyAccessGrantorDetailsResponseModel(EmergencyAccessDetails emergencyAccess)
|
||||
: base(emergencyAccess, "emergencyAccessGrantorDetails")
|
||||
{
|
||||
throw new ArgumentNullException(nameof(emergencyAccess));
|
||||
if (emergencyAccess == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(emergencyAccess));
|
||||
}
|
||||
|
||||
GrantorId = emergencyAccess.GrantorId.ToString();
|
||||
Email = emergencyAccess.GrantorEmail;
|
||||
Name = emergencyAccess.GrantorName;
|
||||
}
|
||||
|
||||
GrantorId = emergencyAccess.GrantorId.ToString();
|
||||
Email = emergencyAccess.GrantorEmail;
|
||||
Name = emergencyAccess.GrantorName;
|
||||
public string GrantorId { get; private set; }
|
||||
public string Name { get; private set; }
|
||||
public string Email { get; private set; }
|
||||
}
|
||||
|
||||
public string GrantorId { get; private set; }
|
||||
public string Name { get; private set; }
|
||||
public string Email { get; private set; }
|
||||
}
|
||||
|
||||
public class EmergencyAccessTakeoverResponseModel : ResponseModel
|
||||
{
|
||||
public EmergencyAccessTakeoverResponseModel(EmergencyAccess emergencyAccess, User grantor, string obj = "emergencyAccessTakeover") : base(obj)
|
||||
public class EmergencyAccessTakeoverResponseModel : ResponseModel
|
||||
{
|
||||
if (emergencyAccess == null)
|
||||
public EmergencyAccessTakeoverResponseModel(EmergencyAccess emergencyAccess, User grantor, string obj = "emergencyAccessTakeover") : base(obj)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(emergencyAccess));
|
||||
if (emergencyAccess == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(emergencyAccess));
|
||||
}
|
||||
|
||||
KeyEncrypted = emergencyAccess.KeyEncrypted;
|
||||
Kdf = grantor.Kdf;
|
||||
KdfIterations = grantor.KdfIterations;
|
||||
}
|
||||
|
||||
KeyEncrypted = emergencyAccess.KeyEncrypted;
|
||||
Kdf = grantor.Kdf;
|
||||
KdfIterations = grantor.KdfIterations;
|
||||
public int KdfIterations { get; private set; }
|
||||
public KdfType Kdf { get; private set; }
|
||||
public string KeyEncrypted { get; private set; }
|
||||
}
|
||||
|
||||
public int KdfIterations { get; private set; }
|
||||
public KdfType Kdf { get; private set; }
|
||||
public string KeyEncrypted { get; private set; }
|
||||
}
|
||||
|
||||
public class EmergencyAccessViewResponseModel : ResponseModel
|
||||
{
|
||||
public EmergencyAccessViewResponseModel(
|
||||
IGlobalSettings globalSettings,
|
||||
EmergencyAccess emergencyAccess,
|
||||
IEnumerable<CipherDetails> ciphers)
|
||||
: base("emergencyAccessView")
|
||||
public class EmergencyAccessViewResponseModel : ResponseModel
|
||||
{
|
||||
KeyEncrypted = emergencyAccess.KeyEncrypted;
|
||||
Ciphers = ciphers.Select(c => new CipherResponseModel(c, globalSettings));
|
||||
}
|
||||
public EmergencyAccessViewResponseModel(
|
||||
IGlobalSettings globalSettings,
|
||||
EmergencyAccess emergencyAccess,
|
||||
IEnumerable<CipherDetails> ciphers)
|
||||
: base("emergencyAccessView")
|
||||
{
|
||||
KeyEncrypted = emergencyAccess.KeyEncrypted;
|
||||
Ciphers = ciphers.Select(c => new CipherResponseModel(c, globalSettings));
|
||||
}
|
||||
|
||||
public string KeyEncrypted { get; set; }
|
||||
public IEnumerable<CipherResponseModel> Ciphers { get; set; }
|
||||
public string KeyEncrypted { get; set; }
|
||||
public IEnumerable<CipherResponseModel> Ciphers { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -2,50 +2,51 @@
|
||||
using Bit.Core.Models.Api;
|
||||
using Bit.Core.Models.Data;
|
||||
|
||||
namespace Bit.Api.Models.Response;
|
||||
|
||||
public class EventResponseModel : ResponseModel
|
||||
namespace Bit.Api.Models.Response
|
||||
{
|
||||
public EventResponseModel(IEvent ev)
|
||||
: base("event")
|
||||
public class EventResponseModel : ResponseModel
|
||||
{
|
||||
if (ev == null)
|
||||
public EventResponseModel(IEvent ev)
|
||||
: base("event")
|
||||
{
|
||||
throw new ArgumentNullException(nameof(ev));
|
||||
if (ev == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(ev));
|
||||
}
|
||||
|
||||
Type = ev.Type;
|
||||
UserId = ev.UserId;
|
||||
OrganizationId = ev.OrganizationId;
|
||||
ProviderId = ev.ProviderId;
|
||||
CipherId = ev.CipherId;
|
||||
CollectionId = ev.CollectionId;
|
||||
GroupId = ev.GroupId;
|
||||
PolicyId = ev.PolicyId;
|
||||
OrganizationUserId = ev.OrganizationUserId;
|
||||
ProviderUserId = ev.ProviderUserId;
|
||||
ProviderOrganizationId = ev.ProviderOrganizationId;
|
||||
ActingUserId = ev.ActingUserId;
|
||||
Date = ev.Date;
|
||||
DeviceType = ev.DeviceType;
|
||||
IpAddress = ev.IpAddress;
|
||||
InstallationId = ev.InstallationId;
|
||||
}
|
||||
|
||||
Type = ev.Type;
|
||||
UserId = ev.UserId;
|
||||
OrganizationId = ev.OrganizationId;
|
||||
ProviderId = ev.ProviderId;
|
||||
CipherId = ev.CipherId;
|
||||
CollectionId = ev.CollectionId;
|
||||
GroupId = ev.GroupId;
|
||||
PolicyId = ev.PolicyId;
|
||||
OrganizationUserId = ev.OrganizationUserId;
|
||||
ProviderUserId = ev.ProviderUserId;
|
||||
ProviderOrganizationId = ev.ProviderOrganizationId;
|
||||
ActingUserId = ev.ActingUserId;
|
||||
Date = ev.Date;
|
||||
DeviceType = ev.DeviceType;
|
||||
IpAddress = ev.IpAddress;
|
||||
InstallationId = ev.InstallationId;
|
||||
public EventType Type { get; set; }
|
||||
public Guid? UserId { get; set; }
|
||||
public Guid? OrganizationId { get; set; }
|
||||
public Guid? ProviderId { get; set; }
|
||||
public Guid? CipherId { get; set; }
|
||||
public Guid? CollectionId { get; set; }
|
||||
public Guid? GroupId { get; set; }
|
||||
public Guid? PolicyId { get; set; }
|
||||
public Guid? OrganizationUserId { get; set; }
|
||||
public Guid? ProviderUserId { get; set; }
|
||||
public Guid? ProviderOrganizationId { get; set; }
|
||||
public Guid? ActingUserId { get; set; }
|
||||
public Guid? InstallationId { get; set; }
|
||||
public DateTime Date { get; set; }
|
||||
public DeviceType? DeviceType { get; set; }
|
||||
public string IpAddress { get; set; }
|
||||
}
|
||||
|
||||
public EventType Type { get; set; }
|
||||
public Guid? UserId { get; set; }
|
||||
public Guid? OrganizationId { get; set; }
|
||||
public Guid? ProviderId { get; set; }
|
||||
public Guid? CipherId { get; set; }
|
||||
public Guid? CollectionId { get; set; }
|
||||
public Guid? GroupId { get; set; }
|
||||
public Guid? PolicyId { get; set; }
|
||||
public Guid? OrganizationUserId { get; set; }
|
||||
public Guid? ProviderUserId { get; set; }
|
||||
public Guid? ProviderOrganizationId { get; set; }
|
||||
public Guid? ActingUserId { get; set; }
|
||||
public Guid? InstallationId { get; set; }
|
||||
public DateTime Date { get; set; }
|
||||
public DeviceType? DeviceType { get; set; }
|
||||
public string IpAddress { get; set; }
|
||||
}
|
||||
|
@ -1,24 +1,25 @@
|
||||
using Bit.Core.Entities;
|
||||
using Bit.Core.Models.Api;
|
||||
|
||||
namespace Bit.Api.Models.Response;
|
||||
|
||||
public class FolderResponseModel : ResponseModel
|
||||
namespace Bit.Api.Models.Response
|
||||
{
|
||||
public FolderResponseModel(Folder folder)
|
||||
: base("folder")
|
||||
public class FolderResponseModel : ResponseModel
|
||||
{
|
||||
if (folder == null)
|
||||
public FolderResponseModel(Folder folder)
|
||||
: base("folder")
|
||||
{
|
||||
throw new ArgumentNullException(nameof(folder));
|
||||
if (folder == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(folder));
|
||||
}
|
||||
|
||||
Id = folder.Id.ToString();
|
||||
Name = folder.Name;
|
||||
RevisionDate = folder.RevisionDate;
|
||||
}
|
||||
|
||||
Id = folder.Id.ToString();
|
||||
Name = folder.Name;
|
||||
RevisionDate = folder.RevisionDate;
|
||||
public string Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public DateTime RevisionDate { get; set; }
|
||||
}
|
||||
|
||||
public string Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public DateTime RevisionDate { get; set; }
|
||||
}
|
||||
|
@ -2,39 +2,40 @@
|
||||
using Bit.Core.Models.Api;
|
||||
using Bit.Core.Models.Data;
|
||||
|
||||
namespace Bit.Api.Models.Response;
|
||||
|
||||
public class GroupResponseModel : ResponseModel
|
||||
namespace Bit.Api.Models.Response
|
||||
{
|
||||
public GroupResponseModel(Group group, string obj = "group")
|
||||
: base(obj)
|
||||
public class GroupResponseModel : ResponseModel
|
||||
{
|
||||
if (group == null)
|
||||
public GroupResponseModel(Group group, string obj = "group")
|
||||
: base(obj)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(group));
|
||||
if (group == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(group));
|
||||
}
|
||||
|
||||
Id = group.Id.ToString();
|
||||
OrganizationId = group.OrganizationId.ToString();
|
||||
Name = group.Name;
|
||||
AccessAll = group.AccessAll;
|
||||
ExternalId = group.ExternalId;
|
||||
}
|
||||
|
||||
Id = group.Id.ToString();
|
||||
OrganizationId = group.OrganizationId.ToString();
|
||||
Name = group.Name;
|
||||
AccessAll = group.AccessAll;
|
||||
ExternalId = group.ExternalId;
|
||||
public string Id { get; set; }
|
||||
public string OrganizationId { get; set; }
|
||||
public string Name { get; set; }
|
||||
public bool AccessAll { get; set; }
|
||||
public string ExternalId { get; set; }
|
||||
}
|
||||
|
||||
public string Id { get; set; }
|
||||
public string OrganizationId { get; set; }
|
||||
public string Name { get; set; }
|
||||
public bool AccessAll { get; set; }
|
||||
public string ExternalId { get; set; }
|
||||
}
|
||||
|
||||
public class GroupDetailsResponseModel : GroupResponseModel
|
||||
{
|
||||
public GroupDetailsResponseModel(Group group, IEnumerable<SelectionReadOnly> collections)
|
||||
: base(group, "groupDetails")
|
||||
public class GroupDetailsResponseModel : GroupResponseModel
|
||||
{
|
||||
Collections = collections.Select(c => new SelectionReadOnlyResponseModel(c));
|
||||
}
|
||||
public GroupDetailsResponseModel(Group group, IEnumerable<SelectionReadOnly> collections)
|
||||
: base(group, "groupDetails")
|
||||
{
|
||||
Collections = collections.Select(c => new SelectionReadOnlyResponseModel(c));
|
||||
}
|
||||
|
||||
public IEnumerable<SelectionReadOnlyResponseModel> Collections { get; set; }
|
||||
public IEnumerable<SelectionReadOnlyResponseModel> Collections { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -1,19 +1,20 @@
|
||||
using Bit.Core.Entities;
|
||||
using Bit.Core.Models.Api;
|
||||
|
||||
namespace Bit.Api.Models.Response;
|
||||
|
||||
public class InstallationResponseModel : ResponseModel
|
||||
namespace Bit.Api.Models.Response
|
||||
{
|
||||
public InstallationResponseModel(Installation installation, bool withKey)
|
||||
: base("installation")
|
||||
public class InstallationResponseModel : ResponseModel
|
||||
{
|
||||
Id = installation.Id.ToString();
|
||||
Key = withKey ? installation.Key : null;
|
||||
Enabled = installation.Enabled;
|
||||
}
|
||||
public InstallationResponseModel(Installation installation, bool withKey)
|
||||
: base("installation")
|
||||
{
|
||||
Id = installation.Id.ToString();
|
||||
Key = withKey ? installation.Key : null;
|
||||
Enabled = installation.Enabled;
|
||||
}
|
||||
|
||||
public string Id { get; set; }
|
||||
public string Key { get; set; }
|
||||
public bool Enabled { get; set; }
|
||||
public string Id { get; set; }
|
||||
public string Key { get; set; }
|
||||
public bool Enabled { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -1,24 +1,25 @@
|
||||
using Bit.Core.Entities;
|
||||
using Bit.Core.Models.Api;
|
||||
|
||||
namespace Bit.Api.Models.Response;
|
||||
|
||||
public class KeysResponseModel : ResponseModel
|
||||
namespace Bit.Api.Models.Response
|
||||
{
|
||||
public KeysResponseModel(User user)
|
||||
: base("keys")
|
||||
public class KeysResponseModel : ResponseModel
|
||||
{
|
||||
if (user == null)
|
||||
public KeysResponseModel(User user)
|
||||
: base("keys")
|
||||
{
|
||||
throw new ArgumentNullException(nameof(user));
|
||||
if (user == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(user));
|
||||
}
|
||||
|
||||
Key = user.Key;
|
||||
PublicKey = user.PublicKey;
|
||||
PrivateKey = user.PrivateKey;
|
||||
}
|
||||
|
||||
Key = user.Key;
|
||||
PublicKey = user.PublicKey;
|
||||
PrivateKey = user.PrivateKey;
|
||||
public string Key { get; set; }
|
||||
public string PublicKey { get; set; }
|
||||
public string PrivateKey { get; set; }
|
||||
}
|
||||
|
||||
public string Key { get; set; }
|
||||
public string PublicKey { get; set; }
|
||||
public string PrivateKey { get; set; }
|
||||
}
|
||||
|
@ -1,16 +1,17 @@
|
||||
using Bit.Core.Models.Api;
|
||||
|
||||
namespace Bit.Api.Models.Response;
|
||||
|
||||
public class ListResponseModel<T> : ResponseModel where T : ResponseModel
|
||||
namespace Bit.Api.Models.Response
|
||||
{
|
||||
public ListResponseModel(IEnumerable<T> data, string continuationToken = null)
|
||||
: base("list")
|
||||
public class ListResponseModel<T> : ResponseModel where T : ResponseModel
|
||||
{
|
||||
Data = data;
|
||||
ContinuationToken = continuationToken;
|
||||
}
|
||||
public ListResponseModel(IEnumerable<T> data, string continuationToken = null)
|
||||
: base("list")
|
||||
{
|
||||
Data = data;
|
||||
ContinuationToken = continuationToken;
|
||||
}
|
||||
|
||||
public IEnumerable<T> Data { get; set; }
|
||||
public string ContinuationToken { get; set; }
|
||||
public IEnumerable<T> Data { get; set; }
|
||||
public string ContinuationToken { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,13 @@
|
||||
namespace Bit.Api.Models.Response;
|
||||
|
||||
public class OrganizationExportResponseModel
|
||||
namespace Bit.Api.Models.Response
|
||||
{
|
||||
public OrganizationExportResponseModel()
|
||||
public class OrganizationExportResponseModel
|
||||
{
|
||||
public OrganizationExportResponseModel()
|
||||
{
|
||||
}
|
||||
|
||||
public ListResponseModel<CollectionResponseModel> Collections { get; set; }
|
||||
|
||||
public ListResponseModel<CipherMiniDetailsResponseModel> Ciphers { get; set; }
|
||||
}
|
||||
|
||||
public ListResponseModel<CollectionResponseModel> Collections { get; set; }
|
||||
|
||||
public ListResponseModel<CipherMiniDetailsResponseModel> Ciphers { get; set; }
|
||||
}
|
||||
|
@ -2,16 +2,17 @@
|
||||
using Bit.Core.Enums;
|
||||
using Bit.Core.Models.Api;
|
||||
|
||||
namespace Bit.Api.Models.Response.Organizations;
|
||||
|
||||
public class OrganizationApiKeyInformation : ResponseModel
|
||||
namespace Bit.Api.Models.Response.Organizations
|
||||
{
|
||||
public OrganizationApiKeyInformation(OrganizationApiKey key) : base("keyInformation")
|
||||
public class OrganizationApiKeyInformation : ResponseModel
|
||||
{
|
||||
KeyType = key.Type;
|
||||
RevisionDate = key.RevisionDate;
|
||||
}
|
||||
public OrganizationApiKeyInformation(OrganizationApiKey key) : base("keyInformation")
|
||||
{
|
||||
KeyType = key.Type;
|
||||
RevisionDate = key.RevisionDate;
|
||||
}
|
||||
|
||||
public OrganizationApiKeyType KeyType { get; set; }
|
||||
public DateTime RevisionDate { get; set; }
|
||||
public OrganizationApiKeyType KeyType { get; set; }
|
||||
public DateTime RevisionDate { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,16 @@
|
||||
using Bit.Core.Models.Api;
|
||||
|
||||
namespace Bit.Api.Models.Response.Organizations;
|
||||
|
||||
public class OrganizationAutoEnrollStatusResponseModel : ResponseModel
|
||||
namespace Bit.Api.Models.Response.Organizations
|
||||
{
|
||||
public OrganizationAutoEnrollStatusResponseModel(Guid orgId, bool resetPasswordEnabled) : base("organizationAutoEnrollStatus")
|
||||
public class OrganizationAutoEnrollStatusResponseModel : ResponseModel
|
||||
{
|
||||
Id = orgId.ToString();
|
||||
ResetPasswordEnabled = resetPasswordEnabled;
|
||||
}
|
||||
public OrganizationAutoEnrollStatusResponseModel(Guid orgId, bool resetPasswordEnabled) : base("organizationAutoEnrollStatus")
|
||||
{
|
||||
Id = orgId.ToString();
|
||||
ResetPasswordEnabled = resetPasswordEnabled;
|
||||
}
|
||||
|
||||
public string Id { get; set; }
|
||||
public bool ResetPasswordEnabled { get; set; }
|
||||
public string Id { get; set; }
|
||||
public bool ResetPasswordEnabled { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -2,27 +2,28 @@
|
||||
using Bit.Core.Entities;
|
||||
using Bit.Core.Enums;
|
||||
|
||||
namespace Bit.Api.Models.Response.Organizations;
|
||||
|
||||
public class OrganizationConnectionResponseModel
|
||||
namespace Bit.Api.Models.Response.Organizations
|
||||
{
|
||||
public Guid? Id { get; set; }
|
||||
public OrganizationConnectionType Type { get; set; }
|
||||
public Guid OrganizationId { get; set; }
|
||||
public bool Enabled { get; set; }
|
||||
public JsonDocument Config { get; set; }
|
||||
|
||||
public OrganizationConnectionResponseModel(OrganizationConnection connection, Type configType)
|
||||
public class OrganizationConnectionResponseModel
|
||||
{
|
||||
if (connection == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
public Guid? Id { get; set; }
|
||||
public OrganizationConnectionType Type { get; set; }
|
||||
public Guid OrganizationId { get; set; }
|
||||
public bool Enabled { get; set; }
|
||||
public JsonDocument Config { get; set; }
|
||||
|
||||
Id = connection.Id;
|
||||
Type = connection.Type;
|
||||
OrganizationId = connection.OrganizationId;
|
||||
Enabled = connection.Enabled;
|
||||
Config = JsonDocument.Parse(connection.Config);
|
||||
public OrganizationConnectionResponseModel(OrganizationConnection connection, Type configType)
|
||||
{
|
||||
if (connection == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Id = connection.Id;
|
||||
Type = connection.Type;
|
||||
OrganizationId = connection.OrganizationId;
|
||||
Enabled = connection.Enabled;
|
||||
Config = JsonDocument.Parse(connection.Config);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,21 +1,22 @@
|
||||
using Bit.Core.Entities;
|
||||
using Bit.Core.Models.Api;
|
||||
|
||||
namespace Bit.Api.Models.Response.Organizations;
|
||||
|
||||
public class OrganizationKeysResponseModel : ResponseModel
|
||||
namespace Bit.Api.Models.Response.Organizations
|
||||
{
|
||||
public OrganizationKeysResponseModel(Organization org) : base("organizationKeys")
|
||||
public class OrganizationKeysResponseModel : ResponseModel
|
||||
{
|
||||
if (org == null)
|
||||
public OrganizationKeysResponseModel(Organization org) : base("organizationKeys")
|
||||
{
|
||||
throw new ArgumentNullException(nameof(org));
|
||||
if (org == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(org));
|
||||
}
|
||||
|
||||
PublicKey = org.PublicKey;
|
||||
PrivateKey = org.PrivateKey;
|
||||
}
|
||||
|
||||
PublicKey = org.PublicKey;
|
||||
PrivateKey = org.PrivateKey;
|
||||
public string PublicKey { get; set; }
|
||||
public string PrivateKey { get; set; }
|
||||
}
|
||||
|
||||
public string PublicKey { get; set; }
|
||||
public string PrivateKey { get; set; }
|
||||
}
|
||||
|
@ -4,109 +4,110 @@ using Bit.Core.Models.Api;
|
||||
using Bit.Core.Models.Business;
|
||||
using Bit.Core.Utilities;
|
||||
|
||||
namespace Bit.Api.Models.Response.Organizations;
|
||||
|
||||
public class OrganizationResponseModel : ResponseModel
|
||||
namespace Bit.Api.Models.Response.Organizations
|
||||
{
|
||||
public OrganizationResponseModel(Organization organization, string obj = "organization")
|
||||
: base(obj)
|
||||
public class OrganizationResponseModel : ResponseModel
|
||||
{
|
||||
if (organization == null)
|
||||
public OrganizationResponseModel(Organization organization, string obj = "organization")
|
||||
: base(obj)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(organization));
|
||||
if (organization == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(organization));
|
||||
}
|
||||
|
||||
Id = organization.Id.ToString();
|
||||
Identifier = organization.Identifier;
|
||||
Name = organization.Name;
|
||||
BusinessName = organization.BusinessName;
|
||||
BusinessAddress1 = organization.BusinessAddress1;
|
||||
BusinessAddress2 = organization.BusinessAddress2;
|
||||
BusinessAddress3 = organization.BusinessAddress3;
|
||||
BusinessCountry = organization.BusinessCountry;
|
||||
BusinessTaxNumber = organization.BusinessTaxNumber;
|
||||
BillingEmail = organization.BillingEmail;
|
||||
Plan = new PlanResponseModel(StaticStore.Plans.FirstOrDefault(plan => plan.Type == organization.PlanType));
|
||||
PlanType = organization.PlanType;
|
||||
Seats = organization.Seats;
|
||||
MaxAutoscaleSeats = organization.MaxAutoscaleSeats;
|
||||
MaxCollections = organization.MaxCollections;
|
||||
MaxStorageGb = organization.MaxStorageGb;
|
||||
UsePolicies = organization.UsePolicies;
|
||||
UseSso = organization.UseSso;
|
||||
UseKeyConnector = organization.UseKeyConnector;
|
||||
UseScim = organization.UseScim;
|
||||
UseGroups = organization.UseGroups;
|
||||
UseDirectory = organization.UseDirectory;
|
||||
UseEvents = organization.UseEvents;
|
||||
UseTotp = organization.UseTotp;
|
||||
Use2fa = organization.Use2fa;
|
||||
UseApi = organization.UseApi;
|
||||
UseResetPassword = organization.UseResetPassword;
|
||||
UsersGetPremium = organization.UsersGetPremium;
|
||||
SelfHost = organization.SelfHost;
|
||||
HasPublicAndPrivateKeys = organization.PublicKey != null && organization.PrivateKey != null;
|
||||
}
|
||||
|
||||
Id = organization.Id.ToString();
|
||||
Identifier = organization.Identifier;
|
||||
Name = organization.Name;
|
||||
BusinessName = organization.BusinessName;
|
||||
BusinessAddress1 = organization.BusinessAddress1;
|
||||
BusinessAddress2 = organization.BusinessAddress2;
|
||||
BusinessAddress3 = organization.BusinessAddress3;
|
||||
BusinessCountry = organization.BusinessCountry;
|
||||
BusinessTaxNumber = organization.BusinessTaxNumber;
|
||||
BillingEmail = organization.BillingEmail;
|
||||
Plan = new PlanResponseModel(StaticStore.Plans.FirstOrDefault(plan => plan.Type == organization.PlanType));
|
||||
PlanType = organization.PlanType;
|
||||
Seats = organization.Seats;
|
||||
MaxAutoscaleSeats = organization.MaxAutoscaleSeats;
|
||||
MaxCollections = organization.MaxCollections;
|
||||
MaxStorageGb = organization.MaxStorageGb;
|
||||
UsePolicies = organization.UsePolicies;
|
||||
UseSso = organization.UseSso;
|
||||
UseKeyConnector = organization.UseKeyConnector;
|
||||
UseScim = organization.UseScim;
|
||||
UseGroups = organization.UseGroups;
|
||||
UseDirectory = organization.UseDirectory;
|
||||
UseEvents = organization.UseEvents;
|
||||
UseTotp = organization.UseTotp;
|
||||
Use2fa = organization.Use2fa;
|
||||
UseApi = organization.UseApi;
|
||||
UseResetPassword = organization.UseResetPassword;
|
||||
UsersGetPremium = organization.UsersGetPremium;
|
||||
SelfHost = organization.SelfHost;
|
||||
HasPublicAndPrivateKeys = organization.PublicKey != null && organization.PrivateKey != null;
|
||||
public string Id { get; set; }
|
||||
public string Identifier { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string BusinessName { get; set; }
|
||||
public string BusinessAddress1 { get; set; }
|
||||
public string BusinessAddress2 { get; set; }
|
||||
public string BusinessAddress3 { get; set; }
|
||||
public string BusinessCountry { get; set; }
|
||||
public string BusinessTaxNumber { get; set; }
|
||||
public string BillingEmail { get; set; }
|
||||
public PlanResponseModel Plan { get; set; }
|
||||
public PlanType PlanType { get; set; }
|
||||
public int? Seats { get; set; }
|
||||
public int? MaxAutoscaleSeats { get; set; } = null;
|
||||
public short? MaxCollections { get; set; }
|
||||
public short? MaxStorageGb { get; set; }
|
||||
public bool UsePolicies { get; set; }
|
||||
public bool UseSso { get; set; }
|
||||
public bool UseKeyConnector { get; set; }
|
||||
public bool UseScim { get; set; }
|
||||
public bool UseGroups { get; set; }
|
||||
public bool UseDirectory { get; set; }
|
||||
public bool UseEvents { get; set; }
|
||||
public bool UseTotp { get; set; }
|
||||
public bool Use2fa { get; set; }
|
||||
public bool UseApi { get; set; }
|
||||
public bool UseResetPassword { get; set; }
|
||||
public bool UsersGetPremium { get; set; }
|
||||
public bool SelfHost { get; set; }
|
||||
public bool HasPublicAndPrivateKeys { get; set; }
|
||||
}
|
||||
|
||||
public string Id { get; set; }
|
||||
public string Identifier { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string BusinessName { get; set; }
|
||||
public string BusinessAddress1 { get; set; }
|
||||
public string BusinessAddress2 { get; set; }
|
||||
public string BusinessAddress3 { get; set; }
|
||||
public string BusinessCountry { get; set; }
|
||||
public string BusinessTaxNumber { get; set; }
|
||||
public string BillingEmail { get; set; }
|
||||
public PlanResponseModel Plan { get; set; }
|
||||
public PlanType PlanType { get; set; }
|
||||
public int? Seats { get; set; }
|
||||
public int? MaxAutoscaleSeats { get; set; } = null;
|
||||
public short? MaxCollections { get; set; }
|
||||
public short? MaxStorageGb { get; set; }
|
||||
public bool UsePolicies { get; set; }
|
||||
public bool UseSso { get; set; }
|
||||
public bool UseKeyConnector { get; set; }
|
||||
public bool UseScim { get; set; }
|
||||
public bool UseGroups { get; set; }
|
||||
public bool UseDirectory { get; set; }
|
||||
public bool UseEvents { get; set; }
|
||||
public bool UseTotp { get; set; }
|
||||
public bool Use2fa { get; set; }
|
||||
public bool UseApi { get; set; }
|
||||
public bool UseResetPassword { get; set; }
|
||||
public bool UsersGetPremium { get; set; }
|
||||
public bool SelfHost { get; set; }
|
||||
public bool HasPublicAndPrivateKeys { get; set; }
|
||||
}
|
||||
|
||||
public class OrganizationSubscriptionResponseModel : OrganizationResponseModel
|
||||
{
|
||||
public OrganizationSubscriptionResponseModel(Organization organization, SubscriptionInfo subscription = null)
|
||||
: base(organization, "organizationSubscription")
|
||||
public class OrganizationSubscriptionResponseModel : OrganizationResponseModel
|
||||
{
|
||||
if (subscription != null)
|
||||
public OrganizationSubscriptionResponseModel(Organization organization, SubscriptionInfo subscription = null)
|
||||
: base(organization, "organizationSubscription")
|
||||
{
|
||||
Subscription = subscription.Subscription != null ?
|
||||
new BillingSubscription(subscription.Subscription) : null;
|
||||
UpcomingInvoice = subscription.UpcomingInvoice != null ?
|
||||
new BillingSubscriptionUpcomingInvoice(subscription.UpcomingInvoice) : null;
|
||||
Expiration = DateTime.UtcNow.AddYears(1); // Not used, so just give it a value.
|
||||
}
|
||||
else
|
||||
{
|
||||
Expiration = organization.ExpirationDate;
|
||||
if (subscription != null)
|
||||
{
|
||||
Subscription = subscription.Subscription != null ?
|
||||
new BillingSubscription(subscription.Subscription) : null;
|
||||
UpcomingInvoice = subscription.UpcomingInvoice != null ?
|
||||
new BillingSubscriptionUpcomingInvoice(subscription.UpcomingInvoice) : null;
|
||||
Expiration = DateTime.UtcNow.AddYears(1); // Not used, so just give it a value.
|
||||
}
|
||||
else
|
||||
{
|
||||
Expiration = organization.ExpirationDate;
|
||||
}
|
||||
|
||||
StorageName = organization.Storage.HasValue ?
|
||||
CoreHelpers.ReadableBytesSize(organization.Storage.Value) : null;
|
||||
StorageGb = organization.Storage.HasValue ?
|
||||
Math.Round(organization.Storage.Value / 1073741824D, 2) : 0; // 1 GB
|
||||
}
|
||||
|
||||
StorageName = organization.Storage.HasValue ?
|
||||
CoreHelpers.ReadableBytesSize(organization.Storage.Value) : null;
|
||||
StorageGb = organization.Storage.HasValue ?
|
||||
Math.Round(organization.Storage.Value / 1073741824D, 2) : 0; // 1 GB
|
||||
public string StorageName { get; set; }
|
||||
public double? StorageGb { get; set; }
|
||||
public BillingSubscription Subscription { get; set; }
|
||||
public BillingSubscriptionUpcomingInvoice UpcomingInvoice { get; set; }
|
||||
public DateTime? Expiration { get; set; }
|
||||
}
|
||||
|
||||
public string StorageName { get; set; }
|
||||
public double? StorageGb { get; set; }
|
||||
public BillingSubscription Subscription { get; set; }
|
||||
public BillingSubscriptionUpcomingInvoice UpcomingInvoice { get; set; }
|
||||
public DateTime? Expiration { get; set; }
|
||||
}
|
||||
|
@ -1,14 +1,15 @@
|
||||
using Bit.Core.Models.Api;
|
||||
|
||||
namespace Bit.Api.Models.Response.Organizations;
|
||||
|
||||
public class OrganizationSponsorshipSyncStatusResponseModel : ResponseModel
|
||||
namespace Bit.Api.Models.Response.Organizations
|
||||
{
|
||||
public OrganizationSponsorshipSyncStatusResponseModel(DateTime? lastSyncDate)
|
||||
: base("syncStatus")
|
||||
public class OrganizationSponsorshipSyncStatusResponseModel : ResponseModel
|
||||
{
|
||||
LastSyncDate = lastSyncDate;
|
||||
}
|
||||
public OrganizationSponsorshipSyncStatusResponseModel(DateTime? lastSyncDate)
|
||||
: base("syncStatus")
|
||||
{
|
||||
LastSyncDate = lastSyncDate;
|
||||
}
|
||||
|
||||
public DateTime? LastSyncDate { get; set; }
|
||||
public DateTime? LastSyncDate { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -3,41 +3,42 @@ using Bit.Core.Models.Api;
|
||||
using Bit.Core.Models.Data;
|
||||
using Bit.Core.Settings;
|
||||
|
||||
namespace Bit.Api.Models.Response.Organizations;
|
||||
|
||||
public class OrganizationSsoResponseModel : ResponseModel
|
||||
namespace Bit.Api.Models.Response.Organizations
|
||||
{
|
||||
public OrganizationSsoResponseModel(Organization organization, GlobalSettings globalSettings,
|
||||
SsoConfig config = null) : base("organizationSso")
|
||||
public class OrganizationSsoResponseModel : ResponseModel
|
||||
{
|
||||
if (config != null)
|
||||
public OrganizationSsoResponseModel(Organization organization, GlobalSettings globalSettings,
|
||||
SsoConfig config = null) : base("organizationSso")
|
||||
{
|
||||
Enabled = config.Enabled;
|
||||
Data = config.GetData();
|
||||
if (config != null)
|
||||
{
|
||||
Enabled = config.Enabled;
|
||||
Data = config.GetData();
|
||||
}
|
||||
|
||||
Urls = new SsoUrls(organization.Id.ToString(), globalSettings);
|
||||
}
|
||||
|
||||
Urls = new SsoUrls(organization.Id.ToString(), globalSettings);
|
||||
public bool Enabled { get; set; }
|
||||
public SsoConfigurationData Data { get; set; }
|
||||
public SsoUrls Urls { get; set; }
|
||||
}
|
||||
|
||||
public bool Enabled { get; set; }
|
||||
public SsoConfigurationData Data { get; set; }
|
||||
public SsoUrls Urls { get; set; }
|
||||
}
|
||||
|
||||
public class SsoUrls
|
||||
{
|
||||
public SsoUrls(string organizationId, GlobalSettings globalSettings)
|
||||
public class SsoUrls
|
||||
{
|
||||
CallbackPath = SsoConfigurationData.BuildCallbackPath(globalSettings.BaseServiceUri.Sso);
|
||||
SignedOutCallbackPath = SsoConfigurationData.BuildSignedOutCallbackPath(globalSettings.BaseServiceUri.Sso);
|
||||
SpEntityId = SsoConfigurationData.BuildSaml2ModulePath(globalSettings.BaseServiceUri.Sso);
|
||||
SpMetadataUrl = SsoConfigurationData.BuildSaml2MetadataUrl(globalSettings.BaseServiceUri.Sso, organizationId);
|
||||
SpAcsUrl = SsoConfigurationData.BuildSaml2AcsUrl(globalSettings.BaseServiceUri.Sso, organizationId);
|
||||
}
|
||||
public SsoUrls(string organizationId, GlobalSettings globalSettings)
|
||||
{
|
||||
CallbackPath = SsoConfigurationData.BuildCallbackPath(globalSettings.BaseServiceUri.Sso);
|
||||
SignedOutCallbackPath = SsoConfigurationData.BuildSignedOutCallbackPath(globalSettings.BaseServiceUri.Sso);
|
||||
SpEntityId = SsoConfigurationData.BuildSaml2ModulePath(globalSettings.BaseServiceUri.Sso);
|
||||
SpMetadataUrl = SsoConfigurationData.BuildSaml2MetadataUrl(globalSettings.BaseServiceUri.Sso, organizationId);
|
||||
SpAcsUrl = SsoConfigurationData.BuildSaml2AcsUrl(globalSettings.BaseServiceUri.Sso, organizationId);
|
||||
}
|
||||
|
||||
public string CallbackPath { get; set; }
|
||||
public string SignedOutCallbackPath { get; set; }
|
||||
public string SpEntityId { get; set; }
|
||||
public string SpMetadataUrl { get; set; }
|
||||
public string SpAcsUrl { get; set; }
|
||||
public string CallbackPath { get; set; }
|
||||
public string SignedOutCallbackPath { get; set; }
|
||||
public string SpEntityId { get; set; }
|
||||
public string SpMetadataUrl { get; set; }
|
||||
public string SpAcsUrl { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -5,138 +5,139 @@ using Bit.Core.Models.Data;
|
||||
using Bit.Core.Models.Data.Organizations.OrganizationUsers;
|
||||
using Bit.Core.Utilities;
|
||||
|
||||
namespace Bit.Api.Models.Response.Organizations;
|
||||
|
||||
public class OrganizationUserResponseModel : ResponseModel
|
||||
namespace Bit.Api.Models.Response.Organizations
|
||||
{
|
||||
public OrganizationUserResponseModel(OrganizationUser organizationUser, string obj = "organizationUser")
|
||||
: base(obj)
|
||||
public class OrganizationUserResponseModel : ResponseModel
|
||||
{
|
||||
if (organizationUser == null)
|
||||
public OrganizationUserResponseModel(OrganizationUser organizationUser, string obj = "organizationUser")
|
||||
: base(obj)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(organizationUser));
|
||||
if (organizationUser == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(organizationUser));
|
||||
}
|
||||
|
||||
Id = organizationUser.Id.ToString();
|
||||
UserId = organizationUser.UserId?.ToString();
|
||||
Type = organizationUser.Type;
|
||||
Status = organizationUser.Status;
|
||||
AccessAll = organizationUser.AccessAll;
|
||||
Permissions = CoreHelpers.LoadClassFromJsonData<Permissions>(organizationUser.Permissions);
|
||||
ResetPasswordEnrolled = !string.IsNullOrEmpty(organizationUser.ResetPasswordKey);
|
||||
}
|
||||
|
||||
Id = organizationUser.Id.ToString();
|
||||
UserId = organizationUser.UserId?.ToString();
|
||||
Type = organizationUser.Type;
|
||||
Status = organizationUser.Status;
|
||||
AccessAll = organizationUser.AccessAll;
|
||||
Permissions = CoreHelpers.LoadClassFromJsonData<Permissions>(organizationUser.Permissions);
|
||||
ResetPasswordEnrolled = !string.IsNullOrEmpty(organizationUser.ResetPasswordKey);
|
||||
}
|
||||
|
||||
public OrganizationUserResponseModel(OrganizationUserUserDetails organizationUser, string obj = "organizationUser")
|
||||
: base(obj)
|
||||
{
|
||||
if (organizationUser == null)
|
||||
public OrganizationUserResponseModel(OrganizationUserUserDetails organizationUser, string obj = "organizationUser")
|
||||
: base(obj)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(organizationUser));
|
||||
if (organizationUser == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(organizationUser));
|
||||
}
|
||||
|
||||
Id = organizationUser.Id.ToString();
|
||||
UserId = organizationUser.UserId?.ToString();
|
||||
Type = organizationUser.Type;
|
||||
Status = organizationUser.Status;
|
||||
AccessAll = organizationUser.AccessAll;
|
||||
Permissions = CoreHelpers.LoadClassFromJsonData<Permissions>(organizationUser.Permissions);
|
||||
ResetPasswordEnrolled = !string.IsNullOrEmpty(organizationUser.ResetPasswordKey);
|
||||
UsesKeyConnector = organizationUser.UsesKeyConnector;
|
||||
}
|
||||
|
||||
Id = organizationUser.Id.ToString();
|
||||
UserId = organizationUser.UserId?.ToString();
|
||||
Type = organizationUser.Type;
|
||||
Status = organizationUser.Status;
|
||||
AccessAll = organizationUser.AccessAll;
|
||||
Permissions = CoreHelpers.LoadClassFromJsonData<Permissions>(organizationUser.Permissions);
|
||||
ResetPasswordEnrolled = !string.IsNullOrEmpty(organizationUser.ResetPasswordKey);
|
||||
UsesKeyConnector = organizationUser.UsesKeyConnector;
|
||||
public string Id { get; set; }
|
||||
public string UserId { get; set; }
|
||||
public OrganizationUserType Type { get; set; }
|
||||
public OrganizationUserStatusType Status { get; set; }
|
||||
public bool AccessAll { get; set; }
|
||||
public Permissions Permissions { get; set; }
|
||||
public bool ResetPasswordEnrolled { get; set; }
|
||||
public bool UsesKeyConnector { get; set; }
|
||||
}
|
||||
|
||||
public string Id { get; set; }
|
||||
public string UserId { get; set; }
|
||||
public OrganizationUserType Type { get; set; }
|
||||
public OrganizationUserStatusType Status { get; set; }
|
||||
public bool AccessAll { get; set; }
|
||||
public Permissions Permissions { get; set; }
|
||||
public bool ResetPasswordEnrolled { get; set; }
|
||||
public bool UsesKeyConnector { get; set; }
|
||||
}
|
||||
|
||||
public class OrganizationUserDetailsResponseModel : OrganizationUserResponseModel
|
||||
{
|
||||
public OrganizationUserDetailsResponseModel(OrganizationUser organizationUser,
|
||||
IEnumerable<SelectionReadOnly> collections)
|
||||
: base(organizationUser, "organizationUserDetails")
|
||||
public class OrganizationUserDetailsResponseModel : OrganizationUserResponseModel
|
||||
{
|
||||
Collections = collections.Select(c => new SelectionReadOnlyResponseModel(c));
|
||||
}
|
||||
|
||||
public IEnumerable<SelectionReadOnlyResponseModel> Collections { get; set; }
|
||||
}
|
||||
|
||||
public class OrganizationUserUserDetailsResponseModel : OrganizationUserResponseModel
|
||||
{
|
||||
public OrganizationUserUserDetailsResponseModel(OrganizationUserUserDetails organizationUser,
|
||||
bool twoFactorEnabled, string obj = "organizationUserUserDetails")
|
||||
: base(organizationUser, obj)
|
||||
{
|
||||
if (organizationUser == null)
|
||||
public OrganizationUserDetailsResponseModel(OrganizationUser organizationUser,
|
||||
IEnumerable<SelectionReadOnly> collections)
|
||||
: base(organizationUser, "organizationUserDetails")
|
||||
{
|
||||
throw new ArgumentNullException(nameof(organizationUser));
|
||||
Collections = collections.Select(c => new SelectionReadOnlyResponseModel(c));
|
||||
}
|
||||
|
||||
Name = organizationUser.Name;
|
||||
Email = organizationUser.Email;
|
||||
TwoFactorEnabled = twoFactorEnabled;
|
||||
SsoBound = !string.IsNullOrWhiteSpace(organizationUser.SsoExternalId);
|
||||
// Prevent reset password when using key connector.
|
||||
ResetPasswordEnrolled = ResetPasswordEnrolled && !organizationUser.UsesKeyConnector;
|
||||
public IEnumerable<SelectionReadOnlyResponseModel> Collections { get; set; }
|
||||
}
|
||||
|
||||
public string Name { get; set; }
|
||||
public string Email { get; set; }
|
||||
public bool TwoFactorEnabled { get; set; }
|
||||
public bool SsoBound { get; set; }
|
||||
}
|
||||
|
||||
public class OrganizationUserResetPasswordDetailsResponseModel : ResponseModel
|
||||
{
|
||||
public OrganizationUserResetPasswordDetailsResponseModel(OrganizationUserResetPasswordDetails orgUser,
|
||||
string obj = "organizationUserResetPasswordDetails") : base(obj)
|
||||
public class OrganizationUserUserDetailsResponseModel : OrganizationUserResponseModel
|
||||
{
|
||||
if (orgUser == null)
|
||||
public OrganizationUserUserDetailsResponseModel(OrganizationUserUserDetails organizationUser,
|
||||
bool twoFactorEnabled, string obj = "organizationUserUserDetails")
|
||||
: base(organizationUser, obj)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(orgUser));
|
||||
if (organizationUser == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(organizationUser));
|
||||
}
|
||||
|
||||
Name = organizationUser.Name;
|
||||
Email = organizationUser.Email;
|
||||
TwoFactorEnabled = twoFactorEnabled;
|
||||
SsoBound = !string.IsNullOrWhiteSpace(organizationUser.SsoExternalId);
|
||||
// Prevent reset password when using key connector.
|
||||
ResetPasswordEnrolled = ResetPasswordEnrolled && !organizationUser.UsesKeyConnector;
|
||||
}
|
||||
|
||||
Kdf = orgUser.Kdf;
|
||||
KdfIterations = orgUser.KdfIterations;
|
||||
ResetPasswordKey = orgUser.ResetPasswordKey;
|
||||
EncryptedPrivateKey = orgUser.EncryptedPrivateKey;
|
||||
public string Name { get; set; }
|
||||
public string Email { get; set; }
|
||||
public bool TwoFactorEnabled { get; set; }
|
||||
public bool SsoBound { get; set; }
|
||||
}
|
||||
|
||||
public KdfType Kdf { get; set; }
|
||||
public int KdfIterations { get; set; }
|
||||
public string ResetPasswordKey { get; set; }
|
||||
public string EncryptedPrivateKey { get; set; }
|
||||
}
|
||||
|
||||
public class OrganizationUserPublicKeyResponseModel : ResponseModel
|
||||
{
|
||||
public OrganizationUserPublicKeyResponseModel(Guid id, Guid userId,
|
||||
string key, string obj = "organizationUserPublicKeyResponseModel") :
|
||||
base(obj)
|
||||
public class OrganizationUserResetPasswordDetailsResponseModel : ResponseModel
|
||||
{
|
||||
Id = id;
|
||||
UserId = userId;
|
||||
Key = key;
|
||||
public OrganizationUserResetPasswordDetailsResponseModel(OrganizationUserResetPasswordDetails orgUser,
|
||||
string obj = "organizationUserResetPasswordDetails") : base(obj)
|
||||
{
|
||||
if (orgUser == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(orgUser));
|
||||
}
|
||||
|
||||
Kdf = orgUser.Kdf;
|
||||
KdfIterations = orgUser.KdfIterations;
|
||||
ResetPasswordKey = orgUser.ResetPasswordKey;
|
||||
EncryptedPrivateKey = orgUser.EncryptedPrivateKey;
|
||||
}
|
||||
|
||||
public KdfType Kdf { get; set; }
|
||||
public int KdfIterations { get; set; }
|
||||
public string ResetPasswordKey { get; set; }
|
||||
public string EncryptedPrivateKey { get; set; }
|
||||
}
|
||||
|
||||
public Guid Id { get; set; }
|
||||
public Guid UserId { get; set; }
|
||||
public string Key { get; set; }
|
||||
}
|
||||
|
||||
public class OrganizationUserBulkResponseModel : ResponseModel
|
||||
{
|
||||
public OrganizationUserBulkResponseModel(Guid id, string error,
|
||||
string obj = "OrganizationBulkConfirmResponseModel") : base(obj)
|
||||
public class OrganizationUserPublicKeyResponseModel : ResponseModel
|
||||
{
|
||||
Id = id;
|
||||
Error = error;
|
||||
public OrganizationUserPublicKeyResponseModel(Guid id, Guid userId,
|
||||
string key, string obj = "organizationUserPublicKeyResponseModel") :
|
||||
base(obj)
|
||||
{
|
||||
Id = id;
|
||||
UserId = userId;
|
||||
Key = key;
|
||||
}
|
||||
|
||||
public Guid Id { get; set; }
|
||||
public Guid UserId { get; set; }
|
||||
public string Key { get; set; }
|
||||
}
|
||||
|
||||
public class OrganizationUserBulkResponseModel : ResponseModel
|
||||
{
|
||||
public OrganizationUserBulkResponseModel(Guid id, string error,
|
||||
string obj = "OrganizationBulkConfirmResponseModel") : base(obj)
|
||||
{
|
||||
Id = id;
|
||||
Error = error;
|
||||
}
|
||||
public Guid Id { get; set; }
|
||||
public string Error { get; set; }
|
||||
}
|
||||
public Guid Id { get; set; }
|
||||
public string Error { get; set; }
|
||||
}
|
||||
|
@ -1,14 +1,15 @@
|
||||
using Bit.Core.Models.Api;
|
||||
|
||||
namespace Bit.Api.Models.Response;
|
||||
|
||||
public class PaymentResponseModel : ResponseModel
|
||||
namespace Bit.Api.Models.Response
|
||||
{
|
||||
public PaymentResponseModel()
|
||||
: base("payment")
|
||||
{ }
|
||||
public class PaymentResponseModel : ResponseModel
|
||||
{
|
||||
public PaymentResponseModel()
|
||||
: base("payment")
|
||||
{ }
|
||||
|
||||
public ProfileResponseModel UserProfile { get; set; }
|
||||
public string PaymentIntentClientSecret { get; set; }
|
||||
public bool Success { get; set; }
|
||||
public ProfileResponseModel UserProfile { get; set; }
|
||||
public string PaymentIntentClientSecret { get; set; }
|
||||
public bool Success { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -2,100 +2,101 @@
|
||||
using Bit.Core.Models.Api;
|
||||
using Bit.Core.Models.StaticStore;
|
||||
|
||||
namespace Bit.Api.Models.Response;
|
||||
|
||||
public class PlanResponseModel : ResponseModel
|
||||
namespace Bit.Api.Models.Response
|
||||
{
|
||||
public PlanResponseModel(Plan plan, string obj = "plan")
|
||||
: base(obj)
|
||||
public class PlanResponseModel : ResponseModel
|
||||
{
|
||||
if (plan == null)
|
||||
public PlanResponseModel(Plan plan, string obj = "plan")
|
||||
: base(obj)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(plan));
|
||||
if (plan == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(plan));
|
||||
}
|
||||
|
||||
Type = plan.Type;
|
||||
Product = plan.Product;
|
||||
Name = plan.Name;
|
||||
IsAnnual = plan.IsAnnual;
|
||||
NameLocalizationKey = plan.NameLocalizationKey;
|
||||
DescriptionLocalizationKey = plan.DescriptionLocalizationKey;
|
||||
CanBeUsedByBusiness = plan.CanBeUsedByBusiness;
|
||||
BaseSeats = plan.BaseSeats;
|
||||
BaseStorageGb = plan.BaseStorageGb;
|
||||
MaxCollections = plan.MaxCollections;
|
||||
MaxUsers = plan.MaxUsers;
|
||||
HasAdditionalSeatsOption = plan.HasAdditionalSeatsOption;
|
||||
HasAdditionalStorageOption = plan.HasAdditionalStorageOption;
|
||||
MaxAdditionalSeats = plan.MaxAdditionalSeats;
|
||||
MaxAdditionalStorage = plan.MaxAdditionalStorage;
|
||||
HasPremiumAccessOption = plan.HasPremiumAccessOption;
|
||||
TrialPeriodDays = plan.TrialPeriodDays;
|
||||
HasSelfHost = plan.HasSelfHost;
|
||||
HasPolicies = plan.HasPolicies;
|
||||
HasGroups = plan.HasGroups;
|
||||
HasDirectory = plan.HasDirectory;
|
||||
HasEvents = plan.HasEvents;
|
||||
HasTotp = plan.HasTotp;
|
||||
Has2fa = plan.Has2fa;
|
||||
HasSso = plan.HasSso;
|
||||
HasResetPassword = plan.HasResetPassword;
|
||||
UsersGetPremium = plan.UsersGetPremium;
|
||||
UpgradeSortOrder = plan.UpgradeSortOrder;
|
||||
DisplaySortOrder = plan.DisplaySortOrder;
|
||||
LegacyYear = plan.LegacyYear;
|
||||
Disabled = plan.Disabled;
|
||||
StripePlanId = plan.StripePlanId;
|
||||
StripeSeatPlanId = plan.StripeSeatPlanId;
|
||||
StripeStoragePlanId = plan.StripeStoragePlanId;
|
||||
BasePrice = plan.BasePrice;
|
||||
SeatPrice = plan.SeatPrice;
|
||||
AdditionalStoragePricePerGb = plan.AdditionalStoragePricePerGb;
|
||||
PremiumAccessOptionPrice = plan.PremiumAccessOptionPrice;
|
||||
}
|
||||
|
||||
Type = plan.Type;
|
||||
Product = plan.Product;
|
||||
Name = plan.Name;
|
||||
IsAnnual = plan.IsAnnual;
|
||||
NameLocalizationKey = plan.NameLocalizationKey;
|
||||
DescriptionLocalizationKey = plan.DescriptionLocalizationKey;
|
||||
CanBeUsedByBusiness = plan.CanBeUsedByBusiness;
|
||||
BaseSeats = plan.BaseSeats;
|
||||
BaseStorageGb = plan.BaseStorageGb;
|
||||
MaxCollections = plan.MaxCollections;
|
||||
MaxUsers = plan.MaxUsers;
|
||||
HasAdditionalSeatsOption = plan.HasAdditionalSeatsOption;
|
||||
HasAdditionalStorageOption = plan.HasAdditionalStorageOption;
|
||||
MaxAdditionalSeats = plan.MaxAdditionalSeats;
|
||||
MaxAdditionalStorage = plan.MaxAdditionalStorage;
|
||||
HasPremiumAccessOption = plan.HasPremiumAccessOption;
|
||||
TrialPeriodDays = plan.TrialPeriodDays;
|
||||
HasSelfHost = plan.HasSelfHost;
|
||||
HasPolicies = plan.HasPolicies;
|
||||
HasGroups = plan.HasGroups;
|
||||
HasDirectory = plan.HasDirectory;
|
||||
HasEvents = plan.HasEvents;
|
||||
HasTotp = plan.HasTotp;
|
||||
Has2fa = plan.Has2fa;
|
||||
HasSso = plan.HasSso;
|
||||
HasResetPassword = plan.HasResetPassword;
|
||||
UsersGetPremium = plan.UsersGetPremium;
|
||||
UpgradeSortOrder = plan.UpgradeSortOrder;
|
||||
DisplaySortOrder = plan.DisplaySortOrder;
|
||||
LegacyYear = plan.LegacyYear;
|
||||
Disabled = plan.Disabled;
|
||||
StripePlanId = plan.StripePlanId;
|
||||
StripeSeatPlanId = plan.StripeSeatPlanId;
|
||||
StripeStoragePlanId = plan.StripeStoragePlanId;
|
||||
BasePrice = plan.BasePrice;
|
||||
SeatPrice = plan.SeatPrice;
|
||||
AdditionalStoragePricePerGb = plan.AdditionalStoragePricePerGb;
|
||||
PremiumAccessOptionPrice = plan.PremiumAccessOptionPrice;
|
||||
public PlanType Type { get; set; }
|
||||
public ProductType Product { get; set; }
|
||||
public string Name { get; set; }
|
||||
public bool IsAnnual { get; set; }
|
||||
public string NameLocalizationKey { get; set; }
|
||||
public string DescriptionLocalizationKey { get; set; }
|
||||
public bool CanBeUsedByBusiness { get; set; }
|
||||
public int BaseSeats { get; set; }
|
||||
public short? BaseStorageGb { get; set; }
|
||||
public short? MaxCollections { get; set; }
|
||||
public short? MaxUsers { get; set; }
|
||||
|
||||
public bool HasAdditionalSeatsOption { get; set; }
|
||||
public int? MaxAdditionalSeats { get; set; }
|
||||
public bool HasAdditionalStorageOption { get; set; }
|
||||
public short? MaxAdditionalStorage { get; set; }
|
||||
public bool HasPremiumAccessOption { get; set; }
|
||||
public int? TrialPeriodDays { get; set; }
|
||||
|
||||
public bool HasSelfHost { get; set; }
|
||||
public bool HasPolicies { get; set; }
|
||||
public bool HasGroups { get; set; }
|
||||
public bool HasDirectory { get; set; }
|
||||
public bool HasEvents { get; set; }
|
||||
public bool HasTotp { get; set; }
|
||||
public bool Has2fa { get; set; }
|
||||
public bool HasApi { get; set; }
|
||||
public bool HasSso { get; set; }
|
||||
public bool HasResetPassword { get; set; }
|
||||
public bool UsersGetPremium { get; set; }
|
||||
|
||||
public int UpgradeSortOrder { get; set; }
|
||||
public int DisplaySortOrder { get; set; }
|
||||
public int? LegacyYear { get; set; }
|
||||
public bool Disabled { get; set; }
|
||||
|
||||
public string StripePlanId { get; set; }
|
||||
public string StripeSeatPlanId { get; set; }
|
||||
public string StripeStoragePlanId { get; set; }
|
||||
public string StripePremiumAccessPlanId { get; set; }
|
||||
public decimal BasePrice { get; set; }
|
||||
public decimal SeatPrice { get; set; }
|
||||
public decimal AdditionalStoragePricePerGb { get; set; }
|
||||
public decimal PremiumAccessOptionPrice { get; set; }
|
||||
}
|
||||
|
||||
public PlanType Type { get; set; }
|
||||
public ProductType Product { get; set; }
|
||||
public string Name { get; set; }
|
||||
public bool IsAnnual { get; set; }
|
||||
public string NameLocalizationKey { get; set; }
|
||||
public string DescriptionLocalizationKey { get; set; }
|
||||
public bool CanBeUsedByBusiness { get; set; }
|
||||
public int BaseSeats { get; set; }
|
||||
public short? BaseStorageGb { get; set; }
|
||||
public short? MaxCollections { get; set; }
|
||||
public short? MaxUsers { get; set; }
|
||||
|
||||
public bool HasAdditionalSeatsOption { get; set; }
|
||||
public int? MaxAdditionalSeats { get; set; }
|
||||
public bool HasAdditionalStorageOption { get; set; }
|
||||
public short? MaxAdditionalStorage { get; set; }
|
||||
public bool HasPremiumAccessOption { get; set; }
|
||||
public int? TrialPeriodDays { get; set; }
|
||||
|
||||
public bool HasSelfHost { get; set; }
|
||||
public bool HasPolicies { get; set; }
|
||||
public bool HasGroups { get; set; }
|
||||
public bool HasDirectory { get; set; }
|
||||
public bool HasEvents { get; set; }
|
||||
public bool HasTotp { get; set; }
|
||||
public bool Has2fa { get; set; }
|
||||
public bool HasApi { get; set; }
|
||||
public bool HasSso { get; set; }
|
||||
public bool HasResetPassword { get; set; }
|
||||
public bool UsersGetPremium { get; set; }
|
||||
|
||||
public int UpgradeSortOrder { get; set; }
|
||||
public int DisplaySortOrder { get; set; }
|
||||
public int? LegacyYear { get; set; }
|
||||
public bool Disabled { get; set; }
|
||||
|
||||
public string StripePlanId { get; set; }
|
||||
public string StripeSeatPlanId { get; set; }
|
||||
public string StripeStoragePlanId { get; set; }
|
||||
public string StripePremiumAccessPlanId { get; set; }
|
||||
public decimal BasePrice { get; set; }
|
||||
public decimal SeatPrice { get; set; }
|
||||
public decimal AdditionalStoragePricePerGb { get; set; }
|
||||
public decimal PremiumAccessOptionPrice { get; set; }
|
||||
}
|
||||
|
@ -3,31 +3,32 @@ using Bit.Core.Entities;
|
||||
using Bit.Core.Enums;
|
||||
using Bit.Core.Models.Api;
|
||||
|
||||
namespace Bit.Api.Models.Response;
|
||||
|
||||
public class PolicyResponseModel : ResponseModel
|
||||
namespace Bit.Api.Models.Response
|
||||
{
|
||||
public PolicyResponseModel(Policy policy, string obj = "policy")
|
||||
: base(obj)
|
||||
public class PolicyResponseModel : ResponseModel
|
||||
{
|
||||
if (policy == null)
|
||||
public PolicyResponseModel(Policy policy, string obj = "policy")
|
||||
: base(obj)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(policy));
|
||||
if (policy == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(policy));
|
||||
}
|
||||
|
||||
Id = policy.Id.ToString();
|
||||
OrganizationId = policy.OrganizationId.ToString();
|
||||
Type = policy.Type;
|
||||
Enabled = policy.Enabled;
|
||||
if (!string.IsNullOrWhiteSpace(policy.Data))
|
||||
{
|
||||
Data = JsonSerializer.Deserialize<Dictionary<string, object>>(policy.Data);
|
||||
}
|
||||
}
|
||||
|
||||
Id = policy.Id.ToString();
|
||||
OrganizationId = policy.OrganizationId.ToString();
|
||||
Type = policy.Type;
|
||||
Enabled = policy.Enabled;
|
||||
if (!string.IsNullOrWhiteSpace(policy.Data))
|
||||
{
|
||||
Data = JsonSerializer.Deserialize<Dictionary<string, object>>(policy.Data);
|
||||
}
|
||||
public string Id { get; set; }
|
||||
public string OrganizationId { get; set; }
|
||||
public PolicyType Type { get; set; }
|
||||
public Dictionary<string, object> Data { get; set; }
|
||||
public bool Enabled { get; set; }
|
||||
}
|
||||
|
||||
public string Id { get; set; }
|
||||
public string OrganizationId { get; set; }
|
||||
public PolicyType Type { get; set; }
|
||||
public Dictionary<string, object> Data { get; set; }
|
||||
public bool Enabled { get; set; }
|
||||
}
|
||||
|
@ -4,97 +4,98 @@ using Bit.Core.Models.Data;
|
||||
using Bit.Core.Models.Data.Organizations.OrganizationUsers;
|
||||
using Bit.Core.Utilities;
|
||||
|
||||
namespace Bit.Api.Models.Response;
|
||||
|
||||
public class ProfileOrganizationResponseModel : ResponseModel
|
||||
namespace Bit.Api.Models.Response
|
||||
{
|
||||
public ProfileOrganizationResponseModel(string str) : base(str) { }
|
||||
|
||||
public ProfileOrganizationResponseModel(OrganizationUserOrganizationDetails organization) : this("profileOrganization")
|
||||
public class ProfileOrganizationResponseModel : ResponseModel
|
||||
{
|
||||
Id = organization.OrganizationId.ToString();
|
||||
Name = organization.Name;
|
||||
UsePolicies = organization.UsePolicies;
|
||||
UseSso = organization.UseSso;
|
||||
UseKeyConnector = organization.UseKeyConnector;
|
||||
UseScim = organization.UseScim;
|
||||
UseGroups = organization.UseGroups;
|
||||
UseDirectory = organization.UseDirectory;
|
||||
UseEvents = organization.UseEvents;
|
||||
UseTotp = organization.UseTotp;
|
||||
Use2fa = organization.Use2fa;
|
||||
UseApi = organization.UseApi;
|
||||
UseResetPassword = organization.UseResetPassword;
|
||||
UsersGetPremium = organization.UsersGetPremium;
|
||||
SelfHost = organization.SelfHost;
|
||||
Seats = organization.Seats;
|
||||
MaxCollections = organization.MaxCollections;
|
||||
MaxStorageGb = organization.MaxStorageGb;
|
||||
Key = organization.Key;
|
||||
HasPublicAndPrivateKeys = organization.PublicKey != null && organization.PrivateKey != null;
|
||||
Status = organization.Status;
|
||||
Type = organization.Type;
|
||||
Enabled = organization.Enabled;
|
||||
SsoBound = !string.IsNullOrWhiteSpace(organization.SsoExternalId);
|
||||
Identifier = organization.Identifier;
|
||||
Permissions = CoreHelpers.LoadClassFromJsonData<Permissions>(organization.Permissions);
|
||||
ResetPasswordEnrolled = organization.ResetPasswordKey != null;
|
||||
UserId = organization.UserId?.ToString();
|
||||
ProviderId = organization.ProviderId?.ToString();
|
||||
ProviderName = organization.ProviderName;
|
||||
FamilySponsorshipFriendlyName = organization.FamilySponsorshipFriendlyName;
|
||||
FamilySponsorshipAvailable = FamilySponsorshipFriendlyName == null &&
|
||||
StaticStore.GetSponsoredPlan(PlanSponsorshipType.FamiliesForEnterprise)
|
||||
.UsersCanSponsor(organization);
|
||||
PlanProductType = StaticStore.GetPlan(organization.PlanType).Product;
|
||||
FamilySponsorshipLastSyncDate = organization.FamilySponsorshipLastSyncDate;
|
||||
FamilySponsorshipToDelete = organization.FamilySponsorshipToDelete;
|
||||
FamilySponsorshipValidUntil = organization.FamilySponsorshipValidUntil;
|
||||
public ProfileOrganizationResponseModel(string str) : base(str) { }
|
||||
|
||||
if (organization.SsoConfig != null)
|
||||
public ProfileOrganizationResponseModel(OrganizationUserOrganizationDetails organization) : this("profileOrganization")
|
||||
{
|
||||
var ssoConfigData = SsoConfigurationData.Deserialize(organization.SsoConfig);
|
||||
KeyConnectorEnabled = ssoConfigData.KeyConnectorEnabled && !string.IsNullOrEmpty(ssoConfigData.KeyConnectorUrl);
|
||||
KeyConnectorUrl = ssoConfigData.KeyConnectorUrl;
|
||||
}
|
||||
}
|
||||
Id = organization.OrganizationId.ToString();
|
||||
Name = organization.Name;
|
||||
UsePolicies = organization.UsePolicies;
|
||||
UseSso = organization.UseSso;
|
||||
UseKeyConnector = organization.UseKeyConnector;
|
||||
UseScim = organization.UseScim;
|
||||
UseGroups = organization.UseGroups;
|
||||
UseDirectory = organization.UseDirectory;
|
||||
UseEvents = organization.UseEvents;
|
||||
UseTotp = organization.UseTotp;
|
||||
Use2fa = organization.Use2fa;
|
||||
UseApi = organization.UseApi;
|
||||
UseResetPassword = organization.UseResetPassword;
|
||||
UsersGetPremium = organization.UsersGetPremium;
|
||||
SelfHost = organization.SelfHost;
|
||||
Seats = organization.Seats;
|
||||
MaxCollections = organization.MaxCollections;
|
||||
MaxStorageGb = organization.MaxStorageGb;
|
||||
Key = organization.Key;
|
||||
HasPublicAndPrivateKeys = organization.PublicKey != null && organization.PrivateKey != null;
|
||||
Status = organization.Status;
|
||||
Type = organization.Type;
|
||||
Enabled = organization.Enabled;
|
||||
SsoBound = !string.IsNullOrWhiteSpace(organization.SsoExternalId);
|
||||
Identifier = organization.Identifier;
|
||||
Permissions = CoreHelpers.LoadClassFromJsonData<Permissions>(organization.Permissions);
|
||||
ResetPasswordEnrolled = organization.ResetPasswordKey != null;
|
||||
UserId = organization.UserId?.ToString();
|
||||
ProviderId = organization.ProviderId?.ToString();
|
||||
ProviderName = organization.ProviderName;
|
||||
FamilySponsorshipFriendlyName = organization.FamilySponsorshipFriendlyName;
|
||||
FamilySponsorshipAvailable = FamilySponsorshipFriendlyName == null &&
|
||||
StaticStore.GetSponsoredPlan(PlanSponsorshipType.FamiliesForEnterprise)
|
||||
.UsersCanSponsor(organization);
|
||||
PlanProductType = StaticStore.GetPlan(organization.PlanType).Product;
|
||||
FamilySponsorshipLastSyncDate = organization.FamilySponsorshipLastSyncDate;
|
||||
FamilySponsorshipToDelete = organization.FamilySponsorshipToDelete;
|
||||
FamilySponsorshipValidUntil = organization.FamilySponsorshipValidUntil;
|
||||
|
||||
public string Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public bool UsePolicies { get; set; }
|
||||
public bool UseSso { get; set; }
|
||||
public bool UseKeyConnector { get; set; }
|
||||
public bool UseScim { get; set; }
|
||||
public bool UseGroups { get; set; }
|
||||
public bool UseDirectory { get; set; }
|
||||
public bool UseEvents { get; set; }
|
||||
public bool UseTotp { get; set; }
|
||||
public bool Use2fa { get; set; }
|
||||
public bool UseApi { get; set; }
|
||||
public bool UseResetPassword { get; set; }
|
||||
public bool UsersGetPremium { get; set; }
|
||||
public bool SelfHost { get; set; }
|
||||
public int? Seats { get; set; }
|
||||
public short? MaxCollections { get; set; }
|
||||
public short? MaxStorageGb { get; set; }
|
||||
public string Key { get; set; }
|
||||
public OrganizationUserStatusType Status { get; set; }
|
||||
public OrganizationUserType Type { get; set; }
|
||||
public bool Enabled { get; set; }
|
||||
public bool SsoBound { get; set; }
|
||||
public string Identifier { get; set; }
|
||||
public Permissions Permissions { get; set; }
|
||||
public bool ResetPasswordEnrolled { get; set; }
|
||||
public string UserId { get; set; }
|
||||
public bool HasPublicAndPrivateKeys { get; set; }
|
||||
public string ProviderId { get; set; }
|
||||
public string ProviderName { get; set; }
|
||||
public string FamilySponsorshipFriendlyName { get; set; }
|
||||
public bool FamilySponsorshipAvailable { get; set; }
|
||||
public ProductType PlanProductType { get; set; }
|
||||
public bool KeyConnectorEnabled { get; set; }
|
||||
public string KeyConnectorUrl { get; set; }
|
||||
public DateTime? FamilySponsorshipLastSyncDate { get; set; }
|
||||
public DateTime? FamilySponsorshipValidUntil { get; set; }
|
||||
public bool? FamilySponsorshipToDelete { get; set; }
|
||||
if (organization.SsoConfig != null)
|
||||
{
|
||||
var ssoConfigData = SsoConfigurationData.Deserialize(organization.SsoConfig);
|
||||
KeyConnectorEnabled = ssoConfigData.KeyConnectorEnabled && !string.IsNullOrEmpty(ssoConfigData.KeyConnectorUrl);
|
||||
KeyConnectorUrl = ssoConfigData.KeyConnectorUrl;
|
||||
}
|
||||
}
|
||||
|
||||
public string Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public bool UsePolicies { get; set; }
|
||||
public bool UseSso { get; set; }
|
||||
public bool UseKeyConnector { get; set; }
|
||||
public bool UseScim { get; set; }
|
||||
public bool UseGroups { get; set; }
|
||||
public bool UseDirectory { get; set; }
|
||||
public bool UseEvents { get; set; }
|
||||
public bool UseTotp { get; set; }
|
||||
public bool Use2fa { get; set; }
|
||||
public bool UseApi { get; set; }
|
||||
public bool UseResetPassword { get; set; }
|
||||
public bool UsersGetPremium { get; set; }
|
||||
public bool SelfHost { get; set; }
|
||||
public int? Seats { get; set; }
|
||||
public short? MaxCollections { get; set; }
|
||||
public short? MaxStorageGb { get; set; }
|
||||
public string Key { get; set; }
|
||||
public OrganizationUserStatusType Status { get; set; }
|
||||
public OrganizationUserType Type { get; set; }
|
||||
public bool Enabled { get; set; }
|
||||
public bool SsoBound { get; set; }
|
||||
public string Identifier { get; set; }
|
||||
public Permissions Permissions { get; set; }
|
||||
public bool ResetPasswordEnrolled { get; set; }
|
||||
public string UserId { get; set; }
|
||||
public bool HasPublicAndPrivateKeys { get; set; }
|
||||
public string ProviderId { get; set; }
|
||||
public string ProviderName { get; set; }
|
||||
public string FamilySponsorshipFriendlyName { get; set; }
|
||||
public bool FamilySponsorshipAvailable { get; set; }
|
||||
public ProductType PlanProductType { get; set; }
|
||||
public bool KeyConnectorEnabled { get; set; }
|
||||
public string KeyConnectorUrl { get; set; }
|
||||
public DateTime? FamilySponsorshipLastSyncDate { get; set; }
|
||||
public DateTime? FamilySponsorshipValidUntil { get; set; }
|
||||
public bool? FamilySponsorshipToDelete { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -1,42 +1,43 @@
|
||||
using Bit.Core.Enums;
|
||||
using Bit.Core.Models.Data;
|
||||
|
||||
namespace Bit.Api.Models.Response;
|
||||
|
||||
public class ProfileProviderOrganizationResponseModel : ProfileOrganizationResponseModel
|
||||
namespace Bit.Api.Models.Response
|
||||
{
|
||||
public ProfileProviderOrganizationResponseModel(ProviderUserOrganizationDetails organization)
|
||||
: base("profileProviderOrganization")
|
||||
public class ProfileProviderOrganizationResponseModel : ProfileOrganizationResponseModel
|
||||
{
|
||||
Id = organization.OrganizationId.ToString();
|
||||
Name = organization.Name;
|
||||
UsePolicies = organization.UsePolicies;
|
||||
UseSso = organization.UseSso;
|
||||
UseKeyConnector = organization.UseKeyConnector;
|
||||
UseScim = organization.UseScim;
|
||||
UseGroups = organization.UseGroups;
|
||||
UseDirectory = organization.UseDirectory;
|
||||
UseEvents = organization.UseEvents;
|
||||
UseTotp = organization.UseTotp;
|
||||
Use2fa = organization.Use2fa;
|
||||
UseApi = organization.UseApi;
|
||||
UseResetPassword = organization.UseResetPassword;
|
||||
UsersGetPremium = organization.UsersGetPremium;
|
||||
SelfHost = organization.SelfHost;
|
||||
Seats = organization.Seats;
|
||||
MaxCollections = organization.MaxCollections;
|
||||
MaxStorageGb = organization.MaxStorageGb;
|
||||
Key = organization.Key;
|
||||
HasPublicAndPrivateKeys = organization.PublicKey != null && organization.PrivateKey != null;
|
||||
Status = OrganizationUserStatusType.Confirmed; // Provider users are always confirmed
|
||||
Type = OrganizationUserType.Owner; // Provider users behave like Owners
|
||||
Enabled = organization.Enabled;
|
||||
SsoBound = false;
|
||||
Identifier = organization.Identifier;
|
||||
Permissions = new Permissions();
|
||||
ResetPasswordEnrolled = false;
|
||||
UserId = organization.UserId?.ToString();
|
||||
ProviderId = organization.ProviderId?.ToString();
|
||||
ProviderName = organization.ProviderName;
|
||||
public ProfileProviderOrganizationResponseModel(ProviderUserOrganizationDetails organization)
|
||||
: base("profileProviderOrganization")
|
||||
{
|
||||
Id = organization.OrganizationId.ToString();
|
||||
Name = organization.Name;
|
||||
UsePolicies = organization.UsePolicies;
|
||||
UseSso = organization.UseSso;
|
||||
UseKeyConnector = organization.UseKeyConnector;
|
||||
UseScim = organization.UseScim;
|
||||
UseGroups = organization.UseGroups;
|
||||
UseDirectory = organization.UseDirectory;
|
||||
UseEvents = organization.UseEvents;
|
||||
UseTotp = organization.UseTotp;
|
||||
Use2fa = organization.Use2fa;
|
||||
UseApi = organization.UseApi;
|
||||
UseResetPassword = organization.UseResetPassword;
|
||||
UsersGetPremium = organization.UsersGetPremium;
|
||||
SelfHost = organization.SelfHost;
|
||||
Seats = organization.Seats;
|
||||
MaxCollections = organization.MaxCollections;
|
||||
MaxStorageGb = organization.MaxStorageGb;
|
||||
Key = organization.Key;
|
||||
HasPublicAndPrivateKeys = organization.PublicKey != null && organization.PrivateKey != null;
|
||||
Status = OrganizationUserStatusType.Confirmed; // Provider users are always confirmed
|
||||
Type = OrganizationUserType.Owner; // Provider users behave like Owners
|
||||
Enabled = organization.Enabled;
|
||||
SsoBound = false;
|
||||
Identifier = organization.Identifier;
|
||||
Permissions = new Permissions();
|
||||
ResetPasswordEnrolled = false;
|
||||
UserId = organization.UserId?.ToString();
|
||||
ProviderId = organization.ProviderId?.ToString();
|
||||
ProviderName = organization.ProviderName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,61 +4,62 @@ using Bit.Core.Models.Api;
|
||||
using Bit.Core.Models.Data;
|
||||
using Bit.Core.Models.Data.Organizations.OrganizationUsers;
|
||||
|
||||
namespace Bit.Api.Models.Response;
|
||||
|
||||
public class ProfileResponseModel : ResponseModel
|
||||
namespace Bit.Api.Models.Response
|
||||
{
|
||||
public ProfileResponseModel(User user,
|
||||
IEnumerable<OrganizationUserOrganizationDetails> organizationsUserDetails,
|
||||
IEnumerable<ProviderUserProviderDetails> providerUserDetails,
|
||||
IEnumerable<ProviderUserOrganizationDetails> providerUserOrganizationDetails,
|
||||
bool twoFactorEnabled,
|
||||
bool premiumFromOrganization) : base("profile")
|
||||
public class ProfileResponseModel : ResponseModel
|
||||
{
|
||||
if (user == null)
|
||||
public ProfileResponseModel(User user,
|
||||
IEnumerable<OrganizationUserOrganizationDetails> organizationsUserDetails,
|
||||
IEnumerable<ProviderUserProviderDetails> providerUserDetails,
|
||||
IEnumerable<ProviderUserOrganizationDetails> providerUserOrganizationDetails,
|
||||
bool twoFactorEnabled,
|
||||
bool premiumFromOrganization) : base("profile")
|
||||
{
|
||||
throw new ArgumentNullException(nameof(user));
|
||||
if (user == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(user));
|
||||
}
|
||||
|
||||
Id = user.Id.ToString();
|
||||
Name = user.Name;
|
||||
Email = user.Email;
|
||||
EmailVerified = user.EmailVerified;
|
||||
Premium = user.Premium;
|
||||
PremiumFromOrganization = premiumFromOrganization;
|
||||
MasterPasswordHint = string.IsNullOrWhiteSpace(user.MasterPasswordHint) ? null : user.MasterPasswordHint;
|
||||
Culture = user.Culture;
|
||||
TwoFactorEnabled = twoFactorEnabled;
|
||||
Key = user.Key;
|
||||
PrivateKey = user.PrivateKey;
|
||||
SecurityStamp = user.SecurityStamp;
|
||||
ForcePasswordReset = user.ForcePasswordReset;
|
||||
UsesKeyConnector = user.UsesKeyConnector;
|
||||
Organizations = organizationsUserDetails?.Select(o => new ProfileOrganizationResponseModel(o));
|
||||
Providers = providerUserDetails?.Select(p => new ProfileProviderResponseModel(p));
|
||||
ProviderOrganizations =
|
||||
providerUserOrganizationDetails?.Select(po => new ProfileProviderOrganizationResponseModel(po));
|
||||
}
|
||||
|
||||
Id = user.Id.ToString();
|
||||
Name = user.Name;
|
||||
Email = user.Email;
|
||||
EmailVerified = user.EmailVerified;
|
||||
Premium = user.Premium;
|
||||
PremiumFromOrganization = premiumFromOrganization;
|
||||
MasterPasswordHint = string.IsNullOrWhiteSpace(user.MasterPasswordHint) ? null : user.MasterPasswordHint;
|
||||
Culture = user.Culture;
|
||||
TwoFactorEnabled = twoFactorEnabled;
|
||||
Key = user.Key;
|
||||
PrivateKey = user.PrivateKey;
|
||||
SecurityStamp = user.SecurityStamp;
|
||||
ForcePasswordReset = user.ForcePasswordReset;
|
||||
UsesKeyConnector = user.UsesKeyConnector;
|
||||
Organizations = organizationsUserDetails?.Select(o => new ProfileOrganizationResponseModel(o));
|
||||
Providers = providerUserDetails?.Select(p => new ProfileProviderResponseModel(p));
|
||||
ProviderOrganizations =
|
||||
providerUserOrganizationDetails?.Select(po => new ProfileProviderOrganizationResponseModel(po));
|
||||
}
|
||||
public ProfileResponseModel() : base("profile")
|
||||
{
|
||||
}
|
||||
|
||||
public ProfileResponseModel() : base("profile")
|
||||
{
|
||||
public string Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Email { get; set; }
|
||||
public bool EmailVerified { get; set; }
|
||||
public bool Premium { get; set; }
|
||||
public bool PremiumFromOrganization { get; set; }
|
||||
public string MasterPasswordHint { get; set; }
|
||||
public string Culture { get; set; }
|
||||
public bool TwoFactorEnabled { get; set; }
|
||||
public string Key { get; set; }
|
||||
public string PrivateKey { get; set; }
|
||||
public string SecurityStamp { get; set; }
|
||||
public bool ForcePasswordReset { get; set; }
|
||||
public bool UsesKeyConnector { get; set; }
|
||||
public IEnumerable<ProfileOrganizationResponseModel> Organizations { get; set; }
|
||||
public IEnumerable<ProfileProviderResponseModel> Providers { get; set; }
|
||||
public IEnumerable<ProfileProviderOrganizationResponseModel> ProviderOrganizations { get; set; }
|
||||
}
|
||||
|
||||
public string Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Email { get; set; }
|
||||
public bool EmailVerified { get; set; }
|
||||
public bool Premium { get; set; }
|
||||
public bool PremiumFromOrganization { get; set; }
|
||||
public string MasterPasswordHint { get; set; }
|
||||
public string Culture { get; set; }
|
||||
public bool TwoFactorEnabled { get; set; }
|
||||
public string Key { get; set; }
|
||||
public string PrivateKey { get; set; }
|
||||
public string SecurityStamp { get; set; }
|
||||
public bool ForcePasswordReset { get; set; }
|
||||
public bool UsesKeyConnector { get; set; }
|
||||
public IEnumerable<ProfileOrganizationResponseModel> Organizations { get; set; }
|
||||
public IEnumerable<ProfileProviderResponseModel> Providers { get; set; }
|
||||
public IEnumerable<ProfileProviderOrganizationResponseModel> ProviderOrganizations { get; set; }
|
||||
}
|
||||
|
@ -3,31 +3,32 @@ using Bit.Core.Models.Api;
|
||||
using Bit.Core.Models.Data;
|
||||
using Bit.Core.Utilities;
|
||||
|
||||
namespace Bit.Api.Models.Response.Providers;
|
||||
|
||||
public class ProfileProviderResponseModel : ResponseModel
|
||||
namespace Bit.Api.Models.Response.Providers
|
||||
{
|
||||
public ProfileProviderResponseModel(ProviderUserProviderDetails provider)
|
||||
: base("profileProvider")
|
||||
public class ProfileProviderResponseModel : ResponseModel
|
||||
{
|
||||
Id = provider.ProviderId.ToString();
|
||||
Name = provider.Name;
|
||||
Key = provider.Key;
|
||||
Status = provider.Status;
|
||||
Type = provider.Type;
|
||||
Enabled = provider.Enabled;
|
||||
Permissions = CoreHelpers.LoadClassFromJsonData<Permissions>(provider.Permissions);
|
||||
UserId = provider.UserId?.ToString();
|
||||
UseEvents = provider.UseEvents;
|
||||
}
|
||||
public ProfileProviderResponseModel(ProviderUserProviderDetails provider)
|
||||
: base("profileProvider")
|
||||
{
|
||||
Id = provider.ProviderId.ToString();
|
||||
Name = provider.Name;
|
||||
Key = provider.Key;
|
||||
Status = provider.Status;
|
||||
Type = provider.Type;
|
||||
Enabled = provider.Enabled;
|
||||
Permissions = CoreHelpers.LoadClassFromJsonData<Permissions>(provider.Permissions);
|
||||
UserId = provider.UserId?.ToString();
|
||||
UseEvents = provider.UseEvents;
|
||||
}
|
||||
|
||||
public string Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Key { get; set; }
|
||||
public ProviderUserStatusType Status { get; set; }
|
||||
public ProviderUserType Type { get; set; }
|
||||
public bool Enabled { get; set; }
|
||||
public Permissions Permissions { get; set; }
|
||||
public string UserId { get; set; }
|
||||
public bool UseEvents { get; set; }
|
||||
public string Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Key { get; set; }
|
||||
public ProviderUserStatusType Status { get; set; }
|
||||
public ProviderUserType Type { get; set; }
|
||||
public bool Enabled { get; set; }
|
||||
public Permissions Permissions { get; set; }
|
||||
public string UserId { get; set; }
|
||||
public bool UseEvents { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -2,71 +2,72 @@
|
||||
using Bit.Core.Models.Api;
|
||||
using Bit.Core.Models.Data;
|
||||
|
||||
namespace Bit.Api.Models.Response.Providers;
|
||||
|
||||
public class ProviderOrganizationResponseModel : ResponseModel
|
||||
namespace Bit.Api.Models.Response.Providers
|
||||
{
|
||||
public ProviderOrganizationResponseModel(ProviderOrganization providerOrganization,
|
||||
string obj = "providerOrganization") : base(obj)
|
||||
public class ProviderOrganizationResponseModel : ResponseModel
|
||||
{
|
||||
if (providerOrganization == null)
|
||||
public ProviderOrganizationResponseModel(ProviderOrganization providerOrganization,
|
||||
string obj = "providerOrganization") : base(obj)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(providerOrganization));
|
||||
if (providerOrganization == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(providerOrganization));
|
||||
}
|
||||
|
||||
Id = providerOrganization.Id;
|
||||
ProviderId = providerOrganization.ProviderId;
|
||||
OrganizationId = providerOrganization.OrganizationId;
|
||||
Key = providerOrganization.Key;
|
||||
Settings = providerOrganization.Settings;
|
||||
CreationDate = providerOrganization.CreationDate;
|
||||
RevisionDate = providerOrganization.RevisionDate;
|
||||
}
|
||||
|
||||
Id = providerOrganization.Id;
|
||||
ProviderId = providerOrganization.ProviderId;
|
||||
OrganizationId = providerOrganization.OrganizationId;
|
||||
Key = providerOrganization.Key;
|
||||
Settings = providerOrganization.Settings;
|
||||
CreationDate = providerOrganization.CreationDate;
|
||||
RevisionDate = providerOrganization.RevisionDate;
|
||||
}
|
||||
|
||||
public ProviderOrganizationResponseModel(ProviderOrganizationOrganizationDetails providerOrganization,
|
||||
string obj = "providerOrganization") : base(obj)
|
||||
{
|
||||
if (providerOrganization == null)
|
||||
public ProviderOrganizationResponseModel(ProviderOrganizationOrganizationDetails providerOrganization,
|
||||
string obj = "providerOrganization") : base(obj)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(providerOrganization));
|
||||
if (providerOrganization == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(providerOrganization));
|
||||
}
|
||||
|
||||
Id = providerOrganization.Id;
|
||||
ProviderId = providerOrganization.ProviderId;
|
||||
OrganizationId = providerOrganization.OrganizationId;
|
||||
Key = providerOrganization.Key;
|
||||
Settings = providerOrganization.Settings;
|
||||
CreationDate = providerOrganization.CreationDate;
|
||||
RevisionDate = providerOrganization.RevisionDate;
|
||||
UserCount = providerOrganization.UserCount;
|
||||
Seats = providerOrganization.Seats;
|
||||
Plan = providerOrganization.Plan;
|
||||
}
|
||||
|
||||
Id = providerOrganization.Id;
|
||||
ProviderId = providerOrganization.ProviderId;
|
||||
OrganizationId = providerOrganization.OrganizationId;
|
||||
Key = providerOrganization.Key;
|
||||
Settings = providerOrganization.Settings;
|
||||
CreationDate = providerOrganization.CreationDate;
|
||||
RevisionDate = providerOrganization.RevisionDate;
|
||||
UserCount = providerOrganization.UserCount;
|
||||
Seats = providerOrganization.Seats;
|
||||
Plan = providerOrganization.Plan;
|
||||
public Guid Id { get; set; }
|
||||
public Guid ProviderId { get; set; }
|
||||
public Guid OrganizationId { get; set; }
|
||||
public string Key { get; set; }
|
||||
public string Settings { get; set; }
|
||||
public DateTime CreationDate { get; set; }
|
||||
public DateTime RevisionDate { get; set; }
|
||||
public int UserCount { get; set; }
|
||||
public int? Seats { get; set; }
|
||||
public string Plan { get; set; }
|
||||
}
|
||||
|
||||
public Guid Id { get; set; }
|
||||
public Guid ProviderId { get; set; }
|
||||
public Guid OrganizationId { get; set; }
|
||||
public string Key { get; set; }
|
||||
public string Settings { get; set; }
|
||||
public DateTime CreationDate { get; set; }
|
||||
public DateTime RevisionDate { get; set; }
|
||||
public int UserCount { get; set; }
|
||||
public int? Seats { get; set; }
|
||||
public string Plan { get; set; }
|
||||
}
|
||||
|
||||
public class ProviderOrganizationOrganizationDetailsResponseModel : ProviderOrganizationResponseModel
|
||||
{
|
||||
public ProviderOrganizationOrganizationDetailsResponseModel(ProviderOrganizationOrganizationDetails providerOrganization,
|
||||
string obj = "providerOrganizationOrganizationDetail") : base(providerOrganization, obj)
|
||||
{
|
||||
if (providerOrganization == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(providerOrganization));
|
||||
}
|
||||
|
||||
OrganizationName = providerOrganization.OrganizationName;
|
||||
}
|
||||
|
||||
public string OrganizationName { get; set; }
|
||||
public class ProviderOrganizationOrganizationDetailsResponseModel : ProviderOrganizationResponseModel
|
||||
{
|
||||
public ProviderOrganizationOrganizationDetailsResponseModel(ProviderOrganizationOrganizationDetails providerOrganization,
|
||||
string obj = "providerOrganizationOrganizationDetail") : base(providerOrganization, obj)
|
||||
{
|
||||
if (providerOrganization == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(providerOrganization));
|
||||
}
|
||||
|
||||
OrganizationName = providerOrganization.OrganizationName;
|
||||
}
|
||||
|
||||
public string OrganizationName { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -1,35 +1,36 @@
|
||||
using Bit.Core.Entities.Provider;
|
||||
using Bit.Core.Models.Api;
|
||||
|
||||
namespace Bit.Api.Models.Response.Providers;
|
||||
|
||||
public class ProviderResponseModel : ResponseModel
|
||||
namespace Bit.Api.Models.Response.Providers
|
||||
{
|
||||
public ProviderResponseModel(Provider provider, string obj = "provider") : base(obj)
|
||||
public class ProviderResponseModel : ResponseModel
|
||||
{
|
||||
if (provider == null)
|
||||
public ProviderResponseModel(Provider provider, string obj = "provider") : base(obj)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(provider));
|
||||
if (provider == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(provider));
|
||||
}
|
||||
|
||||
Id = provider.Id;
|
||||
Name = provider.Name;
|
||||
BusinessName = provider.BusinessName;
|
||||
BusinessAddress1 = provider.BusinessAddress1;
|
||||
BusinessAddress2 = provider.BusinessAddress2;
|
||||
BusinessAddress3 = provider.BusinessAddress3;
|
||||
BusinessCountry = provider.BusinessCountry;
|
||||
BusinessTaxNumber = provider.BusinessTaxNumber;
|
||||
BillingEmail = provider.BillingEmail;
|
||||
}
|
||||
|
||||
Id = provider.Id;
|
||||
Name = provider.Name;
|
||||
BusinessName = provider.BusinessName;
|
||||
BusinessAddress1 = provider.BusinessAddress1;
|
||||
BusinessAddress2 = provider.BusinessAddress2;
|
||||
BusinessAddress3 = provider.BusinessAddress3;
|
||||
BusinessCountry = provider.BusinessCountry;
|
||||
BusinessTaxNumber = provider.BusinessTaxNumber;
|
||||
BillingEmail = provider.BillingEmail;
|
||||
public Guid Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string BusinessName { get; set; }
|
||||
public string BusinessAddress1 { get; set; }
|
||||
public string BusinessAddress2 { get; set; }
|
||||
public string BusinessAddress3 { get; set; }
|
||||
public string BusinessCountry { get; set; }
|
||||
public string BusinessTaxNumber { get; set; }
|
||||
public string BillingEmail { get; set; }
|
||||
}
|
||||
|
||||
public Guid Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string BusinessName { get; set; }
|
||||
public string BusinessAddress1 { get; set; }
|
||||
public string BusinessAddress2 { get; set; }
|
||||
public string BusinessAddress3 { get; set; }
|
||||
public string BusinessCountry { get; set; }
|
||||
public string BusinessTaxNumber { get; set; }
|
||||
public string BillingEmail { get; set; }
|
||||
}
|
||||
|
@ -4,88 +4,89 @@ using Bit.Core.Models.Api;
|
||||
using Bit.Core.Models.Data;
|
||||
using Bit.Core.Utilities;
|
||||
|
||||
namespace Bit.Api.Models.Response.Providers;
|
||||
|
||||
public class ProviderUserResponseModel : ResponseModel
|
||||
namespace Bit.Api.Models.Response.Providers
|
||||
{
|
||||
public ProviderUserResponseModel(ProviderUser providerUser, string obj = "providerUser")
|
||||
: base(obj)
|
||||
public class ProviderUserResponseModel : ResponseModel
|
||||
{
|
||||
if (providerUser == null)
|
||||
public ProviderUserResponseModel(ProviderUser providerUser, string obj = "providerUser")
|
||||
: base(obj)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(providerUser));
|
||||
if (providerUser == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(providerUser));
|
||||
}
|
||||
|
||||
Id = providerUser.Id.ToString();
|
||||
UserId = providerUser.UserId?.ToString();
|
||||
Type = providerUser.Type;
|
||||
Status = providerUser.Status;
|
||||
Permissions = CoreHelpers.LoadClassFromJsonData<Permissions>(providerUser.Permissions);
|
||||
}
|
||||
|
||||
Id = providerUser.Id.ToString();
|
||||
UserId = providerUser.UserId?.ToString();
|
||||
Type = providerUser.Type;
|
||||
Status = providerUser.Status;
|
||||
Permissions = CoreHelpers.LoadClassFromJsonData<Permissions>(providerUser.Permissions);
|
||||
}
|
||||
|
||||
public ProviderUserResponseModel(ProviderUserUserDetails providerUser, string obj = "providerUser")
|
||||
: base(obj)
|
||||
{
|
||||
if (providerUser == null)
|
||||
public ProviderUserResponseModel(ProviderUserUserDetails providerUser, string obj = "providerUser")
|
||||
: base(obj)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(providerUser));
|
||||
if (providerUser == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(providerUser));
|
||||
}
|
||||
|
||||
Id = providerUser.Id.ToString();
|
||||
UserId = providerUser.UserId?.ToString();
|
||||
Type = providerUser.Type;
|
||||
Status = providerUser.Status;
|
||||
Permissions = CoreHelpers.LoadClassFromJsonData<Permissions>(providerUser.Permissions);
|
||||
}
|
||||
|
||||
Id = providerUser.Id.ToString();
|
||||
UserId = providerUser.UserId?.ToString();
|
||||
Type = providerUser.Type;
|
||||
Status = providerUser.Status;
|
||||
Permissions = CoreHelpers.LoadClassFromJsonData<Permissions>(providerUser.Permissions);
|
||||
public string Id { get; set; }
|
||||
public string UserId { get; set; }
|
||||
public ProviderUserType Type { get; set; }
|
||||
public ProviderUserStatusType Status { get; set; }
|
||||
public Permissions Permissions { get; set; }
|
||||
}
|
||||
|
||||
public string Id { get; set; }
|
||||
public string UserId { get; set; }
|
||||
public ProviderUserType Type { get; set; }
|
||||
public ProviderUserStatusType Status { get; set; }
|
||||
public Permissions Permissions { get; set; }
|
||||
}
|
||||
|
||||
public class ProviderUserUserDetailsResponseModel : ProviderUserResponseModel
|
||||
{
|
||||
public ProviderUserUserDetailsResponseModel(ProviderUserUserDetails providerUser,
|
||||
string obj = "providerUserUserDetails") : base(providerUser, obj)
|
||||
public class ProviderUserUserDetailsResponseModel : ProviderUserResponseModel
|
||||
{
|
||||
if (providerUser == null)
|
||||
public ProviderUserUserDetailsResponseModel(ProviderUserUserDetails providerUser,
|
||||
string obj = "providerUserUserDetails") : base(providerUser, obj)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(providerUser));
|
||||
if (providerUser == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(providerUser));
|
||||
}
|
||||
|
||||
Name = providerUser.Name;
|
||||
Email = providerUser.Email;
|
||||
}
|
||||
|
||||
Name = providerUser.Name;
|
||||
Email = providerUser.Email;
|
||||
public string Name { get; set; }
|
||||
public string Email { get; set; }
|
||||
}
|
||||
|
||||
public string Name { get; set; }
|
||||
public string Email { get; set; }
|
||||
}
|
||||
|
||||
public class ProviderUserPublicKeyResponseModel : ResponseModel
|
||||
{
|
||||
public ProviderUserPublicKeyResponseModel(Guid id, Guid userId, string key,
|
||||
string obj = "providerUserPublicKeyResponseModel") : base(obj)
|
||||
public class ProviderUserPublicKeyResponseModel : ResponseModel
|
||||
{
|
||||
Id = id;
|
||||
UserId = userId;
|
||||
Key = key;
|
||||
public ProviderUserPublicKeyResponseModel(Guid id, Guid userId, string key,
|
||||
string obj = "providerUserPublicKeyResponseModel") : base(obj)
|
||||
{
|
||||
Id = id;
|
||||
UserId = userId;
|
||||
Key = key;
|
||||
}
|
||||
|
||||
public Guid Id { get; set; }
|
||||
public Guid UserId { get; set; }
|
||||
public string Key { get; set; }
|
||||
}
|
||||
|
||||
public Guid Id { get; set; }
|
||||
public Guid UserId { get; set; }
|
||||
public string Key { get; set; }
|
||||
}
|
||||
|
||||
public class ProviderUserBulkResponseModel : ResponseModel
|
||||
{
|
||||
public ProviderUserBulkResponseModel(Guid id, string error,
|
||||
string obj = "providerBulkConfirmResponseModel") : base(obj)
|
||||
public class ProviderUserBulkResponseModel : ResponseModel
|
||||
{
|
||||
Id = id;
|
||||
Error = error;
|
||||
public ProviderUserBulkResponseModel(Guid id, string error,
|
||||
string obj = "providerBulkConfirmResponseModel") : base(obj)
|
||||
{
|
||||
Id = id;
|
||||
Error = error;
|
||||
}
|
||||
public Guid Id { get; set; }
|
||||
public string Error { get; set; }
|
||||
}
|
||||
public Guid Id { get; set; }
|
||||
public string Error { get; set; }
|
||||
}
|
||||
|
@ -1,22 +1,23 @@
|
||||
using Bit.Core.Models.Data;
|
||||
|
||||
namespace Bit.Api.Models.Response;
|
||||
|
||||
public class SelectionReadOnlyResponseModel
|
||||
namespace Bit.Api.Models.Response
|
||||
{
|
||||
public SelectionReadOnlyResponseModel(SelectionReadOnly selection)
|
||||
public class SelectionReadOnlyResponseModel
|
||||
{
|
||||
if (selection == null)
|
||||
public SelectionReadOnlyResponseModel(SelectionReadOnly selection)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(selection));
|
||||
if (selection == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(selection));
|
||||
}
|
||||
|
||||
Id = selection.Id.ToString();
|
||||
ReadOnly = selection.ReadOnly;
|
||||
HidePasswords = selection.HidePasswords;
|
||||
}
|
||||
|
||||
Id = selection.Id.ToString();
|
||||
ReadOnly = selection.ReadOnly;
|
||||
HidePasswords = selection.HidePasswords;
|
||||
public string Id { get; set; }
|
||||
public bool ReadOnly { get; set; }
|
||||
public bool HidePasswords { get; set; }
|
||||
}
|
||||
|
||||
public string Id { get; set; }
|
||||
public bool ReadOnly { get; set; }
|
||||
public bool HidePasswords { get; set; }
|
||||
}
|
||||
|
@ -6,47 +6,48 @@ using Bit.Core.Models.Data;
|
||||
using Bit.Core.Settings;
|
||||
using Bit.Core.Utilities;
|
||||
|
||||
namespace Bit.Api.Models.Response;
|
||||
|
||||
public class SendAccessResponseModel : ResponseModel
|
||||
namespace Bit.Api.Models.Response
|
||||
{
|
||||
public SendAccessResponseModel(Send send, GlobalSettings globalSettings)
|
||||
: base("send-access")
|
||||
public class SendAccessResponseModel : ResponseModel
|
||||
{
|
||||
if (send == null)
|
||||
public SendAccessResponseModel(Send send, GlobalSettings globalSettings)
|
||||
: base("send-access")
|
||||
{
|
||||
throw new ArgumentNullException(nameof(send));
|
||||
if (send == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(send));
|
||||
}
|
||||
|
||||
Id = CoreHelpers.Base64UrlEncode(send.Id.ToByteArray());
|
||||
Type = send.Type;
|
||||
|
||||
SendData sendData;
|
||||
switch (send.Type)
|
||||
{
|
||||
case SendType.File:
|
||||
var fileData = JsonSerializer.Deserialize<SendFileData>(send.Data);
|
||||
sendData = fileData;
|
||||
File = new SendFileModel(fileData);
|
||||
break;
|
||||
case SendType.Text:
|
||||
var textData = JsonSerializer.Deserialize<SendTextData>(send.Data);
|
||||
sendData = textData;
|
||||
Text = new SendTextModel(textData);
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentException("Unsupported " + nameof(Type) + ".");
|
||||
}
|
||||
|
||||
Name = sendData.Name;
|
||||
ExpirationDate = send.ExpirationDate;
|
||||
}
|
||||
|
||||
Id = CoreHelpers.Base64UrlEncode(send.Id.ToByteArray());
|
||||
Type = send.Type;
|
||||
|
||||
SendData sendData;
|
||||
switch (send.Type)
|
||||
{
|
||||
case SendType.File:
|
||||
var fileData = JsonSerializer.Deserialize<SendFileData>(send.Data);
|
||||
sendData = fileData;
|
||||
File = new SendFileModel(fileData);
|
||||
break;
|
||||
case SendType.Text:
|
||||
var textData = JsonSerializer.Deserialize<SendTextData>(send.Data);
|
||||
sendData = textData;
|
||||
Text = new SendTextModel(textData);
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentException("Unsupported " + nameof(Type) + ".");
|
||||
}
|
||||
|
||||
Name = sendData.Name;
|
||||
ExpirationDate = send.ExpirationDate;
|
||||
public string Id { get; set; }
|
||||
public SendType Type { get; set; }
|
||||
public string Name { get; set; }
|
||||
public SendFileModel File { get; set; }
|
||||
public SendTextModel Text { get; set; }
|
||||
public DateTime? ExpirationDate { get; set; }
|
||||
public string CreatorIdentifier { get; set; }
|
||||
}
|
||||
|
||||
public string Id { get; set; }
|
||||
public SendType Type { get; set; }
|
||||
public string Name { get; set; }
|
||||
public SendFileModel File { get; set; }
|
||||
public SendTextModel Text { get; set; }
|
||||
public DateTime? ExpirationDate { get; set; }
|
||||
public string CreatorIdentifier { get; set; }
|
||||
}
|
||||
|
@ -1,11 +1,12 @@
|
||||
using Bit.Core.Models.Api;
|
||||
|
||||
namespace Bit.Api.Models.Response;
|
||||
|
||||
public class SendFileDownloadDataResponseModel : ResponseModel
|
||||
namespace Bit.Api.Models.Response
|
||||
{
|
||||
public string Id { get; set; }
|
||||
public string Url { get; set; }
|
||||
public class SendFileDownloadDataResponseModel : ResponseModel
|
||||
{
|
||||
public string Id { get; set; }
|
||||
public string Url { get; set; }
|
||||
|
||||
public SendFileDownloadDataResponseModel() : base("send-fileDownload") { }
|
||||
public SendFileDownloadDataResponseModel() : base("send-fileDownload") { }
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,15 @@
|
||||
using Bit.Core.Enums;
|
||||
using Bit.Core.Models.Api;
|
||||
|
||||
namespace Bit.Api.Models.Response;
|
||||
|
||||
public class SendFileUploadDataResponseModel : ResponseModel
|
||||
namespace Bit.Api.Models.Response
|
||||
{
|
||||
public SendFileUploadDataResponseModel() : base("send-fileUpload") { }
|
||||
public class SendFileUploadDataResponseModel : ResponseModel
|
||||
{
|
||||
public SendFileUploadDataResponseModel() : base("send-fileUpload") { }
|
||||
|
||||
public string Url { get; set; }
|
||||
public FileUploadType FileUploadType { get; set; }
|
||||
public SendResponseModel SendResponse { get; set; }
|
||||
public string Url { get; set; }
|
||||
public FileUploadType FileUploadType { get; set; }
|
||||
public SendResponseModel SendResponse { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -6,66 +6,67 @@ using Bit.Core.Models.Data;
|
||||
using Bit.Core.Settings;
|
||||
using Bit.Core.Utilities;
|
||||
|
||||
namespace Bit.Api.Models.Response;
|
||||
|
||||
public class SendResponseModel : ResponseModel
|
||||
namespace Bit.Api.Models.Response
|
||||
{
|
||||
public SendResponseModel(Send send, GlobalSettings globalSettings)
|
||||
: base("send")
|
||||
public class SendResponseModel : ResponseModel
|
||||
{
|
||||
if (send == null)
|
||||
public SendResponseModel(Send send, GlobalSettings globalSettings)
|
||||
: base("send")
|
||||
{
|
||||
throw new ArgumentNullException(nameof(send));
|
||||
if (send == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(send));
|
||||
}
|
||||
|
||||
Id = send.Id.ToString();
|
||||
AccessId = CoreHelpers.Base64UrlEncode(send.Id.ToByteArray());
|
||||
Type = send.Type;
|
||||
Key = send.Key;
|
||||
MaxAccessCount = send.MaxAccessCount;
|
||||
AccessCount = send.AccessCount;
|
||||
RevisionDate = send.RevisionDate;
|
||||
ExpirationDate = send.ExpirationDate;
|
||||
DeletionDate = send.DeletionDate;
|
||||
Password = send.Password;
|
||||
Disabled = send.Disabled;
|
||||
HideEmail = send.HideEmail.GetValueOrDefault();
|
||||
|
||||
SendData sendData;
|
||||
switch (send.Type)
|
||||
{
|
||||
case SendType.File:
|
||||
var fileData = JsonSerializer.Deserialize<SendFileData>(send.Data);
|
||||
sendData = fileData;
|
||||
File = new SendFileModel(fileData);
|
||||
break;
|
||||
case SendType.Text:
|
||||
var textData = JsonSerializer.Deserialize<SendTextData>(send.Data);
|
||||
sendData = textData;
|
||||
Text = new SendTextModel(textData);
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentException("Unsupported " + nameof(Type) + ".");
|
||||
}
|
||||
|
||||
Name = sendData.Name;
|
||||
Notes = sendData.Notes;
|
||||
}
|
||||
|
||||
Id = send.Id.ToString();
|
||||
AccessId = CoreHelpers.Base64UrlEncode(send.Id.ToByteArray());
|
||||
Type = send.Type;
|
||||
Key = send.Key;
|
||||
MaxAccessCount = send.MaxAccessCount;
|
||||
AccessCount = send.AccessCount;
|
||||
RevisionDate = send.RevisionDate;
|
||||
ExpirationDate = send.ExpirationDate;
|
||||
DeletionDate = send.DeletionDate;
|
||||
Password = send.Password;
|
||||
Disabled = send.Disabled;
|
||||
HideEmail = send.HideEmail.GetValueOrDefault();
|
||||
|
||||
SendData sendData;
|
||||
switch (send.Type)
|
||||
{
|
||||
case SendType.File:
|
||||
var fileData = JsonSerializer.Deserialize<SendFileData>(send.Data);
|
||||
sendData = fileData;
|
||||
File = new SendFileModel(fileData);
|
||||
break;
|
||||
case SendType.Text:
|
||||
var textData = JsonSerializer.Deserialize<SendTextData>(send.Data);
|
||||
sendData = textData;
|
||||
Text = new SendTextModel(textData);
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentException("Unsupported " + nameof(Type) + ".");
|
||||
}
|
||||
|
||||
Name = sendData.Name;
|
||||
Notes = sendData.Notes;
|
||||
public string Id { get; set; }
|
||||
public string AccessId { get; set; }
|
||||
public SendType Type { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Notes { get; set; }
|
||||
public SendFileModel File { get; set; }
|
||||
public SendTextModel Text { get; set; }
|
||||
public string Key { get; set; }
|
||||
public int? MaxAccessCount { get; set; }
|
||||
public int AccessCount { get; set; }
|
||||
public string Password { get; set; }
|
||||
public bool Disabled { get; set; }
|
||||
public DateTime RevisionDate { get; set; }
|
||||
public DateTime? ExpirationDate { get; set; }
|
||||
public DateTime DeletionDate { get; set; }
|
||||
public bool HideEmail { get; set; }
|
||||
}
|
||||
|
||||
public string Id { get; set; }
|
||||
public string AccessId { get; set; }
|
||||
public SendType Type { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Notes { get; set; }
|
||||
public SendFileModel File { get; set; }
|
||||
public SendTextModel Text { get; set; }
|
||||
public string Key { get; set; }
|
||||
public int? MaxAccessCount { get; set; }
|
||||
public int AccessCount { get; set; }
|
||||
public string Password { get; set; }
|
||||
public bool Disabled { get; set; }
|
||||
public DateTime RevisionDate { get; set; }
|
||||
public DateTime? ExpirationDate { get; set; }
|
||||
public DateTime DeletionDate { get; set; }
|
||||
public bool HideEmail { get; set; }
|
||||
}
|
||||
|
@ -3,103 +3,104 @@ using Bit.Core.Models.Api;
|
||||
using Bit.Core.Models.Business;
|
||||
using Bit.Core.Utilities;
|
||||
|
||||
namespace Bit.Api.Models.Response;
|
||||
|
||||
public class SubscriptionResponseModel : ResponseModel
|
||||
namespace Bit.Api.Models.Response
|
||||
{
|
||||
public SubscriptionResponseModel(User user, SubscriptionInfo subscription, UserLicense license)
|
||||
: base("subscription")
|
||||
public class SubscriptionResponseModel : ResponseModel
|
||||
{
|
||||
Subscription = subscription.Subscription != null ? new BillingSubscription(subscription.Subscription) : null;
|
||||
UpcomingInvoice = subscription.UpcomingInvoice != null ?
|
||||
new BillingSubscriptionUpcomingInvoice(subscription.UpcomingInvoice) : null;
|
||||
StorageName = user.Storage.HasValue ? CoreHelpers.ReadableBytesSize(user.Storage.Value) : null;
|
||||
StorageGb = user.Storage.HasValue ? Math.Round(user.Storage.Value / 1073741824D, 2) : 0; // 1 GB
|
||||
MaxStorageGb = user.MaxStorageGb;
|
||||
License = license;
|
||||
Expiration = License.Expires;
|
||||
UsingInAppPurchase = subscription.UsingInAppPurchase;
|
||||
}
|
||||
|
||||
public SubscriptionResponseModel(User user, UserLicense license = null)
|
||||
: base("subscription")
|
||||
{
|
||||
StorageName = user.Storage.HasValue ? CoreHelpers.ReadableBytesSize(user.Storage.Value) : null;
|
||||
StorageGb = user.Storage.HasValue ? Math.Round(user.Storage.Value / 1073741824D, 2) : 0; // 1 GB
|
||||
MaxStorageGb = user.MaxStorageGb;
|
||||
Expiration = user.PremiumExpirationDate;
|
||||
|
||||
if (license != null)
|
||||
public SubscriptionResponseModel(User user, SubscriptionInfo subscription, UserLicense license)
|
||||
: base("subscription")
|
||||
{
|
||||
Subscription = subscription.Subscription != null ? new BillingSubscription(subscription.Subscription) : null;
|
||||
UpcomingInvoice = subscription.UpcomingInvoice != null ?
|
||||
new BillingSubscriptionUpcomingInvoice(subscription.UpcomingInvoice) : null;
|
||||
StorageName = user.Storage.HasValue ? CoreHelpers.ReadableBytesSize(user.Storage.Value) : null;
|
||||
StorageGb = user.Storage.HasValue ? Math.Round(user.Storage.Value / 1073741824D, 2) : 0; // 1 GB
|
||||
MaxStorageGb = user.MaxStorageGb;
|
||||
License = license;
|
||||
Expiration = License.Expires;
|
||||
UsingInAppPurchase = subscription.UsingInAppPurchase;
|
||||
}
|
||||
|
||||
public SubscriptionResponseModel(User user, UserLicense license = null)
|
||||
: base("subscription")
|
||||
{
|
||||
StorageName = user.Storage.HasValue ? CoreHelpers.ReadableBytesSize(user.Storage.Value) : null;
|
||||
StorageGb = user.Storage.HasValue ? Math.Round(user.Storage.Value / 1073741824D, 2) : 0; // 1 GB
|
||||
MaxStorageGb = user.MaxStorageGb;
|
||||
Expiration = user.PremiumExpirationDate;
|
||||
|
||||
if (license != null)
|
||||
{
|
||||
License = license;
|
||||
}
|
||||
}
|
||||
|
||||
public string StorageName { get; set; }
|
||||
public double? StorageGb { get; set; }
|
||||
public short? MaxStorageGb { get; set; }
|
||||
public BillingSubscriptionUpcomingInvoice UpcomingInvoice { get; set; }
|
||||
public BillingSubscription Subscription { get; set; }
|
||||
public UserLicense License { get; set; }
|
||||
public DateTime? Expiration { get; set; }
|
||||
public bool UsingInAppPurchase { get; set; }
|
||||
}
|
||||
|
||||
public class BillingSubscription
|
||||
{
|
||||
public BillingSubscription(SubscriptionInfo.BillingSubscription sub)
|
||||
{
|
||||
Status = sub.Status;
|
||||
TrialStartDate = sub.TrialStartDate;
|
||||
TrialEndDate = sub.TrialEndDate;
|
||||
PeriodStartDate = sub.PeriodStartDate;
|
||||
PeriodEndDate = sub.PeriodEndDate;
|
||||
CancelledDate = sub.CancelledDate;
|
||||
CancelAtEndDate = sub.CancelAtEndDate;
|
||||
Cancelled = sub.Cancelled;
|
||||
if (sub.Items != null)
|
||||
{
|
||||
Items = sub.Items.Select(i => new BillingSubscriptionItem(i));
|
||||
}
|
||||
}
|
||||
|
||||
public DateTime? TrialStartDate { get; set; }
|
||||
public DateTime? TrialEndDate { get; set; }
|
||||
public DateTime? PeriodStartDate { get; set; }
|
||||
public DateTime? PeriodEndDate { get; set; }
|
||||
public DateTime? CancelledDate { get; set; }
|
||||
public bool CancelAtEndDate { get; set; }
|
||||
public string Status { get; set; }
|
||||
public bool Cancelled { get; set; }
|
||||
public IEnumerable<BillingSubscriptionItem> Items { get; set; } = new List<BillingSubscriptionItem>();
|
||||
|
||||
public class BillingSubscriptionItem
|
||||
{
|
||||
public BillingSubscriptionItem(SubscriptionInfo.BillingSubscription.BillingSubscriptionItem item)
|
||||
{
|
||||
Name = item.Name;
|
||||
Amount = item.Amount;
|
||||
Interval = item.Interval;
|
||||
Quantity = item.Quantity;
|
||||
SponsoredSubscriptionItem = item.SponsoredSubscriptionItem;
|
||||
}
|
||||
|
||||
public string Name { get; set; }
|
||||
public decimal Amount { get; set; }
|
||||
public int Quantity { get; set; }
|
||||
public string Interval { get; set; }
|
||||
public bool SponsoredSubscriptionItem { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
public string StorageName { get; set; }
|
||||
public double? StorageGb { get; set; }
|
||||
public short? MaxStorageGb { get; set; }
|
||||
public BillingSubscriptionUpcomingInvoice UpcomingInvoice { get; set; }
|
||||
public BillingSubscription Subscription { get; set; }
|
||||
public UserLicense License { get; set; }
|
||||
public DateTime? Expiration { get; set; }
|
||||
public bool UsingInAppPurchase { get; set; }
|
||||
}
|
||||
|
||||
public class BillingSubscription
|
||||
{
|
||||
public BillingSubscription(SubscriptionInfo.BillingSubscription sub)
|
||||
public class BillingSubscriptionUpcomingInvoice
|
||||
{
|
||||
Status = sub.Status;
|
||||
TrialStartDate = sub.TrialStartDate;
|
||||
TrialEndDate = sub.TrialEndDate;
|
||||
PeriodStartDate = sub.PeriodStartDate;
|
||||
PeriodEndDate = sub.PeriodEndDate;
|
||||
CancelledDate = sub.CancelledDate;
|
||||
CancelAtEndDate = sub.CancelAtEndDate;
|
||||
Cancelled = sub.Cancelled;
|
||||
if (sub.Items != null)
|
||||
public BillingSubscriptionUpcomingInvoice(SubscriptionInfo.BillingUpcomingInvoice inv)
|
||||
{
|
||||
Items = sub.Items.Select(i => new BillingSubscriptionItem(i));
|
||||
}
|
||||
}
|
||||
|
||||
public DateTime? TrialStartDate { get; set; }
|
||||
public DateTime? TrialEndDate { get; set; }
|
||||
public DateTime? PeriodStartDate { get; set; }
|
||||
public DateTime? PeriodEndDate { get; set; }
|
||||
public DateTime? CancelledDate { get; set; }
|
||||
public bool CancelAtEndDate { get; set; }
|
||||
public string Status { get; set; }
|
||||
public bool Cancelled { get; set; }
|
||||
public IEnumerable<BillingSubscriptionItem> Items { get; set; } = new List<BillingSubscriptionItem>();
|
||||
|
||||
public class BillingSubscriptionItem
|
||||
{
|
||||
public BillingSubscriptionItem(SubscriptionInfo.BillingSubscription.BillingSubscriptionItem item)
|
||||
{
|
||||
Name = item.Name;
|
||||
Amount = item.Amount;
|
||||
Interval = item.Interval;
|
||||
Quantity = item.Quantity;
|
||||
SponsoredSubscriptionItem = item.SponsoredSubscriptionItem;
|
||||
Amount = inv.Amount;
|
||||
Date = inv.Date;
|
||||
}
|
||||
|
||||
public string Name { get; set; }
|
||||
public decimal Amount { get; set; }
|
||||
public int Quantity { get; set; }
|
||||
public string Interval { get; set; }
|
||||
public bool SponsoredSubscriptionItem { get; set; }
|
||||
public DateTime? Date { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
public class BillingSubscriptionUpcomingInvoice
|
||||
{
|
||||
public BillingSubscriptionUpcomingInvoice(SubscriptionInfo.BillingUpcomingInvoice inv)
|
||||
{
|
||||
Amount = inv.Amount;
|
||||
Date = inv.Date;
|
||||
}
|
||||
|
||||
public decimal Amount { get; set; }
|
||||
public DateTime? Date { get; set; }
|
||||
}
|
||||
|
@ -5,43 +5,44 @@ using Bit.Core.Models.Data.Organizations.OrganizationUsers;
|
||||
using Bit.Core.Settings;
|
||||
using Core.Models.Data;
|
||||
|
||||
namespace Bit.Api.Models.Response;
|
||||
|
||||
public class SyncResponseModel : ResponseModel
|
||||
namespace Bit.Api.Models.Response
|
||||
{
|
||||
public SyncResponseModel(
|
||||
GlobalSettings globalSettings,
|
||||
User user,
|
||||
bool userTwoFactorEnabled,
|
||||
bool userHasPremiumFromOrganization,
|
||||
IEnumerable<OrganizationUserOrganizationDetails> organizationUserDetails,
|
||||
IEnumerable<ProviderUserProviderDetails> providerUserDetails,
|
||||
IEnumerable<ProviderUserOrganizationDetails> providerUserOrganizationDetails,
|
||||
IEnumerable<Folder> folders,
|
||||
IEnumerable<CollectionDetails> collections,
|
||||
IEnumerable<CipherDetails> ciphers,
|
||||
IDictionary<Guid, IGrouping<Guid, CollectionCipher>> collectionCiphersDict,
|
||||
bool excludeDomains,
|
||||
IEnumerable<Policy> policies,
|
||||
IEnumerable<Send> sends)
|
||||
: base("sync")
|
||||
public class SyncResponseModel : ResponseModel
|
||||
{
|
||||
Profile = new ProfileResponseModel(user, organizationUserDetails, providerUserDetails,
|
||||
providerUserOrganizationDetails, userTwoFactorEnabled, userHasPremiumFromOrganization);
|
||||
Folders = folders.Select(f => new FolderResponseModel(f));
|
||||
Ciphers = ciphers.Select(c => new CipherDetailsResponseModel(c, globalSettings, collectionCiphersDict));
|
||||
Collections = collections?.Select(
|
||||
c => new CollectionDetailsResponseModel(c)) ?? new List<CollectionDetailsResponseModel>();
|
||||
Domains = excludeDomains ? null : new DomainsResponseModel(user, false);
|
||||
Policies = policies?.Select(p => new PolicyResponseModel(p)) ?? new List<PolicyResponseModel>();
|
||||
Sends = sends.Select(s => new SendResponseModel(s, globalSettings));
|
||||
}
|
||||
public SyncResponseModel(
|
||||
GlobalSettings globalSettings,
|
||||
User user,
|
||||
bool userTwoFactorEnabled,
|
||||
bool userHasPremiumFromOrganization,
|
||||
IEnumerable<OrganizationUserOrganizationDetails> organizationUserDetails,
|
||||
IEnumerable<ProviderUserProviderDetails> providerUserDetails,
|
||||
IEnumerable<ProviderUserOrganizationDetails> providerUserOrganizationDetails,
|
||||
IEnumerable<Folder> folders,
|
||||
IEnumerable<CollectionDetails> collections,
|
||||
IEnumerable<CipherDetails> ciphers,
|
||||
IDictionary<Guid, IGrouping<Guid, CollectionCipher>> collectionCiphersDict,
|
||||
bool excludeDomains,
|
||||
IEnumerable<Policy> policies,
|
||||
IEnumerable<Send> sends)
|
||||
: base("sync")
|
||||
{
|
||||
Profile = new ProfileResponseModel(user, organizationUserDetails, providerUserDetails,
|
||||
providerUserOrganizationDetails, userTwoFactorEnabled, userHasPremiumFromOrganization);
|
||||
Folders = folders.Select(f => new FolderResponseModel(f));
|
||||
Ciphers = ciphers.Select(c => new CipherDetailsResponseModel(c, globalSettings, collectionCiphersDict));
|
||||
Collections = collections?.Select(
|
||||
c => new CollectionDetailsResponseModel(c)) ?? new List<CollectionDetailsResponseModel>();
|
||||
Domains = excludeDomains ? null : new DomainsResponseModel(user, false);
|
||||
Policies = policies?.Select(p => new PolicyResponseModel(p)) ?? new List<PolicyResponseModel>();
|
||||
Sends = sends.Select(s => new SendResponseModel(s, globalSettings));
|
||||
}
|
||||
|
||||
public ProfileResponseModel Profile { get; set; }
|
||||
public IEnumerable<FolderResponseModel> Folders { get; set; }
|
||||
public IEnumerable<CollectionDetailsResponseModel> Collections { get; set; }
|
||||
public IEnumerable<CipherDetailsResponseModel> Ciphers { get; set; }
|
||||
public DomainsResponseModel Domains { get; set; }
|
||||
public IEnumerable<PolicyResponseModel> Policies { get; set; }
|
||||
public IEnumerable<SendResponseModel> Sends { get; set; }
|
||||
public ProfileResponseModel Profile { get; set; }
|
||||
public IEnumerable<FolderResponseModel> Folders { get; set; }
|
||||
public IEnumerable<CollectionDetailsResponseModel> Collections { get; set; }
|
||||
public IEnumerable<CipherDetailsResponseModel> Ciphers { get; set; }
|
||||
public DomainsResponseModel Domains { get; set; }
|
||||
public IEnumerable<PolicyResponseModel> Policies { get; set; }
|
||||
public IEnumerable<SendResponseModel> Sends { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -1,34 +1,35 @@
|
||||
using Bit.Core.Models.Business;
|
||||
|
||||
namespace Bit.Api.Models.Response;
|
||||
|
||||
public class TaxInfoResponseModel
|
||||
namespace Bit.Api.Models.Response
|
||||
{
|
||||
public TaxInfoResponseModel() { }
|
||||
|
||||
public TaxInfoResponseModel(TaxInfo taxInfo)
|
||||
public class TaxInfoResponseModel
|
||||
{
|
||||
if (taxInfo == null)
|
||||
public TaxInfoResponseModel() { }
|
||||
|
||||
public TaxInfoResponseModel(TaxInfo taxInfo)
|
||||
{
|
||||
return;
|
||||
if (taxInfo == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
TaxIdNumber = taxInfo.TaxIdNumber;
|
||||
TaxIdType = taxInfo.TaxIdType;
|
||||
Line1 = taxInfo.BillingAddressLine1;
|
||||
Line2 = taxInfo.BillingAddressLine2;
|
||||
City = taxInfo.BillingAddressCity;
|
||||
State = taxInfo.BillingAddressState;
|
||||
PostalCode = taxInfo.BillingAddressPostalCode;
|
||||
Country = taxInfo.BillingAddressCountry;
|
||||
}
|
||||
|
||||
TaxIdNumber = taxInfo.TaxIdNumber;
|
||||
TaxIdType = taxInfo.TaxIdType;
|
||||
Line1 = taxInfo.BillingAddressLine1;
|
||||
Line2 = taxInfo.BillingAddressLine2;
|
||||
City = taxInfo.BillingAddressCity;
|
||||
State = taxInfo.BillingAddressState;
|
||||
PostalCode = taxInfo.BillingAddressPostalCode;
|
||||
Country = taxInfo.BillingAddressCountry;
|
||||
public string TaxIdNumber { get; set; }
|
||||
public string TaxIdType { get; set; }
|
||||
public string Line1 { get; set; }
|
||||
public string Line2 { get; set; }
|
||||
public string City { get; set; }
|
||||
public string State { get; set; }
|
||||
public string PostalCode { get; set; }
|
||||
public string Country { get; set; }
|
||||
}
|
||||
|
||||
public string TaxIdNumber { get; set; }
|
||||
public string TaxIdType { get; set; }
|
||||
public string Line1 { get; set; }
|
||||
public string Line2 { get; set; }
|
||||
public string City { get; set; }
|
||||
public string State { get; set; }
|
||||
public string PostalCode { get; set; }
|
||||
public string Country { get; set; }
|
||||
}
|
||||
|
@ -1,28 +1,29 @@
|
||||
using Bit.Core.Entities;
|
||||
using Bit.Core.Models.Api;
|
||||
|
||||
namespace Bit.Api.Models.Response;
|
||||
|
||||
public class TaxRateResponseModel : ResponseModel
|
||||
namespace Bit.Api.Models.Response
|
||||
{
|
||||
public TaxRateResponseModel(TaxRate taxRate)
|
||||
: base("profile")
|
||||
public class TaxRateResponseModel : ResponseModel
|
||||
{
|
||||
if (taxRate == null)
|
||||
public TaxRateResponseModel(TaxRate taxRate)
|
||||
: base("profile")
|
||||
{
|
||||
throw new ArgumentNullException(nameof(taxRate));
|
||||
if (taxRate == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(taxRate));
|
||||
}
|
||||
|
||||
Id = taxRate.Id;
|
||||
Country = taxRate.Country;
|
||||
State = taxRate.State;
|
||||
PostalCode = taxRate.PostalCode;
|
||||
Rate = taxRate.Rate;
|
||||
}
|
||||
|
||||
Id = taxRate.Id;
|
||||
Country = taxRate.Country;
|
||||
State = taxRate.State;
|
||||
PostalCode = taxRate.PostalCode;
|
||||
Rate = taxRate.Rate;
|
||||
public string Id { get; set; }
|
||||
public string Country { get; set; }
|
||||
public string State { get; set; }
|
||||
public string PostalCode { get; set; }
|
||||
public decimal Rate { get; set; }
|
||||
}
|
||||
|
||||
public string Id { get; set; }
|
||||
public string Country { get; set; }
|
||||
public string State { get; set; }
|
||||
public string PostalCode { get; set; }
|
||||
public decimal Rate { get; set; }
|
||||
}
|
||||
|
@ -3,32 +3,33 @@ using Bit.Core.Enums;
|
||||
using Bit.Core.Models.Api;
|
||||
using OtpNet;
|
||||
|
||||
namespace Bit.Api.Models.Response.TwoFactor;
|
||||
|
||||
public class TwoFactorAuthenticatorResponseModel : ResponseModel
|
||||
namespace Bit.Api.Models.Response.TwoFactor
|
||||
{
|
||||
public TwoFactorAuthenticatorResponseModel(User user)
|
||||
: base("twoFactorAuthenticator")
|
||||
public class TwoFactorAuthenticatorResponseModel : ResponseModel
|
||||
{
|
||||
if (user == null)
|
||||
public TwoFactorAuthenticatorResponseModel(User user)
|
||||
: base("twoFactorAuthenticator")
|
||||
{
|
||||
throw new ArgumentNullException(nameof(user));
|
||||
if (user == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(user));
|
||||
}
|
||||
|
||||
var provider = user.GetTwoFactorProvider(TwoFactorProviderType.Authenticator);
|
||||
if (provider?.MetaData?.ContainsKey("Key") ?? false)
|
||||
{
|
||||
Key = (string)provider.MetaData["Key"];
|
||||
Enabled = provider.Enabled;
|
||||
}
|
||||
else
|
||||
{
|
||||
var key = KeyGeneration.GenerateRandomKey(20);
|
||||
Key = Base32Encoding.ToString(key);
|
||||
Enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
var provider = user.GetTwoFactorProvider(TwoFactorProviderType.Authenticator);
|
||||
if (provider?.MetaData?.ContainsKey("Key") ?? false)
|
||||
{
|
||||
Key = (string)provider.MetaData["Key"];
|
||||
Enabled = provider.Enabled;
|
||||
}
|
||||
else
|
||||
{
|
||||
var key = KeyGeneration.GenerateRandomKey(20);
|
||||
Key = Base32Encoding.ToString(key);
|
||||
Enabled = false;
|
||||
}
|
||||
public bool Enabled { get; set; }
|
||||
public string Key { get; set; }
|
||||
}
|
||||
|
||||
public bool Enabled { get; set; }
|
||||
public string Key { get; set; }
|
||||
}
|
||||
|
@ -3,63 +3,64 @@ using Bit.Core.Enums;
|
||||
using Bit.Core.Models;
|
||||
using Bit.Core.Models.Api;
|
||||
|
||||
namespace Bit.Api.Models.Response.TwoFactor;
|
||||
|
||||
public class TwoFactorDuoResponseModel : ResponseModel
|
||||
namespace Bit.Api.Models.Response.TwoFactor
|
||||
{
|
||||
private const string ResponseObj = "twoFactorDuo";
|
||||
|
||||
public TwoFactorDuoResponseModel(User user)
|
||||
: base(ResponseObj)
|
||||
public class TwoFactorDuoResponseModel : ResponseModel
|
||||
{
|
||||
if (user == null)
|
||||
private const string ResponseObj = "twoFactorDuo";
|
||||
|
||||
public TwoFactorDuoResponseModel(User user)
|
||||
: base(ResponseObj)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(user));
|
||||
if (user == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(user));
|
||||
}
|
||||
|
||||
var provider = user.GetTwoFactorProvider(TwoFactorProviderType.Duo);
|
||||
Build(provider);
|
||||
}
|
||||
|
||||
var provider = user.GetTwoFactorProvider(TwoFactorProviderType.Duo);
|
||||
Build(provider);
|
||||
}
|
||||
|
||||
public TwoFactorDuoResponseModel(Organization org)
|
||||
: base(ResponseObj)
|
||||
{
|
||||
if (org == null)
|
||||
public TwoFactorDuoResponseModel(Organization org)
|
||||
: base(ResponseObj)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(org));
|
||||
if (org == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(org));
|
||||
}
|
||||
|
||||
var provider = org.GetTwoFactorProvider(TwoFactorProviderType.OrganizationDuo);
|
||||
Build(provider);
|
||||
}
|
||||
|
||||
var provider = org.GetTwoFactorProvider(TwoFactorProviderType.OrganizationDuo);
|
||||
Build(provider);
|
||||
}
|
||||
public bool Enabled { get; set; }
|
||||
public string Host { get; set; }
|
||||
public string SecretKey { get; set; }
|
||||
public string IntegrationKey { get; set; }
|
||||
|
||||
public bool Enabled { get; set; }
|
||||
public string Host { get; set; }
|
||||
public string SecretKey { get; set; }
|
||||
public string IntegrationKey { get; set; }
|
||||
|
||||
private void Build(TwoFactorProvider provider)
|
||||
{
|
||||
if (provider?.MetaData != null && provider.MetaData.Count > 0)
|
||||
private void Build(TwoFactorProvider provider)
|
||||
{
|
||||
Enabled = provider.Enabled;
|
||||
if (provider?.MetaData != null && provider.MetaData.Count > 0)
|
||||
{
|
||||
Enabled = provider.Enabled;
|
||||
|
||||
if (provider.MetaData.ContainsKey("Host"))
|
||||
{
|
||||
Host = (string)provider.MetaData["Host"];
|
||||
if (provider.MetaData.ContainsKey("Host"))
|
||||
{
|
||||
Host = (string)provider.MetaData["Host"];
|
||||
}
|
||||
if (provider.MetaData.ContainsKey("SKey"))
|
||||
{
|
||||
SecretKey = (string)provider.MetaData["SKey"];
|
||||
}
|
||||
if (provider.MetaData.ContainsKey("IKey"))
|
||||
{
|
||||
IntegrationKey = (string)provider.MetaData["IKey"];
|
||||
}
|
||||
}
|
||||
if (provider.MetaData.ContainsKey("SKey"))
|
||||
else
|
||||
{
|
||||
SecretKey = (string)provider.MetaData["SKey"];
|
||||
Enabled = false;
|
||||
}
|
||||
if (provider.MetaData.ContainsKey("IKey"))
|
||||
{
|
||||
IntegrationKey = (string)provider.MetaData["IKey"];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Enabled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,30 +2,31 @@
|
||||
using Bit.Core.Enums;
|
||||
using Bit.Core.Models.Api;
|
||||
|
||||
namespace Bit.Api.Models.Response.TwoFactor;
|
||||
|
||||
public class TwoFactorEmailResponseModel : ResponseModel
|
||||
namespace Bit.Api.Models.Response.TwoFactor
|
||||
{
|
||||
public TwoFactorEmailResponseModel(User user)
|
||||
: base("twoFactorEmail")
|
||||
public class TwoFactorEmailResponseModel : ResponseModel
|
||||
{
|
||||
if (user == null)
|
||||
public TwoFactorEmailResponseModel(User user)
|
||||
: base("twoFactorEmail")
|
||||
{
|
||||
throw new ArgumentNullException(nameof(user));
|
||||
if (user == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(user));
|
||||
}
|
||||
|
||||
var provider = user.GetTwoFactorProvider(TwoFactorProviderType.Email);
|
||||
if (provider?.MetaData?.ContainsKey("Email") ?? false)
|
||||
{
|
||||
Email = (string)provider.MetaData["Email"];
|
||||
Enabled = provider.Enabled;
|
||||
}
|
||||
else
|
||||
{
|
||||
Enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
var provider = user.GetTwoFactorProvider(TwoFactorProviderType.Email);
|
||||
if (provider?.MetaData?.ContainsKey("Email") ?? false)
|
||||
{
|
||||
Email = (string)provider.MetaData["Email"];
|
||||
Enabled = provider.Enabled;
|
||||
}
|
||||
else
|
||||
{
|
||||
Enabled = false;
|
||||
}
|
||||
public bool Enabled { get; set; }
|
||||
public string Email { get; set; }
|
||||
}
|
||||
|
||||
public bool Enabled { get; set; }
|
||||
public string Email { get; set; }
|
||||
}
|
||||
|
@ -3,50 +3,51 @@ using Bit.Core.Enums;
|
||||
using Bit.Core.Models;
|
||||
using Bit.Core.Models.Api;
|
||||
|
||||
namespace Bit.Api.Models.Response.TwoFactor;
|
||||
|
||||
public class TwoFactorProviderResponseModel : ResponseModel
|
||||
namespace Bit.Api.Models.Response.TwoFactor
|
||||
{
|
||||
private const string ResponseObj = "twoFactorProvider";
|
||||
|
||||
public TwoFactorProviderResponseModel(TwoFactorProviderType type, TwoFactorProvider provider)
|
||||
: base(ResponseObj)
|
||||
public class TwoFactorProviderResponseModel : ResponseModel
|
||||
{
|
||||
if (provider == null)
|
||||
private const string ResponseObj = "twoFactorProvider";
|
||||
|
||||
public TwoFactorProviderResponseModel(TwoFactorProviderType type, TwoFactorProvider provider)
|
||||
: base(ResponseObj)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(provider));
|
||||
if (provider == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(provider));
|
||||
}
|
||||
|
||||
Enabled = provider.Enabled;
|
||||
Type = type;
|
||||
}
|
||||
|
||||
Enabled = provider.Enabled;
|
||||
Type = type;
|
||||
}
|
||||
|
||||
public TwoFactorProviderResponseModel(TwoFactorProviderType type, User user)
|
||||
: base(ResponseObj)
|
||||
{
|
||||
if (user == null)
|
||||
public TwoFactorProviderResponseModel(TwoFactorProviderType type, User user)
|
||||
: base(ResponseObj)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(user));
|
||||
if (user == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(user));
|
||||
}
|
||||
|
||||
var provider = user.GetTwoFactorProvider(type);
|
||||
Enabled = provider?.Enabled ?? false;
|
||||
Type = type;
|
||||
}
|
||||
|
||||
var provider = user.GetTwoFactorProvider(type);
|
||||
Enabled = provider?.Enabled ?? false;
|
||||
Type = type;
|
||||
}
|
||||
|
||||
public TwoFactorProviderResponseModel(TwoFactorProviderType type, Organization organization)
|
||||
: base(ResponseObj)
|
||||
{
|
||||
if (organization == null)
|
||||
public TwoFactorProviderResponseModel(TwoFactorProviderType type, Organization organization)
|
||||
: base(ResponseObj)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(organization));
|
||||
if (organization == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(organization));
|
||||
}
|
||||
|
||||
var provider = organization.GetTwoFactorProvider(type);
|
||||
Enabled = provider?.Enabled ?? false;
|
||||
Type = type;
|
||||
}
|
||||
|
||||
var provider = organization.GetTwoFactorProvider(type);
|
||||
Enabled = provider?.Enabled ?? false;
|
||||
Type = type;
|
||||
public bool Enabled { get; set; }
|
||||
public TwoFactorProviderType Type { get; set; }
|
||||
}
|
||||
|
||||
public bool Enabled { get; set; }
|
||||
public TwoFactorProviderType Type { get; set; }
|
||||
}
|
||||
|
@ -1,20 +1,21 @@
|
||||
using Bit.Core.Entities;
|
||||
using Bit.Core.Models.Api;
|
||||
|
||||
namespace Bit.Api.Models.Response.TwoFactor;
|
||||
|
||||
public class TwoFactorRecoverResponseModel : ResponseModel
|
||||
namespace Bit.Api.Models.Response.TwoFactor
|
||||
{
|
||||
public TwoFactorRecoverResponseModel(User user)
|
||||
: base("twoFactorRecover")
|
||||
public class TwoFactorRecoverResponseModel : ResponseModel
|
||||
{
|
||||
if (user == null)
|
||||
public TwoFactorRecoverResponseModel(User user)
|
||||
: base("twoFactorRecover")
|
||||
{
|
||||
throw new ArgumentNullException(nameof(user));
|
||||
if (user == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(user));
|
||||
}
|
||||
|
||||
Code = user.TwoFactorRecoveryCode;
|
||||
}
|
||||
|
||||
Code = user.TwoFactorRecoveryCode;
|
||||
public string Code { get; set; }
|
||||
}
|
||||
|
||||
public string Code { get; set; }
|
||||
}
|
||||
|
@ -3,39 +3,40 @@ using Bit.Core.Enums;
|
||||
using Bit.Core.Models;
|
||||
using Bit.Core.Models.Api;
|
||||
|
||||
namespace Bit.Api.Models.Response.TwoFactor;
|
||||
|
||||
public class TwoFactorWebAuthnResponseModel : ResponseModel
|
||||
namespace Bit.Api.Models.Response.TwoFactor
|
||||
{
|
||||
public TwoFactorWebAuthnResponseModel(User user)
|
||||
: base("twoFactorWebAuthn")
|
||||
public class TwoFactorWebAuthnResponseModel : ResponseModel
|
||||
{
|
||||
if (user == null)
|
||||
public TwoFactorWebAuthnResponseModel(User user)
|
||||
: base("twoFactorWebAuthn")
|
||||
{
|
||||
throw new ArgumentNullException(nameof(user));
|
||||
if (user == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(user));
|
||||
}
|
||||
|
||||
var provider = user.GetTwoFactorProvider(TwoFactorProviderType.WebAuthn);
|
||||
Enabled = provider?.Enabled ?? false;
|
||||
Keys = provider?.MetaData?
|
||||
.Where(k => k.Key.StartsWith("Key"))
|
||||
.Select(k => new KeyModel(k.Key, new TwoFactorProvider.WebAuthnData((dynamic)k.Value)));
|
||||
}
|
||||
|
||||
var provider = user.GetTwoFactorProvider(TwoFactorProviderType.WebAuthn);
|
||||
Enabled = provider?.Enabled ?? false;
|
||||
Keys = provider?.MetaData?
|
||||
.Where(k => k.Key.StartsWith("Key"))
|
||||
.Select(k => new KeyModel(k.Key, new TwoFactorProvider.WebAuthnData((dynamic)k.Value)));
|
||||
}
|
||||
public bool Enabled { get; set; }
|
||||
public IEnumerable<KeyModel> Keys { get; set; }
|
||||
|
||||
public bool Enabled { get; set; }
|
||||
public IEnumerable<KeyModel> Keys { get; set; }
|
||||
|
||||
public class KeyModel
|
||||
{
|
||||
public KeyModel(string id, TwoFactorProvider.WebAuthnData data)
|
||||
public class KeyModel
|
||||
{
|
||||
Name = data.Name;
|
||||
Id = Convert.ToInt32(id.Replace("Key", string.Empty));
|
||||
Migrated = data.Migrated;
|
||||
}
|
||||
public KeyModel(string id, TwoFactorProvider.WebAuthnData data)
|
||||
{
|
||||
Name = data.Name;
|
||||
Id = Convert.ToInt32(id.Replace("Key", string.Empty));
|
||||
Migrated = data.Migrated;
|
||||
}
|
||||
|
||||
public string Name { get; set; }
|
||||
public int Id { get; set; }
|
||||
public bool Migrated { get; set; }
|
||||
public string Name { get; set; }
|
||||
public int Id { get; set; }
|
||||
public bool Migrated { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,59 +2,60 @@
|
||||
using Bit.Core.Enums;
|
||||
using Bit.Core.Models.Api;
|
||||
|
||||
namespace Bit.Api.Models.Response.TwoFactor;
|
||||
|
||||
public class TwoFactorYubiKeyResponseModel : ResponseModel
|
||||
namespace Bit.Api.Models.Response.TwoFactor
|
||||
{
|
||||
public TwoFactorYubiKeyResponseModel(User user)
|
||||
: base("twoFactorYubiKey")
|
||||
public class TwoFactorYubiKeyResponseModel : ResponseModel
|
||||
{
|
||||
if (user == null)
|
||||
public TwoFactorYubiKeyResponseModel(User user)
|
||||
: base("twoFactorYubiKey")
|
||||
{
|
||||
throw new ArgumentNullException(nameof(user));
|
||||
if (user == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(user));
|
||||
}
|
||||
|
||||
var provider = user.GetTwoFactorProvider(TwoFactorProviderType.YubiKey);
|
||||
if (provider?.MetaData != null && provider.MetaData.Count > 0)
|
||||
{
|
||||
Enabled = provider.Enabled;
|
||||
|
||||
if (provider.MetaData.ContainsKey("Key1"))
|
||||
{
|
||||
Key1 = (string)provider.MetaData["Key1"];
|
||||
}
|
||||
if (provider.MetaData.ContainsKey("Key2"))
|
||||
{
|
||||
Key2 = (string)provider.MetaData["Key2"];
|
||||
}
|
||||
if (provider.MetaData.ContainsKey("Key3"))
|
||||
{
|
||||
Key3 = (string)provider.MetaData["Key3"];
|
||||
}
|
||||
if (provider.MetaData.ContainsKey("Key4"))
|
||||
{
|
||||
Key4 = (string)provider.MetaData["Key4"];
|
||||
}
|
||||
if (provider.MetaData.ContainsKey("Key5"))
|
||||
{
|
||||
Key5 = (string)provider.MetaData["Key5"];
|
||||
}
|
||||
if (provider.MetaData.ContainsKey("Nfc"))
|
||||
{
|
||||
Nfc = (bool)provider.MetaData["Nfc"];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
var provider = user.GetTwoFactorProvider(TwoFactorProviderType.YubiKey);
|
||||
if (provider?.MetaData != null && provider.MetaData.Count > 0)
|
||||
{
|
||||
Enabled = provider.Enabled;
|
||||
|
||||
if (provider.MetaData.ContainsKey("Key1"))
|
||||
{
|
||||
Key1 = (string)provider.MetaData["Key1"];
|
||||
}
|
||||
if (provider.MetaData.ContainsKey("Key2"))
|
||||
{
|
||||
Key2 = (string)provider.MetaData["Key2"];
|
||||
}
|
||||
if (provider.MetaData.ContainsKey("Key3"))
|
||||
{
|
||||
Key3 = (string)provider.MetaData["Key3"];
|
||||
}
|
||||
if (provider.MetaData.ContainsKey("Key4"))
|
||||
{
|
||||
Key4 = (string)provider.MetaData["Key4"];
|
||||
}
|
||||
if (provider.MetaData.ContainsKey("Key5"))
|
||||
{
|
||||
Key5 = (string)provider.MetaData["Key5"];
|
||||
}
|
||||
if (provider.MetaData.ContainsKey("Nfc"))
|
||||
{
|
||||
Nfc = (bool)provider.MetaData["Nfc"];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Enabled = false;
|
||||
}
|
||||
public bool Enabled { get; set; }
|
||||
public string Key1 { get; set; }
|
||||
public string Key2 { get; set; }
|
||||
public string Key3 { get; set; }
|
||||
public string Key4 { get; set; }
|
||||
public string Key5 { get; set; }
|
||||
public bool Nfc { get; set; }
|
||||
}
|
||||
|
||||
public bool Enabled { get; set; }
|
||||
public string Key1 { get; set; }
|
||||
public string Key2 { get; set; }
|
||||
public string Key3 { get; set; }
|
||||
public string Key4 { get; set; }
|
||||
public string Key5 { get; set; }
|
||||
public bool Nfc { get; set; }
|
||||
}
|
||||
|
@ -1,16 +1,17 @@
|
||||
using Bit.Core.Models.Api;
|
||||
|
||||
namespace Bit.Api.Models.Response;
|
||||
|
||||
public class UserKeyResponseModel : ResponseModel
|
||||
namespace Bit.Api.Models.Response
|
||||
{
|
||||
public UserKeyResponseModel(Guid id, string key)
|
||||
: base("userKey")
|
||||
public class UserKeyResponseModel : ResponseModel
|
||||
{
|
||||
UserId = id.ToString();
|
||||
PublicKey = key;
|
||||
}
|
||||
public UserKeyResponseModel(Guid id, string key)
|
||||
: base("userKey")
|
||||
{
|
||||
UserId = id.ToString();
|
||||
PublicKey = key;
|
||||
}
|
||||
|
||||
public string UserId { get; set; }
|
||||
public string PublicKey { get; set; }
|
||||
public string UserId { get; set; }
|
||||
public string PublicKey { get; set; }
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user