The GSM Gateway is the single entry point for all HTTP traffic in the GSM Application platform. Built on YARP (Yet Another Reverse Proxy) for .NET, it performs JWT validation at the network edge before any request reaches a microservice, and it is solely responsible for establishing the trustedDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/ti-infinite/GSMApplication/llms.txt
Use this file to discover all available pages before exploring further.
X-Company-Id tenant identity header. No data access layer exists in the gateway by design — adding persistence would violate YAGNI and couple the routing layer to business concerns without any architectural benefit.
Responsibilities
JWT Validation
Validates every
Authorization: Bearer token for signature, issuer, and audience. Invalid tokens are rejected with 401 Unauthorized before the request is forwarded.Tenant Header Injection
Strips any client-supplied
X-Company-Id and X-Profile-Id headers, then injects values derived directly from the validated JWT claims.Reverse Proxy Routing
Routes requests to
gsmAuthCluster, gsmApplicationCluster, or gsmOperationsCluster based on the URL prefix.Authorization Policies
Enforces the
AuthenticatedUser policy on application and operations routes, while security routes remain anonymous to support login and tenant resolution.Route Table
The gateway’s YARP route table is defined inappsettings.json under the ReverseProxy key. The table below summarizes every configured route:
| Gateway Path | Cluster | Auth Policy | Forwarded As |
|---|---|---|---|
/api/security/{**catch-all} | gsmAuthCluster | Anonymous | /api/{catch-all} |
/swagger/security/{**catch-all} | gsmAuthCluster | Anonymous | /swagger/{catch-all} |
/api/application/{**catch-all} | gsmApplicationCluster | AuthenticatedUser | /api/{catch-all} |
/swagger/application/{**catch-all} | gsmApplicationCluster | Anonymous | /swagger/{catch-all} |
/api/operations/{**catch-all} | gsmOperationsCluster | AuthenticatedUser | /api/{catch-all} |
/swagger/operations/{**catch-all} | gsmOperationsCluster | Anonymous | /swagger/{catch-all} |
/api or /swagger, keeping downstream service URLs uniform.
Swagger passthrough routes are intentionally anonymous so that developers can access each service’s interactive API documentation in development without requiring a valid token.
Cluster Addresses
Each cluster destination is configured with an address that the YARP engine forwards traffic to. In containerized deployments these values are supplied via environment variables rather than hardcoded in configuration:JWT Validation Settings
The gateway validates tokens produced byGSMAuth. The issuer and audience are configured in appsettings.json and should match the settings in the auth service exactly:
401 Unauthorized and never forwarded to downstream services.
Tenant Header Injection Middleware
TenantHeaderInjectionMiddleware runs after JWT validation and before YARP proxies the request. Its logic guarantees that the only X-Company-Id value a microservice ever sees comes from a verified JWT, not from the client:
Project Layer Structure
The gateway solution follows the same layered pattern as the microservices, minus a DataAccess layer:GSMGateway.Api
HTTP hosting, YARP registration, Swagger aggregation, and middleware pipeline configuration.
GSMGateway.Business
Application rules for resolving tenant identity from JWT claims.
GSMGateway.Abstractions
Interfaces and contracts for dependency inversion across layers.
GSMGateway.Entities
Constants, configuration option classes, and lightweight models.
GSMGateway.Tenant
TenantContext and TenantHeaderInjectionMiddleware.GSMGateway.Infrastructure
Reads and extracts claims from the
ClaimsPrincipal produced by JWT validation.Health Endpoint
Multi-Tenant Flow Summary
User authenticates
The client calls
POST /api/security/v1/auth/login through the gateway. The security route is anonymous, so YARP forwards the request directly to gsmAuthCluster without JWT validation.JWT is issued
GSMAuth validates credentials, builds a JWT containing sub, companyId, and idProfile claims, and returns it to the client.Client calls a protected route
The client attaches
Authorization: Bearer <token> to subsequent requests targeting /api/application/** or /api/operations/**.Gateway validates token and injects headers
The
AuthenticatedUser policy confirms the token is valid, then TenantHeaderInjectionMiddleware strips client headers and injects X-Company-Id and X-Profile-Id from the JWT claims.