Manual:Hooks/IsTrustedProxy

IsTrustedProxy
Available from version 1.9.0
Allows an extension to set an IP as trusted or not.
Define function:
public static function onIsTrustedProxy( $ip, $trusted ) { ... }
Attach hook: In extension.json:
{
	"Hooks": {
		"IsTrustedProxy": "MediaWiki\\Extension\\MyExtension\\Hooks::onIsTrustedProxy"
	}
}
Called from: File(s): ProxyLookup.php
Interface: IsTrustedProxyHook.php

For more information about attaching hooks, see Manual:Hooks .
For examples of extensions using this hook, see Category:IsTrustedProxy extensions.

Details

edit
  • $ip - The IP address of the proxy.
  • $trusted - A bool indicating the IP is or isn't trusted.

Modifies the behavior of ProxyLookup::isTrustedProxy; this is more or less the dynamic equivalent of setting $wgCdnServers . It mainly means that when a request coming from this IP tells (via the X-Forwarded-For header) that the real source of the request is some other IP, MediaWiki will trust that claim.