1
0
mirror of https://github.com/bitwarden/server.git synced 2025-06-30 23:52:50 -05:00

Postgres & MySql Support For Self-Hosted Installations (#1386)

* EF Database Support Init (#1221)

* scaffolding for ef support

* deleted old postgres repos

* added tables to oncreate

* updated all the things to .NET 5

* Addition to #1221: Migrated DockerFiles from dotnet/3.1 to  5.0 (#1223)

* Migrated DockerFiles from dotnet/3.1 to  5.0

* Migrated SSO/Dockerfile from dotnet 3.1 to 5.0

Co-authored-by: Daniel James Smith <djsmith85@users.noreply.github.com>

* EFDatabaseSupport: Updated links and description in README.md and SETUP.md (#1232)

* Updated requirements in README.md

* Updated link to documentation of app-secrets

* upgraded dotnet version to 5.0

* Ef database support implementation examples (#1265)

* mostly finished testing the user repo

* finished testing user repo

* finished org, user, ssoconfig, and ssouser ef implementations

* removed unused prop

* fixed a sql file

* fixed a spacing issue

* fixed a spacing issue

* removed extra database creation

* refactoring

* MsSql => SqlServer

* refactoring

* code review fixes

* build fix

* code review

* continued attempts to fix the the build

* skipped another test

* finished all create test

* initial pass at several repos

* continued building out repos

* initial pass at several repos

* initial pass at device repo

* initial pass at collection repo

* initial run of all Entity Framework implementations

* signup, signin, create/edit ciphers works

* sync working

* all web vault pages seem to load with 100% 200s

* bulkcopy, folders, and favorites

* group and collection management

* sso, groups, emergency access, send

* get basic creates matching on all repos

* got everything building again post merge

* removed some IDE config files

* cleanup

* no more notimplemented methods in the cipher repo

* no more not implementeds everywhere

* cleaned up schema/navigation properties and fixed tests

* removed a sql comment that was written in c# style

* fixed build issues from merge

* removed unsupported db providers

* formatting

* code review refactors

* naming cleanup for queries

* added provider methods

* cipher repo cleanup

* implemented several missing procedures from the EF implementation surround account revision dates, keys, and storage

* fixed the build

* added a null check

* consolidated some cipher repo methods

* formatting fix

* cleaned up indentation of queries

* removed .idea file

* generated postgres migrations

* added mysql migrations

* formatting

* Bug Fixes & Formatting

* Formatting

* fixed a bug with bulk import when using MySql

* code review fixes

* fixed the build

* implemented new methods

* formatting

* fixed the build

* cleaned up select statements in ef queries

* formatting

* formatting

* formatting

Co-authored-by: Daniel James Smith <djsmith85@users.noreply.github.com>
This commit is contained in:
Addison Beck
2021-07-08 12:35:48 -04:00
committed by GitHub
parent be13eb153a
commit b13dda2799
251 changed files with 21099 additions and 608 deletions

View File

@ -52,8 +52,8 @@ namespace Bit.Core.Models.Api
public bool UseBusinessPortal => UsePolicies || UseSso; // TODO add events if needed
public bool UsersGetPremium { get; set; }
public bool SelfHost { get; set; }
public int Seats { get; set; }
public int MaxCollections { 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; }

View File

@ -0,0 +1,10 @@
using System.Data;
using Bit.Core.Models.Table;
namespace Bit.Core.Models.Data
{
public class GroupWithCollections : Group
{
public DataTable Collections { get; set; }
}
}

View File

@ -19,8 +19,8 @@ namespace Bit.Core.Models.Data
public bool UseBusinessPortal => UsePolicies || UseSso;
public bool SelfHost { get; set; }
public bool UsersGetPremium { get; set; }
public int Seats { get; set; }
public int MaxCollections { get; set; }
public int? Seats { get; set; }
public short? MaxCollections { get; set; }
public short? MaxStorageGb { get; set; }
public string Key { get; set; }
public Enums.OrganizationUserStatusType Status { get; set; }

View File

@ -0,0 +1,10 @@
using System.Data;
using Bit.Core.Models.Table;
namespace Bit.Core.Models.Data
{
public class OrganizationUserWithCollections : OrganizationUser
{
public DataTable Collections { get; set; }
}
}

View File

@ -1,57 +1,14 @@
using System.Text.Json;
using System.Collections.Generic;
using System.Text.Json;
using AutoMapper;
namespace Bit.Core.Models.EntityFramework
{
public class Cipher : Table.Cipher
{
private JsonDocument _dataJson;
private JsonDocument _attachmentsJson;
private JsonDocument _favoritesJson;
private JsonDocument _foldersJson;
public User User { get; set; }
public Organization Organization { get; set; }
[IgnoreMap]
public JsonDocument DataJson
{
get => _dataJson;
set
{
Data = value?.ToString();
_dataJson = value;
}
}
[IgnoreMap]
public JsonDocument AttachmentsJson
{
get => _attachmentsJson;
set
{
Attachments = value?.ToString();
_attachmentsJson = value;
}
}
[IgnoreMap]
public JsonDocument FavoritesJson
{
get => _favoritesJson;
set
{
Favorites = value?.ToString();
_favoritesJson = value;
}
}
[IgnoreMap]
public JsonDocument FoldersJson
{
get => _foldersJson;
set
{
Folders = value?.ToString();
_foldersJson = value;
}
}
public virtual User User { get; set; }
public virtual Organization Organization { get; set; }
public virtual ICollection<CollectionCipher> CollectionCiphers { get; set; }
}
public class CipherMapperProfile : Profile

View File

@ -0,0 +1,22 @@
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();
}
}
}

View File

@ -0,0 +1,20 @@
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();
}
}
}

