mirror of
https://github.com/bitwarden/server.git
synced 2025-06-30 23:52:50 -05:00
Split out repositories to Infrastructure.Dapper / EntityFramework (#1759)
This commit is contained in:
@ -1,8 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Bit.Core.Entities;
|
||||
using Bit.Core.Enums;
|
||||
using Bit.Core.Models.Table;
|
||||
using Bit.Core.Utilities;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
|
@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Bit.Core.Entities;
|
||||
using Bit.Core.Enums;
|
||||
using Bit.Core.Models.Table;
|
||||
using Stripe;
|
||||
|
||||
namespace Bit.Core.Models.Business
|
||||
|
@ -1,5 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using Bit.Core.Models.Table;
|
||||
using Bit.Core.Entities;
|
||||
|
||||
namespace Bit.Core.Models.Business
|
||||
{
|
||||
|
@ -4,8 +4,8 @@ using System.Reflection;
|
||||
using System.Security.Cryptography;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using System.Text;
|
||||
using Bit.Core.Entities;
|
||||
using Bit.Core.Enums;
|
||||
using Bit.Core.Models.Table;
|
||||
using Bit.Core.Services;
|
||||
using Bit.Core.Settings;
|
||||
using Newtonsoft.Json;
|
||||
|
@ -1,5 +1,5 @@
|
||||
using Bit.Core.Enums;
|
||||
using Bit.Core.Models.Table;
|
||||
using Bit.Core.Entities;
|
||||
using Bit.Core.Enums;
|
||||
|
||||
namespace Bit.Core.Models.Business
|
||||
{
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using Bit.Core.Entities;
|
||||
using Bit.Core.Enums;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
|
@ -1,5 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using Bit.Core.Models.Table;
|
||||
using Bit.Core.Entities;
|
||||
using Stripe;
|
||||
|
||||
namespace Bit.Core.Models.Business
|
||||
|
@ -1,6 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Bit.Core.Models.Table;
|
||||
using Bit.Core.Entities;
|
||||
using Stripe;
|
||||
|
||||
namespace Bit.Core.Models.Business
|
||||
|
@ -1,6 +1,6 @@
|
||||
using System;
|
||||
using System.Text.Json.Serialization;
|
||||
using Bit.Core.Models.Table;
|
||||
using Bit.Core.Entities;
|
||||
|
||||
namespace Bit.Core.Models.Business.Tokenables
|
||||
{
|
||||
|
@ -1,6 +1,6 @@
|
||||
using System;
|
||||
using System.Text.Json.Serialization;
|
||||
using Bit.Core.Models.Table;
|
||||
using Bit.Core.Entities;
|
||||
using Bit.Core.Tokens;
|
||||
|
||||
namespace Bit.Core.Models.Business.Tokenables
|
||||
|
@ -4,7 +4,7 @@ using System.Reflection;
|
||||
using System.Security.Cryptography;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using System.Text;
|
||||
using Bit.Core.Models.Table;
|
||||
using Bit.Core.Entities;
|
||||
using Bit.Core.Services;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
using Bit.Core.Models.Table;
|
||||
using Bit.Core.Entities;
|
||||
|
||||
namespace Bit.Core.Models.Data
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
using Bit.Core.Models.Table;
|
||||
using Bit.Core.Entities;
|
||||
|
||||
namespace Core.Models.Data
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
using Bit.Core.Models.Table;
|
||||
using Bit.Core.Entities;
|
||||
|
||||
namespace Bit.Core.Models.Data
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
using Bit.Core.Models.Table;
|
||||
using Bit.Core.Entities;
|
||||
|
||||
namespace Bit.Core.Models.Data
|
||||
{
|
||||
|
@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Bit.Core.Entities;
|
||||
using Bit.Core.Enums;
|
||||
using Bit.Core.Models.Table;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Bit.Core.Models.Data
|
||||
|
@ -1,5 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using Bit.Core.Models.Table;
|
||||
using Bit.Core.Entities;
|
||||
using Core.Models.Data;
|
||||
|
||||
namespace Bit.Core.Models.Data
|
||||
|
@ -1,5 +1,5 @@
|
||||
using System.Data;
|
||||
using Bit.Core.Models.Table;
|
||||
using Bit.Core.Entities;
|
||||
|
||||
namespace Bit.Core.Models.Data
|
||||
{
|
||||
|
@ -1,5 +1,5 @@
|
||||
using System;
|
||||
using Bit.Core.Models.Table;
|
||||
using Bit.Core.Entities;
|
||||
|
||||
namespace Bit.Core.Models.Data
|
||||
{
|
||||
|
@ -1,6 +1,6 @@
|
||||
using System;
|
||||
using Bit.Core.Entities;
|
||||
using Bit.Core.Enums;
|
||||
using Bit.Core.Models.Table;
|
||||
|
||||
namespace Bit.Core.Models.Data
|
||||
{
|
||||
|
@ -1,5 +1,5 @@
|
||||
using System.Data;
|
||||
using Bit.Core.Models.Table;
|
||||
using Bit.Core.Entities;
|
||||
|
||||
namespace Bit.Core.Models.Data
|
||||
{
|
||||
|
@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using Bit.Core.Models.Table;
|
||||
using Bit.Core.Models.Table.Provider;
|
||||
using Bit.Core.Entities.Provider;
|
||||
|
||||
namespace Bit.Core.Models.Data
|
||||
{
|
||||
|
@ -1,21 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json;
|
||||
using AutoMapper;
|
||||
|
||||
namespace Bit.Core.Models.EntityFramework
|
||||
{
|
||||
public class Cipher : Table.Cipher
|
||||
{
|
||||
public virtual User User { get; set; }
|
||||
public virtual Organization Organization { get; set; }
|
||||
public virtual ICollection<CollectionCipher> CollectionCiphers { get; set; }
|
||||
}
|
||||
|
||||
public class CipherMapperProfile : Profile
|
||||
{
|
||||
public CipherMapperProfile()
|
||||
{
|
||||
CreateMap<Table.Cipher, Cipher>().ReverseMap();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json;
|
||||
using AutoMapper;
|
||||
|
||||
namespace Bit.Core.Models.EntityFramework
|
||||
{
|
||||
public class Collection : Table.Collection
|
||||
{
|
||||
public virtual Organization Organization { get; set; }
|
||||
public virtual ICollection<CollectionUser> CollectionUsers { get; set; }
|
||||
public virtual ICollection<CollectionCipher> CollectionCiphers { get; set; }
|
||||
public virtual ICollection<CollectionGroup> CollectionGroups { get; set; }
|
||||
}
|
||||
|
||||
public class CollectionMapperProfile : Profile
|
||||
{
|
||||
public CollectionMapperProfile()
|
||||
{
|
||||
CreateMap<Table.Collection, Collection>().ReverseMap();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json;
|
||||
using AutoMapper;
|
||||
|
||||
namespace Bit.Core.Models.EntityFramework
|
||||
{
|
||||
public class CollectionCipher : Table.CollectionCipher
|
||||
{
|
||||
public virtual Cipher Cipher { get; set; }
|
||||
public virtual Collection Collection { get; set; }
|
||||
}
|
||||
|
||||
public class CollectionCipherMapperProfile : Profile
|
||||
{
|
||||
public CollectionCipherMapperProfile()
|
||||
{
|
||||
CreateMap<Table.CollectionCipher, CollectionCipher>().ReverseMap();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
using AutoMapper;
|
||||
|
||||
namespace Bit.Core.Models.EntityFramework
|
||||
{
|
||||
public class CollectionGroup : Table.CollectionGroup
|
||||
{
|
||||
public virtual Collection Collection { get; set; }
|
||||
public virtual Group Group { get; set; }
|
||||
}
|
||||
|
||||
public class CollectionGroupMapperProfile : Profile
|
||||
{
|
||||
public CollectionGroupMapperProfile()
|
||||
{
|
||||
CreateMap<Table.CollectionGroup, CollectionGroup>().ReverseMap();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
using AutoMapper;
|
||||
|
||||
namespace Bit.Core.Models.EntityFramework
|
||||
{
|
||||
public class CollectionUser : Table.CollectionUser
|
||||
{
|
||||
public virtual Collection Collection { get; set; }
|
||||
public virtual OrganizationUser OrganizationUser { get; set; }
|
||||
}
|
||||
|
||||
public class CollectionUserMapperProfile : Profile
|
||||
{
|
||||
public CollectionUserMapperProfile()
|
||||
{
|
||||
CreateMap<Table.CollectionUser, CollectionUser>().ReverseMap();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json;
|
||||
using AutoMapper;
|
||||
|
||||
namespace Bit.Core.Models.EntityFramework
|
||||
{
|
||||
public class Device : Table.Device
|
||||
{
|
||||
public virtual User User { get; set; }
|
||||
}
|
||||
|
||||
public class DeviceMapperProfile : Profile
|
||||
{
|
||||
public DeviceMapperProfile()
|
||||
{
|
||||
CreateMap<Table.Device, Device>().ReverseMap();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json;
|
||||
using AutoMapper;
|
||||
|
||||
namespace Bit.Core.Models.EntityFramework
|
||||
{
|
||||
public class EmergencyAccess : Table.EmergencyAccess
|
||||
{
|
||||
public virtual User Grantee { get; set; }
|
||||
public virtual User Grantor { get; set; }
|
||||
}
|
||||
|
||||
public class EmergencyAccessMapperProfile : Profile
|
||||
{
|
||||
public EmergencyAccessMapperProfile()
|
||||
{
|
||||
CreateMap<Table.EmergencyAccess, EmergencyAccess>().ReverseMap();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
using AutoMapper;
|
||||
|
||||
namespace Bit.Core.Models.EntityFramework
|
||||
{
|
||||
public class Event : Table.Event
|
||||
{
|
||||
}
|
||||
|
||||
public class EventMapperProfile : Profile
|
||||
{
|
||||
public EventMapperProfile()
|
||||
{
|
||||
CreateMap<Table.Event, Event>().ReverseMap();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json;
|
||||
using AutoMapper;
|
||||
|
||||
namespace Bit.Core.Models.EntityFramework
|
||||
{
|
||||
public class Folder : Table.Folder
|
||||
{
|
||||
public virtual User User { get; set; }
|
||||
}
|
||||
|
||||
public class FolderMapperProfile : Profile
|
||||
{
|
||||
public FolderMapperProfile()
|
||||
{
|
||||
CreateMap<Table.Folder, Folder>().ReverseMap();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json;
|
||||
using AutoMapper;
|
||||
|
||||
namespace Bit.Core.Models.EntityFramework
|
||||
{
|
||||
public class Grant : Table.Grant
|
||||
{
|
||||
}
|
||||
|
||||
public class GrantMapperProfile : Profile
|
||||
{
|
||||
public GrantMapperProfile()
|
||||
{
|
||||
CreateMap<Table.Grant, Grant>().ReverseMap();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json;
|
||||
using AutoMapper;
|
||||
|
||||
namespace Bit.Core.Models.EntityFramework
|
||||
{
|
||||
public class Group : Table.Group
|
||||
{
|
||||
public virtual Organization Organization { get; set; }
|
||||
public virtual ICollection<GroupUser> GroupUsers { get; set; }
|
||||
}
|
||||
|
||||
public class GroupMapperProfile : Profile
|
||||
{
|
||||
public GroupMapperProfile()
|
||||
{
|
||||
CreateMap<Table.Group, Group>().ReverseMap();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json;
|
||||
using AutoMapper;
|
||||
|
||||
namespace Bit.Core.Models.EntityFramework
|
||||
{
|
||||
public class GroupUser : Table.GroupUser
|
||||
{
|
||||
public virtual Group Group { get; set; }
|
||||
public virtual OrganizationUser OrganizationUser { get; set; }
|
||||
}
|
||||
|
||||
public class GroupUserMapperProfile : Profile
|
||||
{
|
||||
public GroupUserMapperProfile()
|
||||
{
|
||||
CreateMap<Table.GroupUser, GroupUser>().ReverseMap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,18 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json;
|
||||
using AutoMapper;
|
||||
|
||||
namespace Bit.Core.Models.EntityFramework
|
||||
{
|
||||
public class Installation : Table.Installation
|
||||
{
|
||||
}
|
||||
|
||||
public class InstallationMapperProfile : Profile
|
||||
{
|
||||
public InstallationMapperProfile()
|
||||
{
|
||||
CreateMap<Table.Installation, Installation>().ReverseMap();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using AutoMapper;
|
||||
|
||||
namespace Bit.Core.Models.EntityFramework
|
||||
{
|
||||
public class Organization : Table.Organization
|
||||
{
|
||||
public virtual ICollection<Cipher> Ciphers { get; set; }
|
||||
public virtual ICollection<OrganizationUser> OrganizationUsers { get; set; }
|
||||
public virtual ICollection<Group> Groups { get; set; }
|
||||
public virtual ICollection<Policy> Policies { get; set; }
|
||||
public virtual ICollection<SsoConfig> SsoConfigs { get; set; }
|
||||
public virtual ICollection<SsoUser> SsoUsers { get; set; }
|
||||
public virtual ICollection<Transaction> Transactions { get; set; }
|
||||
}
|
||||
|
||||
public class OrganizationMapperProfile : Profile
|
||||
{
|
||||
public OrganizationMapperProfile()
|
||||
{
|
||||
CreateMap<Table.Organization, Organization>().ReverseMap();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using AutoMapper;
|
||||
|
||||
namespace Bit.Core.Models.EntityFramework
|
||||
{
|
||||
public class OrganizationSponsorship : Table.OrganizationSponsorship
|
||||
{
|
||||
public virtual Installation Installation { get; set; }
|
||||
public virtual Organization SponsoringOrganization { get; set; }
|
||||
public virtual Organization SponsoredOrganization { get; set; }
|
||||
}
|
||||
|
||||
public class OrganizationSponsorshipMapperProfile : Profile
|
||||
{
|
||||
public OrganizationSponsorshipMapperProfile()
|
||||
{
|
||||
CreateMap<Table.OrganizationSponsorship, OrganizationSponsorship>().ReverseMap();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json;
|
||||
using AutoMapper;
|
||||
|
||||
namespace Bit.Core.Models.EntityFramework
|
||||
{
|
||||
public class OrganizationUser : Table.OrganizationUser
|
||||
{
|
||||
public virtual Organization Organization { get; set; }
|
||||
public virtual User User { get; set; }
|
||||
public virtual ICollection<CollectionUser> CollectionUsers { get; set; }
|
||||
}
|
||||
|
||||
public class OrganizationUserMapperProfile : Profile
|
||||
{
|
||||
public OrganizationUserMapperProfile()
|
||||
{
|
||||
CreateMap<Table.OrganizationUser, OrganizationUser>().ReverseMap();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json;
|
||||
using AutoMapper;
|
||||
|
||||
namespace Bit.Core.Models.EntityFramework
|
||||
{
|
||||
public class Policy : Table.Policy
|
||||
{
|
||||
public virtual Organization Organization { get; set; }
|
||||
}
|
||||
|
||||
public class PolicyMapperProfile : Profile
|
||||
{
|
||||
public PolicyMapperProfile()
|
||||
{
|
||||
CreateMap<Table.Policy, Policy>().ReverseMap();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
using AutoMapper;
|
||||
|
||||
namespace Bit.Core.Models.EntityFramework.Provider
|
||||
{
|
||||
public class Provider : Table.Provider.Provider
|
||||
{
|
||||
}
|
||||
|
||||
public class ProviderMapperProfile : Profile
|
||||
{
|
||||
public ProviderMapperProfile()
|
||||
{
|
||||
CreateMap<Table.Provider.Provider, Provider>().ReverseMap();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
using AutoMapper;
|
||||
|
||||
namespace Bit.Core.Models.EntityFramework.Provider
|
||||
{
|
||||
public class ProviderOrganization : Table.Provider.ProviderOrganization
|
||||
{
|
||||
public virtual Provider Provider { get; set; }
|
||||
public virtual Organization Organization { get; set; }
|
||||
}
|
||||
|
||||
public class ProviderOrganizationMapperProfile : Profile
|
||||
{
|
||||
public ProviderOrganizationMapperProfile()
|
||||
{
|
||||
CreateMap<Table.Provider.ProviderOrganization, ProviderOrganization>().ReverseMap();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
using AutoMapper;
|
||||
|
||||
namespace Bit.Core.Models.EntityFramework.Provider
|
||||
{
|
||||
public class ProviderUser : Table.Provider.ProviderUser
|
||||
{
|
||||
public virtual User User { get; set; }
|
||||
public virtual Provider Provider { get; set; }
|
||||
}
|
||||
|
||||
public class ProviderUserMapperProfile : Profile
|
||||
{
|
||||
public ProviderUserMapperProfile()
|
||||
{
|
||||
CreateMap<Table.Provider.ProviderUser, ProviderUser>().ReverseMap();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json;
|
||||
using AutoMapper;
|
||||
|
||||
namespace Bit.Core.Models.EntityFramework
|
||||
{
|
||||
public class Role : Table.Role
|
||||
{
|
||||
}
|
||||
|
||||
public class RoleMapperProfile : Profile
|
||||
{
|
||||
public RoleMapperProfile()
|
||||
{
|
||||
CreateMap<Table.Role, Role>().ReverseMap();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json;
|
||||
using AutoMapper;
|
||||
|
||||
namespace Bit.Core.Models.EntityFramework
|
||||
{
|
||||
public class Send : Table.Send
|
||||
{
|
||||
public virtual Organization Organization { get; set; }
|
||||
public virtual User User { get; set; }
|
||||
}
|
||||
|
||||
public class SendMapperProfile : Profile
|
||||
{
|
||||
public SendMapperProfile()
|
||||
{
|
||||
CreateMap<Table.Send, Send>().ReverseMap();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json;
|
||||
using AutoMapper;
|
||||
|
||||
namespace Bit.Core.Models.EntityFramework
|
||||
{
|
||||
public class SsoConfig : Table.SsoConfig
|
||||
{
|
||||
public virtual Organization Organization { get; set; }
|
||||
}
|
||||
|
||||
public class SsoConfigMapperProfile : Profile
|
||||
{
|
||||
public SsoConfigMapperProfile()
|
||||
{
|
||||
CreateMap<Table.SsoConfig, SsoConfig>().ReverseMap();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json;
|
||||
using AutoMapper;
|
||||
|
||||
namespace Bit.Core.Models.EntityFramework
|
||||
{
|
||||
public class SsoUser : Table.SsoUser
|
||||
{
|
||||
public virtual Organization Organization { get; set; }
|
||||
public virtual User User { get; set; }
|
||||
}
|
||||
|
||||
public class SsoUserMapperProfile : Profile
|
||||
{
|
||||
public SsoUserMapperProfile()
|
||||
{
|
||||
CreateMap<Table.SsoUser, SsoUser>().ReverseMap();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json;
|
||||
using AutoMapper;
|
||||
|
||||
namespace Bit.Core.Models.EntityFramework
|
||||
{
|
||||
public class TaxRate : Table.TaxRate
|
||||
{
|
||||
}
|
||||
|
||||
public class TaxRateMapperProfile : Profile
|
||||
{
|
||||
public TaxRateMapperProfile()
|
||||
{
|
||||
CreateMap<Table.TaxRate, TaxRate>().ReverseMap();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json;
|
||||
using AutoMapper;
|
||||
|
||||
namespace Bit.Core.Models.EntityFramework
|
||||
{
|
||||
public class Transaction : Table.Transaction
|
||||
{
|
||||
public virtual Organization Organization { get; set; }
|
||||
public virtual User User { get; set; }
|
||||
}
|
||||
|
||||
public class TransactionMapperProfile : Profile
|
||||
{
|
||||
public TransactionMapperProfile()
|
||||
{
|
||||
CreateMap<Table.Transaction, Transaction>().ReverseMap();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json;
|
||||
using AutoMapper;
|
||||
|
||||
namespace Bit.Core.Models.EntityFramework
|
||||
{
|
||||
public class U2f : Table.U2f
|
||||
{
|
||||
public virtual User User { get; set; }
|
||||
}
|
||||
|
||||
public class U2fMapperProfile : Profile
|
||||
{
|
||||
public U2fMapperProfile()
|
||||
{
|
||||
CreateMap<Table.U2f, U2f>().ReverseMap();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json;
|
||||
using AutoMapper;
|
||||
|
||||
namespace Bit.Core.Models.EntityFramework
|
||||
{
|
||||
public class User : Table.User
|
||||
{
|
||||
public virtual ICollection<Cipher> Ciphers { get; set; }
|
||||
public virtual ICollection<Folder> Folders { get; set; }
|
||||
public virtual ICollection<CollectionUser> CollectionUsers { get; set; }
|
||||
public virtual ICollection<GroupUser> GroupUsers { get; set; }
|
||||
public virtual ICollection<OrganizationUser> OrganizationUsers { get; set; }
|
||||
public virtual ICollection<SsoUser> SsoUsers { get; set; }
|
||||
public virtual ICollection<Transaction> Transactions { get; set; }
|
||||
public virtual ICollection<U2f> U2fs { get; set; }
|
||||
}
|
||||
|
||||
public class UserMapperProfile : Profile
|
||||
{
|
||||
public UserMapperProfile()
|
||||
{
|
||||
CreateMap<Table.User, User>().ReverseMap();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,111 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Bit.Core.Models.Data;
|
||||
using Bit.Core.Utilities;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Bit.Core.Models.Table
|
||||
{
|
||||
public class Cipher : ITableObject<Guid>, ICloneable
|
||||
{
|
||||
private Dictionary<string, CipherAttachment.MetaData> _attachmentData;
|
||||
|
||||
public Guid Id { get; set; }
|
||||
public Guid? UserId { get; set; }
|
||||
public Guid? OrganizationId { get; set; }
|
||||
public Enums.CipherType Type { get; set; }
|
||||
public string Data { get; set; }
|
||||
public string Favorites { get; set; }
|
||||
public string Folders { get; set; }
|
||||
public string Attachments { get; set; }
|
||||
public DateTime CreationDate { get; internal set; } = DateTime.UtcNow;
|
||||
public DateTime RevisionDate { get; internal set; } = DateTime.UtcNow;
|
||||
public DateTime? DeletedDate { get; internal set; }
|
||||
public Enums.CipherRepromptType? Reprompt { get; set; }
|
||||
|
||||
public void SetNewId()
|
||||
{
|
||||
Id = CoreHelpers.GenerateComb();
|
||||
}
|
||||
|
||||
public Dictionary<string, CipherAttachment.MetaData> GetAttachments()
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(Attachments))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (_attachmentData != null)
|
||||
{
|
||||
return _attachmentData;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
_attachmentData = JsonConvert.DeserializeObject<Dictionary<string, CipherAttachment.MetaData>>(Attachments);
|
||||
foreach (var kvp in _attachmentData)
|
||||
{
|
||||
kvp.Value.AttachmentId = kvp.Key;
|
||||
}
|
||||
return _attachmentData;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public void SetAttachments(Dictionary<string, CipherAttachment.MetaData> data)
|
||||
{
|
||||
if (data == null || data.Count == 0)
|
||||
{
|
||||
_attachmentData = null;
|
||||
Attachments = null;
|
||||
return;
|
||||
}
|
||||
|
||||
_attachmentData = data;
|
||||
Attachments = JsonConvert.SerializeObject(_attachmentData);
|
||||
}
|
||||
|
||||
public void AddAttachment(string id, CipherAttachment.MetaData data)
|
||||
{
|
||||
var attachments = GetAttachments();
|
||||
if (attachments == null)
|
||||
{
|
||||
attachments = new Dictionary<string, CipherAttachment.MetaData>();
|
||||
}
|
||||
|
||||
attachments.Add(id, data);
|
||||
SetAttachments(attachments);
|
||||
}
|
||||
|
||||
public void DeleteAttachment(string id)
|
||||
{
|
||||
var attachments = GetAttachments();
|
||||
if (!attachments?.ContainsKey(id) ?? true)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
attachments.Remove(id);
|
||||
SetAttachments(attachments);
|
||||
}
|
||||
|
||||
public bool ContainsAttachment(string id)
|
||||
{
|
||||
var attachments = GetAttachments();
|
||||
return attachments?.ContainsKey(id) ?? false;
|
||||
}
|
||||
|
||||
object ICloneable.Clone() => Clone();
|
||||
public Cipher Clone()
|
||||
{
|
||||
var clone = CoreHelpers.CloneObject(this);
|
||||
clone.CreationDate = CreationDate;
|
||||
clone.RevisionDate = RevisionDate;
|
||||
|
||||
return clone;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Bit.Core.Utilities;
|
||||
|
||||
namespace Bit.Core.Models.Table
|
||||
{
|
||||
public class Collection : ITableObject<Guid>
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public Guid OrganizationId { get; set; }
|
||||
public string Name { get; set; }
|
||||
[MaxLength(300)]
|
||||
public string ExternalId { get; set; }
|
||||
public DateTime CreationDate { get; internal set; } = DateTime.UtcNow;
|
||||
public DateTime RevisionDate { get; internal set; } = DateTime.UtcNow;
|
||||
|
||||
public void SetNewId()
|
||||
{
|
||||
Id = CoreHelpers.GenerateComb();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace Bit.Core.Models.Table
|
||||
{
|
||||
public class CollectionCipher
|
||||
{
|
||||
public Guid CollectionId { get; set; }
|
||||
public Guid CipherId { get; set; }
|
||||
}
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
using System;
|
||||
using Bit.Core.Utilities;
|
||||
|
||||
namespace Bit.Core.Models.Table
|
||||
{
|
||||
public class CollectionGroup
|
||||
{
|
||||
public Guid CollectionId { get; set; }
|
||||
public Guid GroupId { get; set; }
|
||||
public bool ReadOnly { get; set; }
|
||||
public bool HidePasswords { get; set; }
|
||||
}
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
using System;
|
||||
using Bit.Core.Utilities;
|
||||
|
||||
namespace Bit.Core.Models.Table
|
||||
{
|
||||
public class CollectionUser
|
||||
{
|
||||
public Guid CollectionId { get; set; }
|
||||
public Guid OrganizationUserId { get; set; }
|
||||
public bool ReadOnly { get; set; }
|
||||
public bool HidePasswords { get; set; }
|
||||
}
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Bit.Core.Utilities;
|
||||
|
||||
namespace Bit.Core.Models.Table
|
||||
{
|
||||
public class Device : ITableObject<Guid>
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public Guid UserId { get; set; }
|
||||
[MaxLength(50)]
|
||||
public string Name { get; set; }
|
||||
public Enums.DeviceType Type { get; set; }
|
||||
[MaxLength(50)]
|
||||
public string Identifier { get; set; }
|
||||
[MaxLength(255)]
|
||||
public string PushToken { get; set; }
|
||||
public DateTime CreationDate { get; internal set; } = DateTime.UtcNow;
|
||||
public DateTime RevisionDate { get; internal set; } = DateTime.UtcNow;
|
||||
|
||||
public void SetNewId()
|
||||
{
|
||||
Id = CoreHelpers.GenerateComb();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,48 +0,0 @@
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Bit.Core.Enums;
|
||||
using Bit.Core.Utilities;
|
||||
|
||||
namespace Bit.Core.Models.Table
|
||||
{
|
||||
public class EmergencyAccess : ITableObject<Guid>
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public Guid GrantorId { get; set; }
|
||||
public Guid? GranteeId { get; set; }
|
||||
[MaxLength(256)]
|
||||
public string Email { get; set; }
|
||||
public string KeyEncrypted { get; set; }
|
||||
public EmergencyAccessType Type { get; set; }
|
||||
public EmergencyAccessStatusType Status { get; set; }
|
||||
public int WaitTimeDays { get; set; }
|
||||
public DateTime? RecoveryInitiatedDate { get; internal set; }
|
||||
public DateTime? LastNotificationDate { get; internal set; }
|
||||
public DateTime CreationDate { get; internal set; } = DateTime.UtcNow;
|
||||
public DateTime RevisionDate { get; internal set; } = DateTime.UtcNow;
|
||||
|
||||
public void SetNewId()
|
||||
{
|
||||
Id = CoreHelpers.GenerateComb();
|
||||
}
|
||||
|
||||
public EmergencyAccess ToEmergencyAccess()
|
||||
{
|
||||
return new EmergencyAccess
|
||||
{
|
||||
Id = Id,
|
||||
GrantorId = GrantorId,
|
||||
GranteeId = GranteeId,
|
||||
Email = Email,
|
||||
KeyEncrypted = KeyEncrypted,
|
||||
Type = Type,
|
||||
Status = Status,
|
||||
WaitTimeDays = WaitTimeDays,
|
||||
RecoveryInitiatedDate = RecoveryInitiatedDate,
|
||||
LastNotificationDate = LastNotificationDate,
|
||||
CreationDate = CreationDate,
|
||||
RevisionDate = RevisionDate,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@ -1,55 +0,0 @@
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Bit.Core.Enums;
|
||||
using Bit.Core.Models.Data;
|
||||
using Bit.Core.Utilities;
|
||||
|
||||
namespace Bit.Core.Models.Table
|
||||
{
|
||||
public class Event : ITableObject<Guid>, IEvent
|
||||
{
|
||||
public Event() { }
|
||||
|
||||
public Event(IEvent e)
|
||||
{
|
||||
Date = e.Date;
|
||||
Type = e.Type;
|
||||
UserId = e.UserId;
|
||||
OrganizationId = e.OrganizationId;
|
||||
ProviderId = e.ProviderId;
|
||||
CipherId = e.CipherId;
|
||||
CollectionId = e.CollectionId;
|
||||
PolicyId = e.PolicyId;
|
||||
GroupId = e.GroupId;
|
||||
OrganizationUserId = e.OrganizationUserId;
|
||||
ProviderUserId = e.ProviderUserId;
|
||||
ProviderOrganizationId = e.ProviderOrganizationId;
|
||||
DeviceType = e.DeviceType;
|
||||
IpAddress = e.IpAddress;
|
||||
ActingUserId = e.ActingUserId;
|
||||
}
|
||||
|
||||
public Guid Id { get; set; }
|
||||
public DateTime Date { 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? PolicyId { get; set; }
|
||||
public Guid? GroupId { get; set; }
|
||||
public Guid? OrganizationUserId { get; set; }
|
||||
public Guid? ProviderUserId { get; set; }
|
||||
public Guid? ProviderOrganizationId { get; set; }
|
||||
public DeviceType? DeviceType { get; set; }
|
||||
[MaxLength(50)]
|
||||
public string IpAddress { get; set; }
|
||||
public Guid? ActingUserId { get; set; }
|
||||
|
||||
public void SetNewId()
|
||||
{
|
||||
Id = CoreHelpers.GenerateComb();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
using System;
|
||||
using Bit.Core.Utilities;
|
||||
|
||||
namespace Bit.Core.Models.Table
|
||||
{
|
||||
public class Folder : ITableObject<Guid>
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public Guid UserId { get; set; }
|
||||
public string Name { get; set; }
|
||||
public DateTime CreationDate { get; internal set; } = DateTime.UtcNow;
|
||||
public DateTime RevisionDate { get; internal set; } = DateTime.UtcNow;
|
||||
|
||||
public void SetNewId()
|
||||
{
|
||||
Id = CoreHelpers.GenerateComb();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Bit.Core.Models.Table
|
||||
{
|
||||
public class Grant
|
||||
{
|
||||
[MaxLength(200)]
|
||||
public string Key { get; set; }
|
||||
[MaxLength(50)]
|
||||
public string Type { get; set; }
|
||||
[MaxLength(200)]
|
||||
public string SubjectId { get; set; }
|
||||
[MaxLength(100)]
|
||||
public string SessionId { get; set; }
|
||||
[MaxLength(200)]
|
||||
public string ClientId { get; set; }
|
||||
[MaxLength(200)]
|
||||
public string Description { get; set; }
|
||||
public DateTime CreationDate { get; set; }
|
||||
public DateTime? ExpirationDate { get; set; }
|
||||
public DateTime? ConsumedDate { get; set; }
|
||||
public string Data { get; set; }
|
||||
}
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Bit.Core.Utilities;
|
||||
|
||||
namespace Bit.Core.Models.Table
|
||||
{
|
||||
public class Group : ITableObject<Guid>, IExternal
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public Guid OrganizationId { get; set; }
|
||||
[MaxLength(100)]
|
||||
public string Name { get; set; }
|
||||
public bool AccessAll { get; set; }
|
||||
[MaxLength(300)]
|
||||
public string ExternalId { get; set; }
|
||||
public DateTime CreationDate { get; internal set; } = DateTime.UtcNow;
|
||||
public DateTime RevisionDate { get; internal set; } = DateTime.UtcNow;
|
||||
|
||||
public void SetNewId()
|
||||
{
|
||||
Id = CoreHelpers.GenerateComb();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
using System;
|
||||
using Bit.Core.Utilities;
|
||||
|
||||
namespace Bit.Core.Models.Table
|
||||
{
|
||||
public class GroupUser
|
||||
{
|
||||
public Guid GroupId { get; set; }
|
||||
public Guid OrganizationUserId { get; set; }
|
||||
}
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace Bit.Core.Models
|
||||
{
|
||||
public interface IReferenceable
|
||||
{
|
||||
Guid Id { get; set; }
|
||||
string ReferenceData { get; set; }
|
||||
bool IsUser();
|
||||
}
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace Bit.Core.Models.Table
|
||||
{
|
||||
public interface IRevisable
|
||||
{
|
||||
DateTime CreationDate { get; }
|
||||
DateTime RevisionDate { get; }
|
||||
}
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
namespace Bit.Core.Models.Table
|
||||
{
|
||||
public interface IStorable
|
||||
{
|
||||
long? Storage { get; set; }
|
||||
short? MaxStorageGb { get; set; }
|
||||
long StorageBytesRemaining();
|
||||
long StorageBytesRemaining(short maxStorageGb);
|
||||
}
|
||||
}
|
@ -1,5 +0,0 @@
|
||||
namespace Bit.Core.Models.Table
|
||||
{
|
||||
public interface IStorableSubscriber : IStorable, ISubscriber
|
||||
{ }
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
using System;
|
||||
using Bit.Core.Enums;
|
||||
using Bit.Core.Services;
|
||||
|
||||
namespace Bit.Core.Models.Table
|
||||
{
|
||||
public interface ISubscriber
|
||||
{
|
||||
Guid Id { get; }
|
||||
GatewayType? Gateway { get; set; }
|
||||
string GatewayCustomerId { get; set; }
|
||||
string GatewaySubscriptionId { get; set; }
|
||||
string BillingEmailAddress();
|
||||
string BillingName();
|
||||
string BraintreeCustomerIdPrefix();
|
||||
string BraintreeIdField();
|
||||
string GatewayIdField();
|
||||
bool IsUser();
|
||||
}
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace Bit.Core.Models.Table
|
||||
{
|
||||
public interface ITableObject<T> where T : IEquatable<T>
|
||||
{
|
||||
T Id { get; set; }
|
||||
void SetNewId();
|
||||
}
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Bit.Core.Utilities;
|
||||
|
||||
namespace Bit.Core.Models.Table
|
||||
{
|
||||
public class Installation : ITableObject<Guid>
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
[MaxLength(256)]
|
||||
public string Email { get; set; }
|
||||
[MaxLength(150)]
|
||||
public string Key { get; set; }
|
||||
public bool Enabled { get; set; }
|
||||
public DateTime CreationDate { get; internal set; } = DateTime.UtcNow;
|
||||
|
||||
public void SetNewId()
|
||||
{
|
||||
Id = CoreHelpers.GenerateComb();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,205 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using Bit.Core.Enums;
|
||||
using Bit.Core.Utilities;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Bit.Core.Models.Table
|
||||
{
|
||||
public class Organization : ITableObject<Guid>, ISubscriber, IStorable, IStorableSubscriber, IRevisable, IReferenceable
|
||||
{
|
||||
private Dictionary<TwoFactorProviderType, TwoFactorProvider> _twoFactorProviders;
|
||||
|
||||
public Guid Id { get; set; }
|
||||
[MaxLength(50)]
|
||||
public string Identifier { get; set; }
|
||||
[MaxLength(50)]
|
||||
public string Name { get; set; }
|
||||
[MaxLength(50)]
|
||||
public string BusinessName { get; set; }
|
||||
[MaxLength(50)]
|
||||
public string BusinessAddress1 { get; set; }
|
||||
[MaxLength(50)]
|
||||
public string BusinessAddress2 { get; set; }
|
||||
[MaxLength(50)]
|
||||
public string BusinessAddress3 { get; set; }
|
||||
[MaxLength(2)]
|
||||
public string BusinessCountry { get; set; }
|
||||
[MaxLength(30)]
|
||||
public string BusinessTaxNumber { get; set; }
|
||||
[MaxLength(256)]
|
||||
public string BillingEmail { get; set; }
|
||||
[MaxLength(50)]
|
||||
public string Plan { get; set; }
|
||||
public PlanType PlanType { get; set; }
|
||||
public int? Seats { get; set; }
|
||||
public short? MaxCollections { get; set; }
|
||||
public bool UsePolicies { get; set; }
|
||||
public bool UseSso { get; set; }
|
||||
public bool UseKeyConnector { 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 SelfHost { get; set; }
|
||||
public bool UsersGetPremium { get; set; }
|
||||
public long? Storage { get; set; }
|
||||
public short? MaxStorageGb { get; set; }
|
||||
public GatewayType? Gateway { get; set; }
|
||||
[MaxLength(50)]
|
||||
public string GatewayCustomerId { get; set; }
|
||||
[MaxLength(50)]
|
||||
public string GatewaySubscriptionId { get; set; }
|
||||
public string ReferenceData { get; set; }
|
||||
public bool Enabled { get; set; } = true;
|
||||
[MaxLength(100)]
|
||||
public string LicenseKey { get; set; }
|
||||
[MaxLength(30)]
|
||||
public string ApiKey { get; set; }
|
||||
public string PublicKey { get; set; }
|
||||
public string PrivateKey { get; set; }
|
||||
public string TwoFactorProviders { get; set; }
|
||||
public DateTime? ExpirationDate { get; set; }
|
||||
public DateTime CreationDate { get; internal set; } = DateTime.UtcNow;
|
||||
public DateTime RevisionDate { get; internal set; } = DateTime.UtcNow;
|
||||
public int? MaxAutoscaleSeats { get; set; } = null;
|
||||
public DateTime? OwnersNotifiedOfAutoscaling { get; set; } = null;
|
||||
|
||||
public void SetNewId()
|
||||
{
|
||||
if (Id == default(Guid))
|
||||
{
|
||||
Id = CoreHelpers.GenerateComb();
|
||||
}
|
||||
}
|
||||
|
||||
public string BillingEmailAddress()
|
||||
{
|
||||
return BillingEmail?.ToLowerInvariant()?.Trim();
|
||||
}
|
||||
|
||||
public string BillingName()
|
||||
{
|
||||
return BusinessName;
|
||||
}
|
||||
|
||||
public string BraintreeCustomerIdPrefix()
|
||||
{
|
||||
return "o";
|
||||
}
|
||||
|
||||
public string BraintreeIdField()
|
||||
{
|
||||
return "organization_id";
|
||||
}
|
||||
|
||||
public string GatewayIdField()
|
||||
{
|
||||
return "organizationId";
|
||||
}
|
||||
|
||||
public bool IsUser()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public long StorageBytesRemaining()
|
||||
{
|
||||
if (!MaxStorageGb.HasValue)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return StorageBytesRemaining(MaxStorageGb.Value);
|
||||
}
|
||||
|
||||
public long StorageBytesRemaining(short maxStorageGb)
|
||||
{
|
||||
var maxStorageBytes = maxStorageGb * 1073741824L;
|
||||
if (!Storage.HasValue)
|
||||
{
|
||||
return maxStorageBytes;
|
||||
}
|
||||
|
||||
return maxStorageBytes - Storage.Value;
|
||||
}
|
||||
|
||||
public Dictionary<TwoFactorProviderType, TwoFactorProvider> GetTwoFactorProviders()
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(TwoFactorProviders))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (_twoFactorProviders == null)
|
||||
{
|
||||
_twoFactorProviders =
|
||||
JsonConvert.DeserializeObject<Dictionary<TwoFactorProviderType, TwoFactorProvider>>(
|
||||
TwoFactorProviders);
|
||||
}
|
||||
|
||||
return _twoFactorProviders;
|
||||
}
|
||||
catch (JsonSerializationException)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public void SetTwoFactorProviders(Dictionary<TwoFactorProviderType, TwoFactorProvider> providers)
|
||||
{
|
||||
if (!providers.Any())
|
||||
{
|
||||
TwoFactorProviders = null;
|
||||
_twoFactorProviders = null;
|
||||
return;
|
||||
}
|
||||
|
||||
TwoFactorProviders = JsonConvert.SerializeObject(providers, new JsonSerializerSettings
|
||||
{
|
||||
ContractResolver = new EnumKeyResolver<byte>()
|
||||
});
|
||||
_twoFactorProviders = providers;
|
||||
}
|
||||
|
||||
public bool TwoFactorProviderIsEnabled(TwoFactorProviderType provider)
|
||||
{
|
||||
var providers = GetTwoFactorProviders();
|
||||
if (providers == null || !providers.ContainsKey(provider))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return providers[provider].Enabled && Use2fa;
|
||||
}
|
||||
|
||||
public bool TwoFactorIsEnabled()
|
||||
{
|
||||
var providers = GetTwoFactorProviders();
|
||||
if (providers == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return providers.Any(p => (p.Value?.Enabled ?? false) && Use2fa);
|
||||
}
|
||||
|
||||
public TwoFactorProvider GetTwoFactorProvider(TwoFactorProviderType provider)
|
||||
{
|
||||
var providers = GetTwoFactorProviders();
|
||||
if (providers == null || !providers.ContainsKey(provider))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return providers[provider];
|
||||
}
|
||||
}
|
||||
}
|
@ -1,31 +0,0 @@
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Bit.Core.Enums;
|
||||
using Bit.Core.Utilities;
|
||||
|
||||
namespace Bit.Core.Models.Table
|
||||
{
|
||||
public class OrganizationSponsorship : ITableObject<Guid>
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public Guid? InstallationId { get; set; }
|
||||
public Guid? SponsoringOrganizationId { get; set; }
|
||||
public Guid? SponsoringOrganizationUserId { get; set; }
|
||||
public Guid? SponsoredOrganizationId { get; set; }
|
||||
[MaxLength(256)]
|
||||
public string FriendlyName { get; set; }
|
||||
[MaxLength(256)]
|
||||
public string OfferedToEmail { get; set; }
|
||||
public PlanSponsorshipType? PlanSponsorshipType { get; set; }
|
||||
[Required]
|
||||
public bool CloudSponsor { get; set; }
|
||||
public DateTime? LastSyncDate { get; set; }
|
||||
public byte TimesRenewedWithoutValidation { get; set; }
|
||||
public DateTime? SponsorshipLapsedDate { get; set; }
|
||||
|
||||
public void SetNewId()
|
||||
{
|
||||
Id = CoreHelpers.GenerateComb();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,31 +0,0 @@
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Bit.Core.Enums;
|
||||
using Bit.Core.Utilities;
|
||||
|
||||
namespace Bit.Core.Models.Table
|
||||
{
|
||||
public class OrganizationUser : ITableObject<Guid>, IExternal
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public Guid OrganizationId { get; set; }
|
||||
public Guid? UserId { get; set; }
|
||||
[MaxLength(256)]
|
||||
public string Email { get; set; }
|
||||
public string Key { get; set; }
|
||||
public string ResetPasswordKey { get; set; }
|
||||
public OrganizationUserStatusType Status { get; set; }
|
||||
public OrganizationUserType Type { get; set; }
|
||||
public bool AccessAll { get; set; }
|
||||
[MaxLength(300)]
|
||||
public string ExternalId { get; set; }
|
||||
public DateTime CreationDate { get; internal set; } = DateTime.UtcNow;
|
||||
public DateTime RevisionDate { get; internal set; } = DateTime.UtcNow;
|
||||
public string Permissions { get; set; }
|
||||
|
||||
public void SetNewId()
|
||||
{
|
||||
Id = CoreHelpers.GenerateComb();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
using System;
|
||||
using Bit.Core.Enums;
|
||||
using Bit.Core.Utilities;
|
||||
|
||||
namespace Bit.Core.Models.Table
|
||||
{
|
||||
public class Policy : ITableObject<Guid>
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public Guid OrganizationId { get; set; }
|
||||
public PolicyType Type { get; set; }
|
||||
public string Data { get; set; }
|
||||
public bool Enabled { get; set; }
|
||||
public DateTime CreationDate { get; internal set; } = DateTime.UtcNow;
|
||||
public DateTime RevisionDate { get; internal set; } = DateTime.UtcNow;
|
||||
|
||||
public void SetNewId()
|
||||
{
|
||||
Id = CoreHelpers.GenerateComb();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
using System;
|
||||
using Bit.Core.Enums.Provider;
|
||||
using Bit.Core.Utilities;
|
||||
|
||||
namespace Bit.Core.Models.Table.Provider
|
||||
{
|
||||
public class Provider : ITableObject<Guid>
|
||||
{
|
||||
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 ProviderStatusType Status { get; set; }
|
||||
public bool UseEvents { get; set; }
|
||||
public bool Enabled { get; set; } = true;
|
||||
public DateTime CreationDate { get; internal set; } = DateTime.UtcNow;
|
||||
public DateTime RevisionDate { get; internal set; } = DateTime.UtcNow;
|
||||
|
||||
public void SetNewId()
|
||||
{
|
||||
if (Id == default)
|
||||
{
|
||||
Id = CoreHelpers.GenerateComb();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
using System;
|
||||
using Bit.Core.Utilities;
|
||||
|
||||
namespace Bit.Core.Models.Table.Provider
|
||||
{
|
||||
public class ProviderOrganization : ITableObject<Guid>
|
||||
{
|
||||
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; internal set; } = DateTime.UtcNow;
|
||||
public DateTime RevisionDate { get; internal set; } = DateTime.UtcNow;
|
||||
|
||||
public void SetNewId()
|
||||
{
|
||||
if (Id == default)
|
||||
{
|
||||
Id = CoreHelpers.GenerateComb();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
using System;
|
||||
using Bit.Core.Enums.Provider;
|
||||
using Bit.Core.Utilities;
|
||||
|
||||
namespace Bit.Core.Models.Table.Provider
|
||||
{
|
||||
public class ProviderUser : ITableObject<Guid>
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public Guid ProviderId { get; set; }
|
||||
public Guid? UserId { get; set; }
|
||||
public string Email { get; set; }
|
||||
public string Key { get; set; }
|
||||
public ProviderUserStatusType Status { get; set; }
|
||||
public ProviderUserType Type { get; set; }
|
||||
public string Permissions { get; set; }
|
||||
public DateTime CreationDate { get; set; } = DateTime.UtcNow;
|
||||
public DateTime RevisionDate { get; set; } = DateTime.UtcNow;
|
||||
|
||||
public void SetNewId()
|
||||
{
|
||||
if (Id == default)
|
||||
{
|
||||
Id = CoreHelpers.GenerateComb();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
namespace Bit.Core.Models.Table
|
||||
{
|
||||
/// <summary>
|
||||
/// This class is not used. It is implemented to make the Identity provider happy.
|
||||
/// </summary>
|
||||
public class Role
|
||||
{
|
||||
public string Name { get; set; }
|
||||
}
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Bit.Core.Enums;
|
||||
using Bit.Core.Utilities;
|
||||
|
||||
namespace Bit.Core.Models.Table
|
||||
{
|
||||
public class Send : ITableObject<Guid>
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public Guid? UserId { get; set; }
|
||||
public Guid? OrganizationId { get; set; }
|
||||
public SendType Type { get; set; }
|
||||
public string Data { get; set; }
|
||||
public string Key { get; set; }
|
||||
[MaxLength(300)]
|
||||
public string Password { get; set; }
|
||||
public int? MaxAccessCount { get; set; }
|
||||
public int AccessCount { get; set; }
|
||||
public DateTime CreationDate { get; internal set; } = DateTime.UtcNow;
|
||||
public DateTime RevisionDate { get; internal set; } = DateTime.UtcNow;
|
||||
public DateTime? ExpirationDate { get; set; }
|
||||
public DateTime DeletionDate { get; set; }
|
||||
public bool Disabled { get; set; }
|
||||
public bool? HideEmail { get; set; }
|
||||
|
||||
public void SetNewId()
|
||||
{
|
||||
Id = CoreHelpers.GenerateComb();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,31 +0,0 @@
|
||||
using System;
|
||||
using Bit.Core.Models.Data;
|
||||
|
||||
namespace Bit.Core.Models.Table
|
||||
{
|
||||
public class SsoConfig : ITableObject<long>
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public bool Enabled { get; set; } = true;
|
||||
public Guid OrganizationId { get; set; }
|
||||
public string Data { get; set; }
|
||||
public DateTime CreationDate { get; internal set; } = DateTime.UtcNow;
|
||||
public DateTime RevisionDate { get; internal set; } = DateTime.UtcNow;
|
||||
|
||||
public void SetNewId()
|
||||
{
|
||||
// int will be auto-populated
|
||||
Id = 0;
|
||||
}
|
||||
|
||||
public SsoConfigurationData GetData()
|
||||
{
|
||||
return SsoConfigurationData.Deserialize(Data);
|
||||
}
|
||||
|
||||
public void SetData(SsoConfigurationData data)
|
||||
{
|
||||
Data = data.Serialize();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Bit.Core.Models.Table
|
||||
{
|
||||
public class SsoUser : ITableObject<long>
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public Guid UserId { get; set; }
|
||||
public Guid? OrganizationId { get; set; }
|
||||
[MaxLength(50)]
|
||||
public string ExternalId { get; set; }
|
||||
public DateTime CreationDate { get; internal set; } = DateTime.UtcNow;
|
||||
|
||||
public void SetNewId()
|
||||
{
|
||||
// int will be auto-populated
|
||||
Id = 0;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Bit.Core.Models.Table
|
||||
{
|
||||
public class TaxRate : ITableObject<string>
|
||||
{
|
||||
[MaxLength(40)]
|
||||
public string Id { get; set; }
|
||||
[MaxLength(50)]
|
||||
public string Country { get; set; }
|
||||
[MaxLength(2)]
|
||||
public string State { get; set; }
|
||||
[MaxLength(10)]
|
||||
public string PostalCode { get; set; }
|
||||
public decimal Rate { get; set; }
|
||||
public bool Active { get; set; }
|
||||
|
||||
public void SetNewId()
|
||||
{
|
||||
// Id is created by Stripe, should exist before this gets called
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Bit.Core.Enums;
|
||||
using Bit.Core.Utilities;
|
||||
|
||||
namespace Bit.Core.Models.Table
|
||||
{
|
||||
public class Transaction : ITableObject<Guid>
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public Guid? UserId { get; set; }
|
||||
public Guid? OrganizationId { get; set; }
|
||||
public TransactionType Type { get; set; }
|
||||
public decimal Amount { get; set; }
|
||||
public bool? Refunded { get; set; }
|
||||
public decimal? RefundedAmount { get; set; }
|
||||
[MaxLength(100)]
|
||||
public string Details { get; set; }
|
||||
public PaymentMethodType? PaymentMethodType { get; set; }
|
||||
public GatewayType? Gateway { get; set; }
|
||||
[MaxLength(50)]
|
||||
public string GatewayId { get; set; }
|
||||
public DateTime CreationDate { get; set; } = DateTime.UtcNow;
|
||||
|
||||
public void SetNewId()
|
||||
{
|
||||
Id = CoreHelpers.GenerateComb();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Bit.Core.Models.Table
|
||||
{
|
||||
public class U2f : ITableObject<int>
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public Guid UserId { get; set; }
|
||||
[MaxLength(200)]
|
||||
public string KeyHandle { get; set; }
|
||||
[MaxLength(200)]
|
||||
public string Challenge { get; set; }
|
||||
[MaxLength(50)]
|
||||
public string AppId { get; set; }
|
||||
[MaxLength(20)]
|
||||
public string Version { get; set; }
|
||||
public DateTime CreationDate { get; internal set; } = DateTime.UtcNow;
|
||||
|
||||
public void SetNewId()
|
||||
{
|
||||
// int will be auto-populated
|
||||
Id = 0;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,188 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Bit.Core.Enums;
|
||||
using Bit.Core.Utilities;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Bit.Core.Models.Table
|
||||
{
|
||||
public class User : ITableObject<Guid>, ISubscriber, IStorable, IStorableSubscriber, IRevisable, ITwoFactorProvidersUser, IReferenceable
|
||||
{
|
||||
private Dictionary<TwoFactorProviderType, TwoFactorProvider> _twoFactorProviders;
|
||||
|
||||
public Guid Id { get; set; }
|
||||
[MaxLength(50)]
|
||||
public string Name { get; set; }
|
||||
[Required]
|
||||
[MaxLength(256)]
|
||||
public string Email { get; set; }
|
||||
public bool EmailVerified { get; set; }
|
||||
[MaxLength(300)]
|
||||
public string MasterPassword { get; set; }
|
||||
[MaxLength(50)]
|
||||
public string MasterPasswordHint { get; set; }
|
||||
[MaxLength(10)]
|
||||
public string Culture { get; set; } = "en-US";
|
||||
[Required]
|
||||
[MaxLength(50)]
|
||||
public string SecurityStamp { get; set; }
|
||||
public string TwoFactorProviders { get; set; }
|
||||
[MaxLength(32)]
|
||||
public string TwoFactorRecoveryCode { get; set; }
|
||||
public string EquivalentDomains { get; set; }
|
||||
public string ExcludedGlobalEquivalentDomains { get; set; }
|
||||
public DateTime AccountRevisionDate { get; internal set; } = DateTime.UtcNow;
|
||||
public string Key { get; set; }
|
||||
public string PublicKey { get; set; }
|
||||
public string PrivateKey { get; set; }
|
||||
public bool Premium { get; set; }
|
||||
public DateTime? PremiumExpirationDate { get; set; }
|
||||
public DateTime? RenewalReminderDate { get; set; }
|
||||
public long? Storage { get; set; }
|
||||
public short? MaxStorageGb { get; set; }
|
||||
public GatewayType? Gateway { get; set; }
|
||||
[MaxLength(50)]
|
||||
public string GatewayCustomerId { get; set; }
|
||||
[MaxLength(50)]
|
||||
public string GatewaySubscriptionId { get; set; }
|
||||
public string ReferenceData { get; set; }
|
||||
[MaxLength(100)]
|
||||
public string LicenseKey { get; set; }
|
||||
[Required]
|
||||
[MaxLength(30)]
|
||||
public string ApiKey { get; set; }
|
||||
public KdfType Kdf { get; set; } = KdfType.PBKDF2_SHA256;
|
||||
public int KdfIterations { get; set; } = 5000;
|
||||
public DateTime CreationDate { get; internal set; } = DateTime.UtcNow;
|
||||
public DateTime RevisionDate { get; internal set; } = DateTime.UtcNow;
|
||||
public bool ForcePasswordReset { get; set; }
|
||||
public bool UsesKeyConnector { get; set; }
|
||||
|
||||
public void SetNewId()
|
||||
{
|
||||
Id = CoreHelpers.GenerateComb();
|
||||
}
|
||||
|
||||
public string BillingEmailAddress()
|
||||
{
|
||||
return Email?.ToLowerInvariant()?.Trim();
|
||||
}
|
||||
|
||||
public string BillingName()
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
|
||||
public string BraintreeCustomerIdPrefix()
|
||||
{
|
||||
return "u";
|
||||
}
|
||||
|
||||
public string BraintreeIdField()
|
||||
{
|
||||
return "user_id";
|
||||
}
|
||||
|
||||
public string GatewayIdField()
|
||||
{
|
||||
return "userId";
|
||||
}
|
||||
|
||||
public bool IsUser()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public Dictionary<TwoFactorProviderType, TwoFactorProvider> GetTwoFactorProviders()
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(TwoFactorProviders))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (_twoFactorProviders == null)
|
||||
{
|
||||
_twoFactorProviders =
|
||||
JsonConvert.DeserializeObject<Dictionary<TwoFactorProviderType, TwoFactorProvider>>(
|
||||
TwoFactorProviders);
|
||||
}
|
||||
|
||||
return _twoFactorProviders;
|
||||
}
|
||||
catch (JsonSerializationException)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Guid? GetUserId()
|
||||
{
|
||||
return Id;
|
||||
}
|
||||
|
||||
public bool GetPremium()
|
||||
{
|
||||
return Premium;
|
||||
}
|
||||
|
||||
public void SetTwoFactorProviders(Dictionary<TwoFactorProviderType, TwoFactorProvider> providers)
|
||||
{
|
||||
TwoFactorProviders = JsonConvert.SerializeObject(providers, new JsonSerializerSettings
|
||||
{
|
||||
ContractResolver = new EnumKeyResolver<byte>()
|
||||
});
|
||||
_twoFactorProviders = providers;
|
||||
}
|
||||
|
||||
public TwoFactorProvider GetTwoFactorProvider(TwoFactorProviderType provider)
|
||||
{
|
||||
var providers = GetTwoFactorProviders();
|
||||
if (providers == null || !providers.ContainsKey(provider))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return providers[provider];
|
||||
}
|
||||
|
||||
public long StorageBytesRemaining()
|
||||
{
|
||||
if (!MaxStorageGb.HasValue)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return StorageBytesRemaining(MaxStorageGb.Value);
|
||||
}
|
||||
|
||||
public long StorageBytesRemaining(short maxStorageGb)
|
||||
{
|
||||
var maxStorageBytes = maxStorageGb * 1073741824L;
|
||||
if (!Storage.HasValue)
|
||||
{
|
||||
return maxStorageBytes;
|
||||
}
|
||||
|
||||
return maxStorageBytes - Storage.Value;
|
||||
}
|
||||
|
||||
public IdentityUser ToIdentityUser(bool twoFactorEnabled)
|
||||
{
|
||||
return new IdentityUser
|
||||
{
|
||||
Id = Id.ToString(),
|
||||
Email = Email,
|
||||
NormalizedEmail = Email,
|
||||
EmailConfirmed = EmailVerified,
|
||||
UserName = Email,
|
||||
NormalizedUserName = Email,
|
||||
TwoFactorEnabled = twoFactorEnabled,
|
||||
SecurityStamp = SecurityStamp
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user