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:

Code
Client
   |
   v
Azure Front Door
   |
   v
ASP.NET Core API
   |
   +-- JWT Validation
   |
   +-- Authorization
   |
   +-- Business Logic
   |
   v
Database

Every 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:

Code
Client
   |
   v
Azure Front Door
   |
   +-- Edge Request Processing
   +-- JWT Validation
   |
   v
ASP.NET Core API
   |
   +-- Authorization
   +-- Business Logic
   |
   v
Database

The 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:

Code
Who is making this request?

Authorization answers:

Code
Is this identity allowed to perform this operation?

A JWT can contain claims such as:

JSON
{
  "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:

C#
[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:

SQL
Internet
   |
   v
Azure Front Door
   |
   +-- TLS
   +-- WAF
   +-- Request Filtering
   +-- Edge Authentication Checks
   |
   v
API
   |
   +-- JWT Validation
   +-- Authorization
   +-- Business Rules

Keeping 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:

Code
Client
   |
   v
Front Door
   |
   +-- Validate / Filter
   |
   v
Backend
   |
   +-- Validate Security Context
   +-- Authorize Request

The 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:

Code
Issuer
Audience
Signature
Expiration
Not Before
Required Claims
Algorithm

For example:

JSON
{
  "iss": "https://identity.example",
  "aud": "orders-api",
  "sub": "12345",
  "exp": 1900000000
}

The API may require:

Code
iss = expected identity provider
aud = orders-api
signature = valid
exp > current time

Do 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:

SQL
JWT
 |
 +-- Read Header
 |
 +-- Read Claims
 |
 +-- Verify Signature
 |
 +-- Validate Issuer
 |
 +-- Validate Audience
 |
 +-- Validate Lifetime
 |
 v
Accept / Reject

The signature prevents a client from simply changing:

JSON
"role": "user"

to:

JSON
"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:

VB.NET
Old Signing Key
      |
      v
New Signing Key
      |
      v
Tokens signed with new key

If 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:

Code
Authorization: Bearer eyJ...

The token should travel over HTTPS.

The backend should also avoid logging the complete authorization header.

For example, avoid:

C#
_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:

Code
Missing Authorization Header
        |
        v
Reject at Edge

Or:

Code
Invalid Authentication Context
        |
        v
Reject at Edge

The API can then handle more detailed authorization:

SQL
Valid Identity
     |
     v
API
     |
     +-- Is user allowed to read this resource?
     |
     +-- Does user own this order?
     |
     +-- Does user have required scope?

This creates a useful division of responsibility.

Avoid Putting Business Authorization at the Edge

Consider an API endpoint:

Code
GET /orders/12345

The edge may know that the user has a valid token.

It may not know whether the user is allowed to access order 12345.

The API can perform the business check:

C#
var order = await repository.GetAsync(orderId);

if (order.CustomerId != userId)
{
    return Forbid();
}

Moving this kind of authorization to the edge can create complicated rules and duplicate business logic.

Keep resource-level authorization close to the application that owns the data.

ASP.NET Core Should Still Validate JWTs

An ASP.NET Core API can configure JWT authentication using the standard authentication middleware.

A simplified configuration looks like:

C#
builder.Services
    .AddAuthentication("Bearer")
    .AddJwtBearer("Bearer", options =>
    {
        options.Authority =
            builder.Configuration["Jwt:Authority"];

        options.Audience =
            builder.Configuration["Jwt:Audience"];

        options.RequireHttpsMetadata = true;
    });

builder.Services.AddAuthorization();

Then:

C#
app.UseAuthentication();
app.UseAuthorization();

The controller or endpoint can use:

C#
[Authorize]

or a more specific policy:

C#
[Authorize(Policy = "Orders.Read")]

The edge and API layers therefore have different responsibilities.

Example Architecture

A production architecture can look like this:

Code
                    Internet
                       |
                       v
                Azure Front Door
                       |
          +------------+------------+
          |                         |
         WAF                 Edge Request Checks
          |                         |
          +------------+------------+
                       |
                       v
                ASP.NET Core API
                       |
              JWT Authentication
                       |
                 Authorization
                       |
               Business Logic
                       |
                       v
                    Data

This arrangement allows the edge to reject unsuitable traffic while preserving application-level security controls.

Common Mistakes

Trusting a Header From the Client

Do not trust a client-provided header such as:

Code
X-User-Id: 12345

as proof of identity.

A client can send arbitrary headers.

Identity information should come from a validated authentication mechanism.

Removing Backend JWT Validation

Edge validation should not automatically become the only authentication layer.

Keep an appropriate trust boundary at the API.

Hard-Coding Signing Keys

Signing keys can rotate.

Use the identity provider's supported key-discovery mechanism rather than embedding a permanent key in application configuration.

Validating Only Token Expiration

A token can be unexpired and still be invalid for your API.

Validate issuer, audience, signature, lifetime, and required claims as appropriate.

Logging Bearer Tokens

Never log complete JWTs.

They should be treated as credentials.

Putting Resource Authorization at the Edge

The edge should not become a copy of your application's business authorization layer.

Keep resource ownership and business rules inside the API.

Best Practices

AreaRecommendation
TLSRequire HTTPS
TokenValidate cryptographic signature
IssuerValidate expected issuer
AudienceValidate expected API audience
LifetimeCheck token validity period
Signing keysSupport key rotation
BackendKeep an application security boundary
AuthorizationKeep business rules in the API
LoggingNever log complete bearer tokens
WAFUse it as an additional protection layer
MonitoringTrack authentication failures without exposing credentials

The most important design principle is separation of responsibility.

Front Door can help reduce unnecessary traffic and provide an additional security layer. The API remains responsible for application-specific authorization and should not blindly trust client-provided identity information.

Advantages

Using the edge for suitable authentication checks can provide several benefits:

  • Invalid traffic can be rejected earlier.
  • Backend resources can be protected from unnecessary requests.
  • Security controls can be centralized.
  • The API can focus more on application-specific authorization.
  • WAF and routing controls can work alongside authentication.
  • Authentication-related filtering can be applied consistently across multiple backends.

These benefits are most useful when the application receives significant external traffic.

Disadvantages

Edge authentication also introduces additional complexity.

JWT validation requires correct handling of signing keys, token lifetime, issuer, audience, and identity provider behavior.

Troubleshooting can also become harder because a request may be rejected before reaching the application.

There is another important trade-off: duplicating authentication logic at the edge and API can increase operational complexity.

For this reason, edge validation should be introduced for a clear purpose rather than simply because the platform supports it.

Troubleshooting

Requests Are Rejected Before Reaching the API

Check Front Door routing, WAF rules, edge processing rules, authentication configuration, and token requirements.

Application logs cannot help with a request that never reaches the application.

Valid Tokens Are Being Rejected

Check:

Code
Issuer
Audience
Expiration
Signing Key
Algorithm
Clock Differences

A mismatch in any of these values can cause validation failure.

Tokens Work Against the API Directly but Fail Through Front Door

Compare the request received by the API with the request sent directly to the backend.

Check whether the authorization header is being preserved and whether any intermediary is modifying the request.

Authentication Works Until Keys Rotate

Review signing-key discovery and caching behavior.

Do not assume that an identity provider uses one permanent signing key.

Authorization Fails After Authentication Succeeds

Check the API's authorization policies and claims.

A valid JWT does not automatically mean the user has permission to perform every operation.

Summary

JWT validation at the Azure Front Door edge can provide an additional security and traffic-filtering layer before requests reach an ASP.NET Core API.

A sensible architecture separates responsibilities:

SQL
Front Door
    |
    +-- WAF
    +-- Request Filtering
    +-- Suitable Authentication Checks
    |
    v
ASP.NET Core API
    |
    +-- JWT Validation
    +-- Authorization
    +-- Business Rules

The edge should handle coarse-grained protection, while the API should remain responsible for application-specific authorization.

The most important rule is not to turn edge validation into a replacement for backend security. Validate tokens correctly, support signing-key rotation, protect credentials, and keep resource-level authorization inside the application that owns the business logic.