View File

@ -0,0 +1,18 @@
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();
}
}
}

View File

@ -0,0 +1,18 @@
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();
}
}
}

View File

@ -0,0 +1,19 @@
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();
}
}
}

View File

@ -0,0 +1,20 @@
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();
}
}
}

View File

@ -0,0 +1,18 @@
using System.Collections.Generic;
using System.Text.Json;
using AutoMapper;
namespace Bit.Core.Models.EntityFramework
{
public class Event : Table.Event
{
}
public class EventMapperProfile : Profile
{
public EventMapperProfile()
{
CreateMap<Table.Event, Event>().ReverseMap();
}
}
}

View File

@ -0,0 +1,19 @@
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();
}
}
}

View File

@ -0,0 +1,18 @@
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();
}
}
}

View File

@ -0,0 +1,20 @@
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();
}
}
}

View File

@ -0,0 +1,21 @@
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();
}
}
}

View File

@ -0,0 +1,18 @@
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();
}
}
}

View File

@ -1,25 +1,17 @@
using System.Collections.Generic;
using System.Text.Json;
using AutoMapper;
namespace Bit.Core.Models.EntityFramework
{
public class Organization : Table.Organization
{
private JsonDocument _twoFactorProvidersJson;
public ICollection<Cipher> Ciphers { get; set; }
[IgnoreMap]
public JsonDocument TwoFactorProvidersJson
{
get => _twoFactorProvidersJson;
set
{
TwoFactorProviders = value?.ToString();
_twoFactorProvidersJson = value;
}
}
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

View File

@ -0,0 +1,21 @@
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();
}
}
}

View File

@ -0,0 +1,19 @@
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();
}
}
}

View File

@ -0,0 +1,16 @@
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();
}
}
}

View File

@ -0,0 +1,18 @@
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();
}
}
}

View File

@ -0,0 +1,18 @@
using AutoMapper;
namespace Bit.Core.Models.EntityFramework.Provider
{
public class ProviderOrganizationProviderUser : Table.Provider.ProviderOrganizationProviderUser
{
public virtual ProviderOrganization ProviderOrganization { get; set; }
public virtual ProviderUser ProviderUser { get; set; }
}
public class ProviderOrganizationProviderUserMapperProfile : Profile
{
public ProviderOrganizationProviderUserMapperProfile()
{
CreateMap<Table.Provider.ProviderOrganizationProviderUser, ProviderOrganizationProviderUser>().ReverseMap();
}
}
}

View File

@ -0,0 +1,18 @@
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();
}
}
}

View File

@ -0,0 +1,18 @@
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();
}
}
}

View File

@ -0,0 +1,20 @@
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();
}
}
}

View File

@ -0,0 +1,19 @@
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();
}
}
}

View File

@ -0,0 +1,20 @@
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();
}
}
}

View File

@ -0,0 +1,18 @@
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();
}
}
}

View File

@ -0,0 +1,20 @@
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();
}
}
}

View File

@ -0,0 +1,19 @@
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();
}
}
}

View File

@ -6,20 +6,14 @@ namespace Bit.Core.Models.EntityFramework
{
public class User : Table.User
{
private JsonDocument _twoFactorProvidersJson;
public ICollection<Cipher> Ciphers { get; set; }
[IgnoreMap]
public JsonDocument TwoFactorProvidersJson
{
get => _twoFactorProvidersJson;
set
{
TwoFactorProviders = value?.ToString();
_twoFactorProvidersJson = value;
}
}
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

View File

@ -1,4 +1,5 @@
using System;
using System.ComponentModel.DataAnnotations;
using Bit.Core.Utilities;
namespace Bit.Core.Models.Table
@ -8,6 +9,7 @@ namespace Bit.Core.Models.Table
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;

View File

@ -0,0 +1,13 @@
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; }
}
}

