comparison docs/setup.rst @ 8886:3d7ba590f6f5

auth: only use X- headers instead of REMOTE_ADDR if explicitly told so in remote_addr_header Before, X-Forwarded-For (and others) headers would *always* be trusted blindly, also in setups without a proxy server. It would thus in some cases be possible for users to fake their IP, and thus potentially be possible to bypass IP restrictions configured in Kallithea. Fixed by making it configurable which WSGI environment variable to use for the remote address. Users can configure remote_addr_header to for example HTTP_X_FORWARDED_FOR instead of using the default REMOTE_ADDR. This change is a bit similar to what is going on in the https_fixup middleware, but is doing a bit more of what for example is happening in similar code in werkzeug/middleware/proxy_fix.py .
author Mads Kiilerich <mads@kiilerich.com>
date Sun, 09 May 2021 22:34:02 +0200
parents 883a0c6c425f
children 070b8c39736f
comparison
equal deleted inserted replaced
8885:f08fbf424898 8886:3d7ba590f6f5
421 client to the proxy server, the proxy server must be configured to 421 client to the proxy server, the proxy server must be configured to
422 somehow pass the original information on to Kallithea, and Kallithea must be 422 somehow pass the original information on to Kallithea, and Kallithea must be
423 configured to pick that information up and trust it. 423 configured to pick that information up and trust it.
424 424
425 Kallithea will by default rely on its WSGI server to provide the IP of the 425 Kallithea will by default rely on its WSGI server to provide the IP of the
426 client in the WSGI environment as ``REMOTE_ADDR``, but it can also 426 client in the WSGI environment as ``REMOTE_ADDR``, but it can be configured to
427 get it from the ``X-Real-IP`` or ``X-Forwarded-For`` HTTP headers. 427 get it from an HTTP header that has been set by the proxy server. For
428 example, if the proxy server puts the client IP in the ``X-Forwarded-For``
429 HTTP header, set::
430
431 remote_addr_variable = HTTP_X_FORWARDED_FOR
428 432
429 Kallithea will by default rely on finding the protocol (``http`` or ``https``) 433 Kallithea will by default rely on finding the protocol (``http`` or ``https``)
430 in the WSGI environment as ``wsgi.url_scheme``. If the proxy server puts 434 in the WSGI environment as ``wsgi.url_scheme``. If the proxy server puts
431 the protocol of the client request in the ``X-Url-Scheme``, 435 the protocol of the client request in the ``X-Url-Scheme``,
432 ``X-Forwarded-Scheme``, or ``X-Forwarded-Proto`` HTTP header, 436 ``X-Forwarded-Scheme``, or ``X-Forwarded-Proto`` HTTP header,