Manual:Hooks/ContentSecurityPolicyDirectives

From MediaWiki.org
Jump to navigation Jump to search
ContentSecurityPolicyDirectives
Available from version 1.32.0
Modify the content security policy directives.
Define function:
public static function onContentSecurityPolicyDirectives( array &$directives, array $policyConfig, int $mode ) { ... }
Attach hook:

In extension.json:

{
	"Hooks": {
		"ContentSecurityPolicyDirectives": "MyExtensionHooks::onContentSecurityPolicyDirectives"
	}
}

For MediaWiki ≤1.25:

$wgHooks['ContentSecurityPolicyDirectives'][] = 'MyExtensionHooks::onContentSecurityPolicyDirectives';
Called from:File(s): ContentSecurityPolicy.php

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

Use this only if ContentSecurityPolicyDefaultSource and ContentSecurityPolicyScriptSource do not meet your needs.

Details[edit]

  • &$directives: Array of Content-Security-Policy directives
  • $policyConfig: Current configuration for the Content-Security-Policy header
  • $mode: ContentSecurityPolicy::REPORT_ONLY_MODE or ContentSecurityPolicy::FULL_MODE depending on type of header