Skip to content

Add tenant isolation enforcement to Elasticsearch search queries in SearchService #889

Description

@RUKAYAT-CODER

Overview

src/search/search.service.ts builds Elasticsearch queries without consistently including a tenantId filter. In a multi-tenant deployment, a search for "javascript" could return courses from other tenants, leaking course titles, descriptions, and instructor information across tenant boundaries.

Specifications

Features:

  • Every Elasticsearch query in SearchService must include a term filter on tenantId.

Tasks:

  • Inject the current tenant context (TenancyService or request-scoped tenant ID) into SearchService.
  • Add a helper buildTenantFilter(tenantId) that returns an Elasticsearch term query.
  • Apply this filter as a must clause in every bool query.
  • Add integration tests with two tenants verifying search results are isolated.

Impacted Files:

  • src/search/search.service.ts

Acceptance Criteria

  • Search results for Tenant A never include content from Tenant B.
  • Integration test verifies isolation by populating both tenants and searching cross-boundary.
  • Filter is applied even when no other query parameters are present.

Metadata

Metadata

Labels

Stellar WaveIssues in the Stellar wave programbugSomething isn't workingsecurity

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions