feat: zero trust security architecture & database query caching strategy#1069
Open
JudeDaniel6 wants to merge 1 commit into
Open
feat: zero trust security architecture & database query caching strategy#1069JudeDaniel6 wants to merge 1 commit into
JudeDaniel6 wants to merge 1 commit into
Conversation
…aching strategy Resolves rinafcode#645 - Zero Trust Security Architecture: - Add ZeroTrustGuard: identity verification on every inbound request (Bearer JWT or HMAC service-to-service token); public paths (health, metrics, docs) are allow-listed. All decisions are written to the audit trail. - Add ServiceAuthService: HMAC-SHA256 service-to-service authentication with replay protection (5-min token window), timing-safe comparison, and an ENV-driven service registry (SERVICE_IDENTITIES). Tokens carry serviceId, timestamp, nonce, and signature. - Update SecurityModule to export ZeroTrustGuard, ServiceAuthService, and AuditLoggingService. EncryptionService (AES-256-GCM) covers encryption in transit and at rest. - Unit tests: 24 tests covering all guard paths and auth scenarios. Resolves rinafcode#511 - Database Query Caching Strategy: - Add QueryCacheService: standardised cache-aside helper for frequently executed DB queries (courses, user profiles, search results). Per-query-type TTLs from CACHE_TTL, standardised keys from cache-key.builder, event-driven invalidation via CacheInvalidationService. - Hit/miss counters exposed via getStats() for monitoring cache hit rates. - Update CachingModule to register and export QueryCacheService. - Unit tests: 16 tests covering hit/miss logic, TTL, bypass, invalidation, and hit-rate computation.
|
Hey @JudeDaniel6! 👋 It looks like this PR isn't linked to any issue. If this PR is for one of the issues assigned to you as part of a Wave, please link it to ensure your contribution is tracked properly. You can do this by adding a keyword to the PR description (e.g.,
|
Contributor
|
Well done on the job done so far! |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Resolves #645 — Zero Trust Security Architecture
Resolves #511 — Database Query Caching Strategy
Changes
Issue #645 — Zero Trust Security Architecture
src/security/zero-trust.guard.ts—ZeroTrustGuardsrc/security/service-auth.service.ts—ServiceAuthService<serviceId>.<timestamp>.<nonce>.<signature>— replay protection via 5-minute validity window and a per-token random nonce.timingSafeEqual) prevents timing attacks.SERVICE_IDENTITIESenv var (JSON array of{id, name, secret}).src/security/security.module.ts(updated)ZeroTrustGuard,ServiceAuthService, andAuditLoggingService.EncryptionService(AES-256-GCM, existing) covers encryption in transit and at rest.Acceptance criteria satisfied:
Issue #511 — Database Query Caching Strategy
src/caching/query-cache.service.ts—QueryCacheServicegetCourse,getCourseList,getUserProfile,getSearchResults.CACHE_TTLconstants (configurable per call viaQueryCacheOptions).cache-key.builder.ts.invalidateCourse,invalidateUser,invalidateSearch) delegate to the existing event-drivenCacheInvalidationService.getStats()exposes hit/miss counters and computed hit rate for monitoring.src/caching/caching.module.ts(updated)QueryCacheService.Acceptance criteria satisfied:
getStats()+CacheAnalyticsService)Tests
zero-trust.guard.spec.tsservice-auth.service.spec.tsquery-cache.service.spec.tsCI Verification
All three CI pipeline steps pass locally: