added pvc saving of Key
Some checks failed
Tests / Declarative: Post Actions No test results found
csharp-secdevops-pipeline-pod/pipeline/head There was a failure building this commit

This commit is contained in:
2026-06-11 08:05:59 +02:00
parent f096aa9b0a
commit 707e39e70a

View File

@@ -10,10 +10,22 @@ using Microsoft.AspNetCore.Components.Server;
using System.Security.Claims; using System.Security.Claims;
using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
// SECDEVOPS: Namespaces für Data Protection hinzufügen
using System.IO;
using Microsoft.AspNetCore.DataProtection;
// Initialisieren des Web Builders, der den Server und die Umgebung vorbereitet // Initialisieren des Web Builders, der den Server und die Umgebung vorbereitet
var builder = WebApplication.CreateBuilder(args); var builder = WebApplication.CreateBuilder(args);
// ==========================================
// SECDEVOPS: Data Protection für K8s PVC & Key-Rotation
// ==========================================
var keysFolder = new DirectoryInfo(@"/app/data/dp-keys");
builder.Services.AddDataProtection()
.PersistKeysToFileSystem(keysFolder)
.SetApplicationName("SecDevOpsLabApp"); // Bindet die Keys fix an diese App (Wichtig für Replicas)
// NEU: Blazor-Authentifizierungsdienste registrieren // NEU: Blazor-Authentifizierungsdienste registrieren
builder.Services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme) builder.Services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
.AddCookie(options => .AddCookie(options =>