View File

@ -0,0 +1,13 @@
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; }
}
}

View File

@ -1,4 +1,5 @@
using System;
using System.ComponentModel.DataAnnotations;
using Bit.Core.Utilities;
namespace Bit.Core.Models.Table
@ -7,9 +8,12 @@ namespace Bit.Core.Models.Table
{
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;

View File

@ -1,4 +1,5 @@
using System;
using System.ComponentModel.DataAnnotations;
using Bit.Core.Enums;
using Bit.Core.Utilities;
@ -9,6 +10,7 @@ namespace Bit.Core.Models.Table
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; }

View File

@ -1,4 +1,5 @@
using System;
using System.ComponentModel.DataAnnotations;
using Bit.Core.Enums;
using Bit.Core.Models.Data;
using Bit.Core.Utilities;
@ -36,6 +37,7 @@ namespace Bit.Core.Models.Table
public Guid? GroupId { get; set; }
public Guid? OrganizationUserId { get; set; }
public DeviceType? DeviceType { get; set; }
[MaxLength(50)]
public string IpAddress { get; set; }
public Guid? ActingUserId { get; set; }

View File

@ -1,14 +1,21 @@
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; }

View File

@ -1,4 +1,5 @@
using System;
using System.ComponentModel.DataAnnotations;
using Bit.Core.Utilities;
namespace Bit.Core.Models.Table
@ -7,8 +8,10 @@ namespace Bit.Core.Models.Table
{
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;

View File

@ -1,12 +1,15 @@
using Bit.Core.Utilities;
using System;
using System.ComponentModel.DataAnnotations;
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;

View File

@ -4,6 +4,7 @@ using Bit.Core.Enums;
using System.Collections.Generic;
using Newtonsoft.Json;
using System.Linq;
using System.ComponentModel.DataAnnotations;
namespace Bit.Core.Models.Table
{
@ -12,15 +13,25 @@ namespace Bit.Core.Models.Table
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; }
@ -39,11 +50,15 @@ namespace Bit.Core.Models.Table
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; }

View File

@ -1,6 +1,7 @@
using System;
using Bit.Core.Utilities;
using Bit.Core.Enums;
using System.ComponentModel.DataAnnotations;
namespace Bit.Core.Models.Table
{
@ -9,12 +10,14 @@ namespace Bit.Core.Models.Table
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;

View File

@ -1,4 +1,5 @@
using System;
using System.ComponentModel.DataAnnotations;
using Bit.Core.Enums;
using Bit.Core.Utilities;
@ -12,6 +13,7 @@ namespace Bit.Core.Models.Table
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; }

View File

@ -13,7 +13,8 @@ namespace Bit.Core.Models.Table
public void SetNewId()
{
// nothing - int will be auto-populated
// int will be auto-populated
Id = 0;
}
}
}

View File

@ -1,4 +1,5 @@
using System;
using System.ComponentModel.DataAnnotations;
namespace Bit.Core.Models.Table
{
@ -7,12 +8,14 @@ namespace Bit.Core.Models.Table
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()
{
// nothing - int will be auto-populated
// int will be auto-populated
Id = 0;
}
}
}

View File

@ -1,10 +1,16 @@
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; }

View File

@ -1,4 +1,5 @@
using System;
using System.ComponentModel.DataAnnotations;
using Bit.Core.Enums;
using Bit.Core.Utilities;
@ -13,9 +14,11 @@ namespace Bit.Core.Models.Table
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;

View File

@ -1,4 +1,5 @@
using System;
using System.ComponentModel.DataAnnotations;
namespace Bit.Core.Models.Table
{
@ -6,15 +7,20 @@ namespace Bit.Core.Models.Table
{
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()
{
// do nothing since it is an identity
// int will be auto-populated
Id = 0;
}
}
}

View File

@ -4,6 +4,7 @@ using Bit.Core.Utilities;
using System.Collections.Generic;
using Newtonsoft.Json;
using Microsoft.AspNetCore.Identity;
using System.ComponentModel.DataAnnotations;
namespace Bit.Core.Models.Table
{
@ -12,14 +13,23 @@ namespace Bit.Core.Models.Table
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; }
@ -33,10 +43,15 @@ namespace Bit.Core.Models.Table
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;