> For the complete documentation index, see [llms.txt](https://waf-doc.inext.checkpoint.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://waf-doc.inext.checkpoint.com/additional-security-engines/api-protection/authentication-enforcement.md). Agents can also search and read this documentation through its [MCP server](https://waf-doc.inext.checkpoint.com/~gitbook/mcp).

# Authentication Enforcement

#### Overview

CloudGuard WAF’s Authentication Enforcement ensures that only authorized requests can access your protected web application. It validates incoming requests against the configured authentication type and can detect/block unauthenticated or improperly authenticated traffic.

### **How to set up** Authentication Enforcement

#### **Configuration Options**

<figure><img src="https://2760087783-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEWA4nfgNrSRL8dA6Kap7%2Fuploads%2FnmuJPdHbdp9vT0R3jcw4%2Fimage.png?alt=media&amp;token=c6588122-ce1b-475d-935c-0ee74e396cdd" alt=""><figcaption></figcaption></figure>

* **Authentication Type**\
  Currently, only **JWT (JSON Web Token)** is supported.
* **Existence Verification** \
  Ensures that an authentication token is present.
* **Authentication Expiration**\
  Validates that the token has not expired.

{% hint style="info" %}
A default tolerance period of 5 minutes is applied to the expiration time.
{% endhint %}

* **Signature Verification**\
  Verifies the JWT using the uploaded public key.

{% hint style="info" %}
Signature Verification supports the following **asymmetric algorithms**: RS256, RS512, ES256, ES385, ES512.
{% endhint %}

**Unauthenticated Endpoints**

By default, this protection applies to the entire asset.

* If you want to **exclude specific URIs**, you can define them here.

#### **Response Code for Unauthorized Access**

{% hint style="danger" %}
The default response status code is 403 when a request is blocked, which might cause unexpected behavior, the following section explains how to configure 401 response code to align with authentication best practices.
{% endhint %}

To return a `401 Unauthorized` response for blocked requests follow the steps bellow:

1. create a dedicated [Web User Response](https://waf-doc.inext.checkpoint.com/setup-instructions/setup-web-user-response-pages.md), with the following configurations:
   * Mode: `Response Code Only`&#x20;
   * HTTP Response Code: `401`

<div data-full-width="false"><figure><img src="https://2760087783-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEWA4nfgNrSRL8dA6Kap7%2Fuploads%2FGSfMMkcjeWhKurKoLVGI%2Fimage.png?alt=media&amp;token=3911f0c3-971a-4869-a20c-91167ad217d1" alt="" width="199"><figcaption></figcaption></figure></div>

2. Assign the Web User Response to the practice.

<figure><img src="https://2760087783-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEWA4nfgNrSRL8dA6Kap7%2Fuploads%2FJnGeFDbeGZqqYqtkRLDN%2Fimage.png?alt=media&amp;token=d6e10702-776a-47e3-a3b3-6b9ad0c839d0" alt="" width="375"><figcaption></figcaption></figure>

3. Enforce Policy.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://waf-doc.inext.checkpoint.com/additional-security-engines/api-protection/authentication-enforcement.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
