Skip to content

✨ Tenant Context Middleware #1508

@zacharykeeping

Description

@zacharykeeping

Hi Developers,

Pain

The API needs to determine which tenant is making each request and set the appropriate context for database queries and business logic.

Suggested Solution

Create ASP.NET Core middleware that extracts tenant from the request (header, subdomain, or auth claim) and sets the tenant context for the request pipeline.

Implementation:

  • Create middleware to extract tenant
  • Support multiple resolution strategies
  • Add tenant to logging scope
  • Handle invalid tenant gracefully

Tasks

  • Create ASP.NET Core middleware
  • Support multiple tenant resolution strategies (header, subdomain, auth claim)
  • Add tenant to logging scope
  • Handle missing/invalid tenant gracefully
  • Test all resolution strategies
  • Integrate with authentication
  • Return appropriate HTTP status for invalid tenant
  • Document tenant resolution strategy

Acceptance Criteria

More Information

Files to Create/Modify:

  • NEW: src/WebAPI/Middleware/TenantResolutionMiddleware.cs
  • MODIFY: src/WebAPI/Program.cs
  • Update authentication configuration

Dependencies: Previous PBI must be completed first

Epic: #1483

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    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