phantom_token

The `phantom_token` directive enables token introspection for access tokens in NGINX, facilitating secure backend API calls with validated tokens.

Syntaxphantom_token on | off;
Defaultoff
Contexthttp, server, location
Argumentsflag

Description

The phantom_token directive is a configuration parameter within the Phantom Token NGINX Module that allows you to enable the introspection of OAuth access tokens presented in the Authorization header of incoming requests. When this directive is activated, it intercepts requests and verifies that they contain a valid access token. This is achieved by making a call to a configured introspection endpoint on the Curity Identity Server, following RFC 7662 standards. Upon successful introspection, the server receives a JSON Web Token (JWT) that is then used to replace the original access token in requests to backend APIs, thereby ensuring security and integrity in user data transactions.

To utilize this directive, you should specify it within the relevant contexts—http, server, or location. The directive requires a boolean flag as an argument, which indicates whether to enable or disable the introspection mechanism. It's important to configure the necessary subtleties of your NGINX configuration to define the introspection endpoint address, scope, and other needed parameters so that the module can function optimally. Misconfiguring any of these settings may lead to unauthorized requests or inefficient handling of tokens, potentially exposing your application to security vulnerabilities.

Config Example

server {
    listen 80;
    location /api/ {
        phantom_token on;
        # Additional configuration for the introspection endpoint
        proxy_pass http://backend_service;
    }
}

Ensure that the introspection endpoint is correctly configured; otherwise, token validation will fail.

Be cautious of network latency when calling the introspection endpoint, as it may affect request processing times.

Verify that the Authorization header is correctly set in requests to avoid unauthorized errors.

← Back to all directives