Skip to content

Replace RavenDB Hub/Sink replication with ETL Sink task#3

Closed
Mateosssss wants to merge 19 commits into
mainfrom
etl-replication
Closed

Replace RavenDB Hub/Sink replication with ETL Sink task#3
Mateosssss wants to merge 19 commits into
mainfrom
etl-replication

Conversation

@Mateosssss

Copy link
Copy Markdown
Collaborator
  • Remove VerityReplicationHub and VerityReplicationSink (pull replication model)
  • Remove migration 005_ConfigureHubSink
  • Add VeritySinkEtlTask — push-based ETL via RavenDB ETL Sink
  • Add migration 005_ConfigureSinkEtl to register the ETL task
  • Minor whitespace cleanup in SecEdgarCompanyImporter

Vienias and others added 16 commits April 29, 2026 11:42
Update: RavenDB version
… audit trail

- Add Duende IdentityServer with RavenDB user store, FAPI 2.0 (PAR + DPoP),
  login/register/logout Razor pages, and RavenEventSink writing auth events
  to SecurityEvents collection in RavenDB
- Add Duende BFF proxying API calls and frontend through a single origin,
  handling token lifecycle transparently via session cookies
- Add AuthMiddleware (IFunctionsWorkerMiddleware) + JWT Bearer validation
  on Azure Functions backend; protect write endpoints with [Authorize]
- Add GET /api/security/events endpoint and /security frontend page
  showing auth events stored in RavenDB alongside financial data
- Add migration 006 seeding demo users (alice, bob, carol, dave, eve)
- Add IDENTITY.md documenting why IdentityServer, BFF pattern, and FAPI 2.0
  make sense for a financial audit platform
Resolves the 4 merge conflicts by keeping main's standalone "seeder"
worker (Setup project) as the migration runner and layering the
identity/auth feature on top.

- Program.cs (App): use simple AddRavenDBClient; drop in-app
  MigrationStartup/MigrationContext/AddRavenDbMigrations (now handled by
  the seeder). Keep JWT auth + AuthMiddleware.
- Api.cs (App): adopt main's Api(session, store, edgar) constructor and
  drop the POST /api/migrate endpoint (superseded by the seeder). Keep
  the GetSubjectFromBearer/DecodeJwtClaims helpers used by auth endpoints.
- AppHost.csproj: keep IdentityServer + Bff references; reference Setup as
  a normal Aspire resource (the seeder), not IsAspireProjectResource=false.
- Setup.csproj: keep both main's Exe/CommunityToolkit RavenDB client and
  the AspNetCore FrameworkReference needed by 006_SeedDemoUsers
  (PasswordHasher).

The seeder scans the Setup assembly, so 006_SeedDemoUsers runs
automatically alongside migrations 001-005.

echo "---"; git log --oneline -3; echo "---"; git status
- AuthMiddleware: enforce role claims from [Authorize(Roles=...)] attributes, return 403 on mismatch
- Program.cs: configure JWT with MapInboundClaims=false, RoleClaimType="role", JsonStringEnumConverter
- Api.cs: rename admin/* routes to manage/* (admin is reserved by Azure Functions host), filter null SubjectId in GetAllUsers
- VerityAgentApi.cs: fix GenerateAuditNotes — load user document as users/{userId} not {userId}
- BFF: Duende BFF with FAPI 2.0 / DPoP, role and company_id claims forwarded to frontend
- IdentityServer: FAPI 2.0 security profile, registration endpoint, role claim in tokens
- Frontend: admin panel (/admin route) for role and company assignment, role-gated UI on company/report pages, BFF auth integration
- Migration 006: seed demo users (alice=Admin, bob=Analyst, carol/dave=Viewer, eve=Analyst)
- Remove accidentally committed IdentityServer signing key, add keys/ to .gitignore
- Remove VerityReplicationHub and VerityReplicationSink (pull replication model)
- Remove migration 005_ConfigureHubSink
- Add VeritySinkEtlTask — push-based ETL via RavenDB ETL Sink
- Add migration 005_ConfigureSinkEtl to register the ETL task
- Minor whitespace cleanup in SecEdgarCompanyImporter
- Hub: WithFiltering = true
- Migration generates self-signed certificate for Sink at setup time
- Hub access registration limits Sink to Companies/* and Reports/*
- Sink authenticates with generated certificate (PFX)
Switch RavenDB from unsecured to TLS-secured mode, which is required
for WithFiltering = true on Hub Pull Replication (VerityReplicationHub).

AppHost:
- Generate self-signed server cert (3-month validity — Developer license
  rejects certs longer than 4 months) with Server + Client Auth EKUs
- Generate sink replication cert with Client Auth EKU (required by
  RavenDB client cert validation)
- Bind RavenDB on ravenHostPort inside the container (not 443) so that
  RAVEN_PublicServerUrl=localhost:9534 resolves both inside and outside
  the container, avoiding "DB created but not accessible" raft errors
- Override Aspire EndpointAnnotation.TargetPort to match the binding port
- Inject server cert path into all clients via Aspire__RavenDB__Client__CertificatePath

All clients (App, Setup, IdentityServer, DataSubscriptionsApp):
- Add RequestExecutor.RemoteCertificateValidationCallback to accept the
  self-signed cert (chain errors only; name validation still applies)

Migrations:
- Wrap Remote Attachments, Time Series, AI Agent, GenAI Tasks, Queue ETL
  in try-catch — these features are gated behind Enterprise license and
  were silently bypassed in unsecured mode but enforced in secured mode
- Pass server cert to sinkStore in 005_ConfigureHubSink for authenticated
  Sink database creation

BFF:
- Map /api/audit/stream and /api/report/stream before the catch-all
  without AsBffApiEndpoint() — EventSource cannot send X-CSRF headers

Frontend:
- Remove accidental import of Node.js inspector/promises in api.ts

Fix log statement in VerityAgentApi to use user.Id instead of body.UserId
@Scooletz

Copy link
Copy Markdown
Collaborator

Should be separate and small. Please recreate @Mateosssss

@Mateosssss

Copy link
Copy Markdown
Collaborator Author

Recreated as a focused, replication-only PR: #4 (based on identity, no unrelated identity/RBAC/BFF changes mixed in).

@Mateosssss Mateosssss deleted the etl-replication branch June 11, 2026 08:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants