APIs often receive a large number of requests that can be rejected before they reach the application.
Authentication is one example.
If an API requires a valid JSON Web Token (JWT), the application may currently receive every request, validate the token, and only then decide whether the request should continue.
For applications behind Azure Front Door, moving suitable authentication checks closer to the edge can reduce unnecessary traffic to the backend and create a cleaner security boundary.
The important word is suitable. Edge validation should complement application-level authorization, not automatically replace it.
This article explains how JWT validation can be designed around Azure Front Door, where it fits, what should remain inside the API, and the common problems to avoid.
What Happens Without Edge Validation?
Consider a typical API architecture:
Client
|
v
Azure Front Door
|
v
ASP.NET Core API
|
+-- JWT Validation
|
+-- Authorization
|
+-- Business Logic
|
v
DatabaseEvery request reaches the application before authentication decisions are made.
For legitimate requests, this is expected.
For invalid or obviously unauthorized requests, the backend still has to spend resources receiving the request and processing the authentication middleware.
A more edge-oriented architecture looks like this:
Client
|
v
Azure Front Door
|
+-- Edge Request Processing
+-- JWT Validation
|
v
ASP.NET Core API
|
+-- Authorization
+-- Business Logic
|
v
DatabaseThe edge becomes an additional filtering layer.
JWT Authentication vs Authorization
Before moving JWT validation toward the edge, it is important to separate authentication from authorization.
Authentication answers:
Who is making this request?Authorization answers:
Is this identity allowed to perform this operation?A JWT can contain claims such as:
{
"sub": "12345",
"aud": "orders-api",
"scope": "orders.read",
"role": "admin"
}An edge layer may validate whether the token is structurally and cryptographically valid.
The API should still make business-specific authorization decisions.
For example:
[Authorize(Policy = "Orders.Read")]
[HttpGet("{id}")]
public async Task<IActionResult> GetOrder(int id)
{
...
}The API knows what Orders.Read means in the context of the application.
That knowledge generally should not be moved into a generic edge rule.
Where Azure Front Door Fits
Azure Front Door sits between clients and backend services.
It can provide capabilities such as:
- Global routing
- TLS termination
- Web Application Firewall
- Request routing
- Caching
- Edge request processing
The edge is therefore a useful place to perform checks that can safely happen before the request reaches the application.
A useful security model is:
Internet
|
v
Azure Front Door
|
+-- TLS
+-- WAF
+-- Request Filtering
+-- Edge Authentication Checks
|
v
API
|
+-- JWT Validation
+-- Authorization
+-- Business RulesKeeping security controls at multiple layers provides defense in depth.
Do Not Treat Edge Validation as the Only Authentication Layer
One of the biggest mistakes is assuming that a valid edge check means the backend no longer needs to validate the token.
That can create a serious security boundary problem.
The backend should not blindly trust authentication-related headers just because the request came through Front Door.
A safer architecture is:
Client
|
v
Front Door
|
+-- Validate / Filter
|
v
Backend
|
+-- Validate Security Context
+-- Authorize RequestThe exact implementation depends on the Front Door configuration and how identity information is propagated.
The principle is simple:
The backend should have its own security boundary.
Define the JWT Requirements
Before configuring edge validation, define exactly what makes a token acceptable.
Typical checks include:
Issuer
Audience
Signature
Expiration
Not Before
Required Claims
AlgorithmFor example:
{
"iss": "https://identity.example",
"aud": "orders-api",
"sub": "12345",
"exp": 1900000000
}The API may require:
iss = expected identity provider
aud = orders-api
signature = valid
exp > current timeDo not validate only whether the token contains a specific claim.
A token should be cryptographically verified.
Validate the Signature
JWT validation normally involves the identity provider's signing keys.
The basic flow is:
JWT
|
+-- Read Header
|
+-- Read Claims
|
+-- Verify Signature
|
+-- Validate Issuer
|
+-- Validate Audience
|
+-- Validate Lifetime
|
v
Accept / RejectThe signature prevents a client from simply changing:
"role": "user"to:
"role": "admin"and sending the modified token.
A production implementation should use the identity provider's published signing keys and handle key rotation correctly.
Key Rotation Matters
Identity providers can rotate signing keys.
For example:
Old Signing Key
|
v
New Signing Key
|
v
Tokens signed with new keyIf an edge validation system caches signing keys indefinitely, newly issued tokens can fail validation.
The validation layer therefore needs a reliable mechanism for obtaining current signing keys.
This is one reason authentication at the edge requires more operational planning than checking a static token value.
Protect the Token Path
JWTs are commonly sent through the Authorization header:
Authorization: Bearer eyJ...The token should travel over HTTPS.
The backend should also avoid logging the complete authorization header.
For example, avoid:
_logger.LogInformation(
"Authorization header: {Header}",
authorizationHeader);A bearer token is a credential. Logging it can turn an otherwise secure system into a credential exposure problem.
If diagnostics require request information, log safe identifiers instead.
Use Edge Rules for Coarse-Grained Decisions
The edge is most useful when the decision is simple and consistent.
For example:
Missing Authorization Header
|
v
Reject at EdgeOr:
Invalid Authentication Context
|
v
Reject at EdgeThe API can then handle more detailed authorization:
Join the conversation! Your thoughts help the community grow.