Open main menu

Manual:Hooks/IsTrustedProxy

< Manual:Hooks
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": "MyExtensionHooks::onIsTrustedProxy"
	}
}

For MediaWiki ≤1.25:

$wgHooks['IsTrustedProxy'][] = 'MyExtensionHooks::onIsTrustedProxy';
Called from:File(s): ProxyTools.php

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

DetailsEdit

  • $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 $wgSquidServers. 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.