-
Notifications
You must be signed in to change notification settings - Fork 1
Feature/FUND-2062 zrc bsn encrypt #172
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 15 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
221725e
FUND-2062 Added Encryption for ZRC BSN
ragaumon b4fbebe
FUND-2062 Removed unneeded Hashing
ragaumon 74ee9e3
FUND-2062 Created generic Hasher
ragaumon 8b789cd
FUND-2062 Made generic DataProtection
ragaumon d82ad7a
FUND-2062 Added MIgration for encryption
ragaumon 3d9563d
FUND-2062 Some clean up
ragaumon a040f0a
FUND-2062 Updated README file
ragaumon c32d64c
FUND-2062 Fixes EF MIgrations
ragaumon 6055df8
FUND-2062 Updated README.md
ragaumon bb8b7a6
FUND-2062 Added separated Connection for `DataProtectionKeyDbContext`
ragaumon 3e9893b
FUND-2062 Moved to separate project DataProtectionKeyDbContext. Moved…
ragaumon 4c4c774
FUND-2062 Added validation
ragaumon 5e625df
FUND-2062 Updated InpBsnBackfillService
ragaumon 4d4b1ec
FUND-2062 Updated InpBsnBackfillService and other comment fix
ragaumon 51a70d5
Merge remote-tracking branch 'origin/main' into feature/FUND-2062_zrc…
ragaumon 9c3c699
Updated Readme files
ragaumon 2facfab
Formating md
ragaumon 93e7f4b
Formating md
ragaumon f2e3ec2
Formating md
ragaumon 7805a37
Formating md
ragaumon 79b2f0a
Fixed BackfillService
ragaumon 3ecc802
Updated md files
ragaumon a1e9d27
Updated md files
ragaumon 9f03fe3
Merge remote-tracking branch 'origin/main' into feature/FUND-2062_zrc…
ragaumon b740b39
Reverted Zaken README.md
ragaumon 57b38b9
Fixed InpBsnBackfillService
ragaumon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
src/OneGround.ZGW.Common.DataProtection.DataModel/DataProtectionDbContextExtensions.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| using System; | ||
| using System.Threading.Tasks; | ||
| using Microsoft.AspNetCore.Builder; | ||
| using Microsoft.EntityFrameworkCore; | ||
| using Microsoft.Extensions.Configuration; | ||
| using Microsoft.Extensions.DependencyInjection; | ||
|
|
||
| namespace OneGround.ZGW.Common.DataProtection.DataModel; | ||
|
|
||
| public static class DataProtectionDbContextExtensions | ||
| { | ||
| public static IServiceCollection AddDataProtectionDbContext(this IServiceCollection services, IConfiguration configuration) | ||
| { | ||
| var connectionString = configuration.GetConnectionString("DataProtectionConnectionString"); | ||
| if (string.IsNullOrWhiteSpace(connectionString)) | ||
| throw new InvalidOperationException("No valid 'DataProtectionConnectionString' specified in ConnectionStrings."); | ||
|
|
||
| services.AddDbContext<DataProtectionKeyDbContext>(dbContextOptionsBuilder => | ||
| { | ||
| dbContextOptionsBuilder.UseNpgsql(connectionString, o => o.MigrationsHistoryTable("__EFMigrationsHistory", "data_protection")); | ||
| }); | ||
|
|
||
| return services; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Migrates the DataProtection database schema eagerly during startup. | ||
| /// Must be called before app.Run() to ensure the schema exists before ASP.NET DataProtection reads keys. | ||
| /// </summary> | ||
| public static async Task MigrateDataProtectionDatabaseAsync(this WebApplication app) | ||
| { | ||
| using var scope = app.Services.CreateScope(); | ||
| await scope.ServiceProvider.GetRequiredService<DataProtectionKeyDbContext>().Database.MigrateAsync(); | ||
| } | ||
| } |
17 changes: 17 additions & 0 deletions
17
src/OneGround.ZGW.Common.DataProtection.DataModel/DataProtectionKeyDbContext.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| using Microsoft.AspNetCore.DataProtection.EntityFrameworkCore; | ||
| using Microsoft.EntityFrameworkCore; | ||
|
|
||
| namespace OneGround.ZGW.Common.DataProtection.DataModel; | ||
|
|
||
| public class DataProtectionKeyDbContext : DbContext, IDataProtectionKeyContext | ||
| { | ||
| public DataProtectionKeyDbContext(DbContextOptions<DataProtectionKeyDbContext> options) | ||
| : base(options) { } | ||
|
|
||
| public DbSet<DataProtectionKey> DataProtectionKeys { get; set; } | ||
|
|
||
| protected override void OnModelCreating(ModelBuilder modelBuilder) | ||
| { | ||
| modelBuilder.HasDefaultSchema("data_protection"); | ||
| } | ||
| } |
21 changes: 21 additions & 0 deletions
21
src/OneGround.ZGW.Common.DataProtection.DataModel/DataProtectionKeyDbContextFactory.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| using Microsoft.EntityFrameworkCore; | ||
| using Microsoft.Extensions.Configuration; | ||
| using OneGround.ZGW.DataAccess; | ||
|
|
||
| namespace OneGround.ZGW.Common.DataProtection.DataModel; | ||
|
|
||
| public class DataProtectionKeyDbContextFactory : BaseDbContextFactory<DataProtectionKeyDbContext> | ||
| { | ||
| public DataProtectionKeyDbContextFactory(IConfiguration configuration) | ||
| : base(configuration, "DataProtectionConnectionString") { } | ||
|
|
||
| public DataProtectionKeyDbContextFactory() | ||
| : base("DataProtectionConnectionString") { } | ||
|
|
||
| public override DataProtectionKeyDbContext CreateDbContext(string[] args) | ||
| { | ||
| var optionsBuilder = new DbContextOptionsBuilder<DataProtectionKeyDbContext>(); | ||
| optionsBuilder.UseNpgsql(ConnectionString, o => o.MigrationsHistoryTable("__EFMigrationsHistory", "data_protection")); | ||
| return new DataProtectionKeyDbContext(optionsBuilder.Options); | ||
| } | ||
| } |
49 changes: 49 additions & 0 deletions
49
...ataProtection.DataModel/Migrations/20260401134941_create_data_protection_keys.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
40 changes: 40 additions & 0 deletions
40
....Common.DataProtection.DataModel/Migrations/20260401134941_create_data_protection_keys.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| using Microsoft.EntityFrameworkCore.Migrations; | ||
| using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; | ||
|
|
||
| #nullable disable | ||
|
|
||
| namespace OneGround.ZGW.Common.DataProtection.DataModel.Migrations | ||
| { | ||
| /// <inheritdoc /> | ||
| public partial class create_data_protection_keys : Migration | ||
| { | ||
| /// <inheritdoc /> | ||
| protected override void Up(MigrationBuilder migrationBuilder) | ||
| { | ||
| migrationBuilder.EnsureSchema(name: "data_protection"); | ||
|
|
||
| migrationBuilder.CreateTable( | ||
| name: "DataProtectionKeys", | ||
| schema: "data_protection", | ||
| columns: table => new | ||
| { | ||
| Id = table | ||
| .Column<int>(type: "integer", nullable: false) | ||
| .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), | ||
| FriendlyName = table.Column<string>(type: "text", nullable: true), | ||
| Xml = table.Column<string>(type: "text", nullable: true), | ||
| }, | ||
| constraints: table => | ||
| { | ||
| table.PrimaryKey("PK_DataProtectionKeys", x => x.Id); | ||
| } | ||
| ); | ||
| } | ||
|
|
||
| /// <inheritdoc /> | ||
| protected override void Down(MigrationBuilder migrationBuilder) | ||
| { | ||
| migrationBuilder.DropTable(name: "DataProtectionKeys", schema: "data_protection"); | ||
| } | ||
| } | ||
| } |
46 changes: 46 additions & 0 deletions
46
...ZGW.Common.DataProtection.DataModel/Migrations/DataProtectionKeyDbContextModelSnapshot.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| // <auto-generated /> | ||
| using Microsoft.EntityFrameworkCore; | ||
| using Microsoft.EntityFrameworkCore.Infrastructure; | ||
| using Microsoft.EntityFrameworkCore.Storage.ValueConversion; | ||
| using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; | ||
| using OneGround.ZGW.Common.DataProtection.DataModel; | ||
|
|
||
| #nullable disable | ||
|
|
||
| namespace OneGround.ZGW.Common.DataProtection.DataModel.Migrations | ||
| { | ||
| [DbContext(typeof(DataProtectionKeyDbContext))] | ||
| partial class DataProtectionKeyDbContextModelSnapshot : ModelSnapshot | ||
| { | ||
| protected override void BuildModel(ModelBuilder modelBuilder) | ||
| { | ||
| #pragma warning disable 612, 618 | ||
| modelBuilder | ||
| .HasDefaultSchema("data_protection") | ||
| .HasAnnotation("ProductVersion", "8.0.25") | ||
| .HasAnnotation("Relational:MaxIdentifierLength", 63); | ||
|
|
||
| NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); | ||
|
|
||
| modelBuilder.Entity("Microsoft.AspNetCore.DataProtection.EntityFrameworkCore.DataProtectionKey", b => | ||
| { | ||
| b.Property<int>("Id") | ||
| .ValueGeneratedOnAdd() | ||
| .HasColumnType("integer"); | ||
|
|
||
| NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); | ||
|
|
||
| b.Property<string>("FriendlyName") | ||
| .HasColumnType("text"); | ||
|
|
||
| b.Property<string>("Xml") | ||
| .HasColumnType("text"); | ||
|
|
||
| b.HasKey("Id"); | ||
|
|
||
| b.ToTable("DataProtectionKeys", "data_protection"); | ||
| }); | ||
| #pragma warning restore 612, 618 | ||
| } | ||
| } | ||
| } |
14 changes: 14 additions & 0 deletions
14
src/OneGround.ZGW.Common.DataProtection.DataModel/ZGW.Common.DataProtection.DataModel.csproj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
| <PropertyGroup> | ||
| <TargetFramework>net8.0</TargetFramework> | ||
| <AssemblyName>OneGround.ZGW.Common.DataProtection.DataModel</AssemblyName> | ||
| <RootNamespace>OneGround.ZGW.Common.DataProtection.DataModel</RootNamespace> | ||
| </PropertyGroup> | ||
| <ItemGroup> | ||
| <ProjectReference Include="..\OneGround.ZGW.DataAccess\ZGW.DataAccess.csproj" /> | ||
| </ItemGroup> | ||
| <ItemGroup> | ||
| <PackageReference Include="Microsoft.AspNetCore.DataProtection.EntityFrameworkCore" /> | ||
| <PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" /> | ||
| </ItemGroup> | ||
| </Project> |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.