<!-- review: finished -->

<a id="external-jwt"></a>

# JWT

The module enables validation of JSON Web Tokens (JWT) using specified keys.
It is **incompatible** with the [Auth JWT](https://en.angie.software//angie/docs/installation/external-modules/auth-jwt.md#external-auth-jwt) module.

<a id="installation-14"></a>

## Installation

To [install](https://en.angie.software//angie/docs/installation/index.md#install-packages) the module, use one of the
following packages:

- Angie: `angie-module-jwt`
- Angie PRO: `angie-pro-module-jwt`

<a id="loading-the-module-14"></a>

## Loading the Module

Enable the module in the `main{}` context:

```nginx
load_module modules/ngx_http_auth_jwt_module.so;
```

<a id="configuration-example-91"></a>

## Configuration Example

```nginx
http {
    server {
        auth_jwt_key "0123456789abcdef" hex;
        auth_jwt     off;

        # Authorization via the Authentication header
        location /secured-by-auth-header/ {
            auth_jwt on;
        }

        # Authorization via cookie
        location /secured-by-cookie/ {
            auth_jwt $cookie_MyCookieName;
        }

        # Key inheritance and override
        location /secured-by-auth-header-too/ {
            auth_jwt_key "another-secret";
            auth_jwt on;
        }

        # Authorization via RSA key
        location /secured-by-rsa-key/ {
            auth_jwt_key /etc/keys/rsa-public.pem file;
            auth_jwt on;
        }

        location /not-secure/ {}
    }
}
```

<a id="additional-information-15"></a>

## Additional Information

For detailed documentation and source code, see:
[https://github.com/max-lt/nginx-jwt-module](https://github.com/max-lt/nginx-jwt-module)
