1
0
mirror of https://github.com/bitwarden/server.git synced 2025-06-30 07:36:14 -05:00

[SM-394] Secrets Manager (#2164)

Long lived feature branch for Secrets Manager

Co-authored-by: Thomas Avery <43214426+Thomas-Avery@users.noreply.github.com>
Co-authored-by: cd-bitwarden <106776772+cd-bitwarden@users.noreply.github.com>
Co-authored-by: CarleyDiaz-Bitwarden <103955722+CarleyDiaz-Bitwarden@users.noreply.github.com>
Co-authored-by: Thomas Avery <tavery@bitwarden.com>
Co-authored-by: Colton Hurst <colton@coltonhurst.com>
This commit is contained in:
Oscar Hinton
2023-01-13 15:02:53 +01:00
committed by GitHub
parent 09e524c9a2
commit 1f0fc43278
188 changed files with 21346 additions and 329 deletions

View File

@ -18,19 +18,94 @@ namespace Bit.PostgresMigrations.Migrations
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("Npgsql:CollationDefinition:postgresIndetermanisticCollation", "en-u-ks-primary,en-u-ks-primary,icu,False")
.HasAnnotation("ProductVersion", "6.0.4")
.HasAnnotation("ProductVersion", "6.0.12")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.AccessPolicy", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uuid");
b.Property<DateTime>("CreationDate")
.HasColumnType("timestamp with time zone");
b.Property<string>("Discriminator")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("Read")
.HasColumnType("boolean");
b.Property<DateTime>("RevisionDate")
.HasColumnType("timestamp with time zone");
b.Property<bool>("Write")
.HasColumnType("boolean");
b.HasKey("Id")
.HasAnnotation("SqlServer:Clustered", true);
b.ToTable("AccessPolicy", (string)null);
b.HasDiscriminator<string>("Discriminator").HasValue("AccessPolicy");
});
modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.ApiKey", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uuid");
b.Property<string>("ClientSecret")
.HasMaxLength(30)
.HasColumnType("character varying(30)");
b.Property<DateTime>("CreationDate")
.HasColumnType("timestamp with time zone");
b.Property<string>("EncryptedPayload")
.HasMaxLength(4000)
.HasColumnType("character varying(4000)");
b.Property<DateTime?>("ExpireAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Key")
.HasColumnType("text");
b.Property<string>("Name")
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.Property<DateTime>("RevisionDate")
.HasColumnType("timestamp with time zone");
b.Property<string>("Scope")
.HasMaxLength(4000)
.HasColumnType("character varying(4000)");
b.Property<Guid?>("ServiceAccountId")
.HasColumnType("uuid");
b.HasKey("Id")
.HasAnnotation("SqlServer:Clustered", true);
b.HasIndex("ServiceAccountId")
.HasAnnotation("SqlServer:Clustered", false);
b.ToTable("ApiKey", (string)null);
});
modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.AuthRequest", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uuid");
b.Property<string>("AccessCode")
.HasColumnType("text");
.HasMaxLength(25)
.HasColumnType("character varying(25)");
b.Property<bool?>("Approved")
.HasColumnType("boolean");
@ -50,7 +125,8 @@ namespace Bit.PostgresMigrations.Migrations
.HasColumnType("text");
b.Property<string>("RequestDeviceIdentifier")
.HasColumnType("text");
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<byte>("RequestDeviceType")
.HasColumnType("smallint");
@ -59,7 +135,8 @@ namespace Bit.PostgresMigrations.Migrations
.HasColumnType("text");
b.Property<string>("RequestIpAddress")
.HasColumnType("text");
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<DateTime?>("ResponseDate")
.HasColumnType("timestamp with time zone");
@ -190,7 +267,7 @@ namespace Bit.PostgresMigrations.Migrations
b.HasIndex("GroupId");
b.ToTable("CollectionGroups", (string)null);
b.ToTable("CollectionGroups");
});
modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.CollectionUser", b =>
@ -216,7 +293,7 @@ namespace Bit.PostgresMigrations.Migrations
b.HasIndex("UserId");
b.ToTable("CollectionUsers", (string)null);
b.ToTable("CollectionUsers");
});
modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Device", b =>
@ -648,6 +725,9 @@ namespace Bit.PostgresMigrations.Migrations
b.Property<bool>("UseScim")
.HasColumnType("boolean");
b.Property<bool>("UseSecretsManager")
.HasColumnType("boolean");
b.Property<bool>("UseSso")
.HasColumnType("boolean");
@ -836,6 +916,38 @@ namespace Bit.PostgresMigrations.Migrations
b.ToTable("Policy", (string)null);
});
modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Project", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uuid");
b.Property<DateTime>("CreationDate")
.HasColumnType("timestamp with time zone");
b.Property<DateTime?>("DeletedDate")
.HasColumnType("timestamp with time zone");
b.Property<string>("Name")
.HasColumnType("text");
b.Property<Guid>("OrganizationId")
.HasColumnType("uuid");
b.Property<DateTime>("RevisionDate")
.HasColumnType("timestamp with time zone");
b.HasKey("Id")
.HasAnnotation("SqlServer:Clustered", true);
b.HasIndex("DeletedDate")
.HasAnnotation("SqlServer:Clustered", false);
b.HasIndex("OrganizationId")
.HasAnnotation("SqlServer:Clustered", false);
b.ToTable("Project", (string)null);
});
modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Provider", b =>
{
b.Property<Guid>("Id")
@ -958,6 +1070,44 @@ namespace Bit.PostgresMigrations.Migrations
b.ToTable("ProviderUser", (string)null);
});
modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Secret", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uuid");
b.Property<DateTime>("CreationDate")
.HasColumnType("timestamp with time zone");
b.Property<DateTime?>("DeletedDate")
.HasColumnType("timestamp with time zone");
b.Property<string>("Key")
.HasColumnType("text");
b.Property<string>("Note")
.HasColumnType("text");
b.Property<Guid>("OrganizationId")
.HasColumnType("uuid");
b.Property<DateTime>("RevisionDate")
.HasColumnType("timestamp with time zone");
b.Property<string>("Value")
.HasColumnType("text");
b.HasKey("Id")
.HasAnnotation("SqlServer:Clustered", true);
b.HasIndex("DeletedDate")
.HasAnnotation("SqlServer:Clustered", false);
b.HasIndex("OrganizationId")
.HasAnnotation("SqlServer:Clustered", false);
b.ToTable("Secret", (string)null);
});
modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Send", b =>
{
b.Property<Guid>("Id")
@ -1015,6 +1165,32 @@ namespace Bit.PostgresMigrations.Migrations
b.ToTable("Send", (string)null);
});
modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.ServiceAccount", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uuid");
b.Property<DateTime>("CreationDate")
.HasColumnType("timestamp with time zone");
b.Property<string>("Name")
.HasColumnType("text");
b.Property<Guid>("OrganizationId")
.HasColumnType("uuid");
b.Property<DateTime>("RevisionDate")
.HasColumnType("timestamp with time zone");
b.HasKey("Id")
.HasAnnotation("SqlServer:Clustered", true);
b.HasIndex("OrganizationId")
.HasAnnotation("SqlServer:Clustered", false);
b.ToTable("ServiceAccount", (string)null);
});
modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.SsoConfig", b =>
{
b.Property<long>("Id")
@ -1288,6 +1464,134 @@ namespace Bit.PostgresMigrations.Migrations
b.ToTable("User", (string)null);
});
modelBuilder.Entity("ProjectSecret", b =>
{
b.Property<Guid>("ProjectsId")
.HasColumnType("uuid");
b.Property<Guid>("SecretsId")
.HasColumnType("uuid");
b.HasKey("ProjectsId", "SecretsId");
b.HasIndex("SecretsId");
b.ToTable("ProjectSecret");
});
modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.GroupProjectAccessPolicy", b =>
{
b.HasBaseType("Bit.Infrastructure.EntityFramework.Models.AccessPolicy");
b.Property<Guid?>("GrantedProjectId")
.ValueGeneratedOnUpdateSometimes()
.HasColumnType("uuid")
.HasColumnName("GrantedProjectId");
b.Property<Guid?>("GroupId")
.ValueGeneratedOnUpdateSometimes()
.HasColumnType("uuid")
.HasColumnName("GroupId");
b.HasIndex("GrantedProjectId");
b.HasIndex("GroupId");
b.HasDiscriminator().HasValue("group_project");
});
modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.GroupServiceAccountAccessPolicy", b =>
{
b.HasBaseType("Bit.Infrastructure.EntityFramework.Models.AccessPolicy");
b.Property<Guid?>("GrantedServiceAccountId")
.ValueGeneratedOnUpdateSometimes()
.HasColumnType("uuid")
.HasColumnName("GrantedServiceAccountId");
b.Property<Guid?>("GroupId")
.ValueGeneratedOnUpdateSometimes()
.HasColumnType("uuid")
.HasColumnName("GroupId");
b.HasIndex("GrantedServiceAccountId");
b.HasIndex("GroupId");
b.HasDiscriminator().HasValue("group_service_account");
});
modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.ServiceAccountProjectAccessPolicy", b =>
{
b.HasBaseType("Bit.Infrastructure.EntityFramework.Models.AccessPolicy");
b.Property<Guid?>("GrantedProjectId")
.ValueGeneratedOnUpdateSometimes()
.HasColumnType("uuid")
.HasColumnName("GrantedProjectId");
b.Property<Guid?>("ServiceAccountId")
.HasColumnType("uuid")
.HasColumnName("ServiceAccountId");
b.HasIndex("GrantedProjectId");
b.HasIndex("ServiceAccountId");
b.HasDiscriminator().HasValue("service_account_project");
});
modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.UserProjectAccessPolicy", b =>
{
b.HasBaseType("Bit.Infrastructure.EntityFramework.Models.AccessPolicy");
b.Property<Guid?>("GrantedProjectId")
.ValueGeneratedOnUpdateSometimes()
.HasColumnType("uuid")
.HasColumnName("GrantedProjectId");
b.Property<Guid?>("OrganizationUserId")
.ValueGeneratedOnUpdateSometimes()
.HasColumnType("uuid")
.HasColumnName("OrganizationUserId");
b.HasIndex("GrantedProjectId");
b.HasIndex("OrganizationUserId");
b.HasDiscriminator().HasValue("user_project");
});
modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.UserServiceAccountAccessPolicy", b =>
{
b.HasBaseType("Bit.Infrastructure.EntityFramework.Models.AccessPolicy");
b.Property<Guid?>("GrantedServiceAccountId")
.ValueGeneratedOnUpdateSometimes()
.HasColumnType("uuid")
.HasColumnName("GrantedServiceAccountId");
b.Property<Guid?>("OrganizationUserId")
.ValueGeneratedOnUpdateSometimes()
.HasColumnType("uuid")
.HasColumnName("OrganizationUserId");
b.HasIndex("GrantedServiceAccountId");
b.HasIndex("OrganizationUserId");
b.HasDiscriminator().HasValue("user_service_account");
});
modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.ApiKey", b =>
{
b.HasOne("Bit.Infrastructure.EntityFramework.Models.ServiceAccount", "ServiceAccount")
.WithMany()
.HasForeignKey("ServiceAccountId");
b.Navigation("ServiceAccount");
});
modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.AuthRequest", b =>
{
b.HasOne("Bit.Infrastructure.EntityFramework.Models.Device", "ResponseDevice")
@ -1530,6 +1834,17 @@ namespace Bit.PostgresMigrations.Migrations
b.Navigation("Organization");
});
modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Project", b =>
{
b.HasOne("Bit.Infrastructure.EntityFramework.Models.Organization", "Organization")
.WithMany()
.HasForeignKey("OrganizationId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Organization");
});
modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.ProviderOrganization", b =>
{
b.HasOne("Bit.Infrastructure.EntityFramework.Models.Organization", "Organization")
@ -1566,6 +1881,17 @@ namespace Bit.PostgresMigrations.Migrations
b.Navigation("User");
});
modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Secret", b =>
{
b.HasOne("Bit.Infrastructure.EntityFramework.Models.Organization", "Organization")
.WithMany()
.HasForeignKey("OrganizationId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Organization");
});
modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Send", b =>
{
b.HasOne("Bit.Infrastructure.EntityFramework.Models.Organization", "Organization")
@ -1581,6 +1907,17 @@ namespace Bit.PostgresMigrations.Migrations
b.Navigation("User");
});
modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.ServiceAccount", b =>
{
b.HasOne("Bit.Infrastructure.EntityFramework.Models.Organization", "Organization")
.WithMany()
.HasForeignKey("OrganizationId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Organization");
});
modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.SsoConfig", b =>
{
b.HasOne("Bit.Infrastructure.EntityFramework.Models.Organization", "Organization")
@ -1624,6 +1961,96 @@ namespace Bit.PostgresMigrations.Migrations
b.Navigation("User");
});
modelBuilder.Entity("ProjectSecret", b =>
{
b.HasOne("Bit.Infrastructure.EntityFramework.Models.Project", null)
.WithMany()
.HasForeignKey("ProjectsId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Bit.Infrastructure.EntityFramework.Models.Secret", null)
.WithMany()
.HasForeignKey("SecretsId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.GroupProjectAccessPolicy", b =>
{
b.HasOne("Bit.Infrastructure.EntityFramework.Models.Project", "GrantedProject")
.WithMany("GroupAccessPolicies")
.HasForeignKey("GrantedProjectId");
b.HasOne("Bit.Infrastructure.EntityFramework.Models.Group", "Group")
.WithMany()
.HasForeignKey("GroupId");
b.Navigation("GrantedProject");
b.Navigation("Group");
});
modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.GroupServiceAccountAccessPolicy", b =>
{
b.HasOne("Bit.Infrastructure.EntityFramework.Models.ServiceAccount", "GrantedServiceAccount")
.WithMany()
.HasForeignKey("GrantedServiceAccountId");
b.HasOne("Bit.Infrastructure.EntityFramework.Models.Group", "Group")
.WithMany()
.HasForeignKey("GroupId");
b.Navigation("GrantedServiceAccount");
b.Navigation("Group");
});
modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.ServiceAccountProjectAccessPolicy", b =>
{
b.HasOne("Bit.Infrastructure.EntityFramework.Models.Project", "GrantedProject")
.WithMany("ServiceAccountAccessPolicies")
.HasForeignKey("GrantedProjectId");
b.HasOne("Bit.Infrastructure.EntityFramework.Models.ServiceAccount", "ServiceAccount")
.WithMany()
.HasForeignKey("ServiceAccountId");
b.Navigation("GrantedProject");
b.Navigation("ServiceAccount");
});
modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.UserProjectAccessPolicy", b =>
{
b.HasOne("Bit.Infrastructure.EntityFramework.Models.Project", "GrantedProject")
.WithMany("UserAccessPolicies")
.HasForeignKey("GrantedProjectId");
b.HasOne("Bit.Infrastructure.EntityFramework.Models.OrganizationUser", "OrganizationUser")
.WithMany()
.HasForeignKey("OrganizationUserId");
b.Navigation("GrantedProject");
b.Navigation("OrganizationUser");
});
modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.UserServiceAccountAccessPolicy", b =>
{
b.HasOne("Bit.Infrastructure.EntityFramework.Models.ServiceAccount", "GrantedServiceAccount")
.WithMany()
.HasForeignKey("GrantedServiceAccountId");
b.HasOne("Bit.Infrastructure.EntityFramework.Models.OrganizationUser", "OrganizationUser")
.WithMany()
.HasForeignKey("OrganizationUserId");
b.Navigation("GrantedServiceAccount");
b.Navigation("OrganizationUser");
});
modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Cipher", b =>
{
b.Navigation("CollectionCiphers");
@ -1669,6 +2096,15 @@ namespace Bit.PostgresMigrations.Migrations
b.Navigation("CollectionUsers");
});
modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Project", b =>
{
b.Navigation("GroupAccessPolicies");
b.Navigation("ServiceAccountAccessPolicies");
b.Navigation("UserAccessPolicies");
});
modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.User", b =>
{
b.Navigation("Ciphers");