linotp.middlewares.trusted_proxy_handler module

Middleware for Trusted Proxy Handling.

This module provides a middleware class, TrustedProxyHandler, designed to manage requests coming through trusted proxies. The middleware strips proxy information from incoming requests if the request originates from a trusted proxy. This ensures that the application processes requests with the correct client information, avoiding potential issues related to proxy-related headers.

Classes:
TrustedProxyHandler: Middleware that removes proxy information from requests

originating from trusted proxies.

Usage Example:

from trusted_proxy_handler import TrustedProxyHandler from some_wsgi_framework import your_app

# List of trusted proxies trusted_proxies = [“192.168.1.1”, “10.0.0.1”]

# Wrap your WSGI application with the middleware app = TrustedProxyHandler(your_app, trusted_proxies)

class linotp.middlewares.trusted_proxy_handler.TrustedProxyHandler(app, trusted_proxies: Union[list, set])

Bases: object

This middleware removes the proxy information from the request only if it matches the trusted proxies in the settings.