15 public const CONSTRUCTOR_OPTIONS = [
18 'RestAllowCrossOriginCookieAuth',
20 'CrossSiteAJAXdomains',
21 'CrossSiteAJAXdomainExceptions',
63 && !$this->user->isRegistered()
65 $origin = Origin::parseHeaderList( $request->
getHeader(
'Origin' ) );
68 return 'rest-cross-origin-anon-write';
80 $allowed = array_merge( [ $this->
getCanonicalDomain() ], $this->options->get(
'CrossSiteAJAXdomains' ) );
81 $excluded = $this->options->get(
'CrossSiteAJAXdomainExceptions' );
83 return $origin->
match( $allowed, $excluded );
92 ] =
wfParseUrl( $this->options->get(
'CanonicalServer' ) );
108 if ( !$this->options->get(
'AllowCrossOrigin' ) ) {
112 $allowedOrigin =
'*';
114 if ( $this->options->get(
'RestAllowCrossOriginCookieAuth' ) ) {
123 $response->
addHeader(
'Vary',
'Origin' );
126 if ( $request->hasHeader(
'Origin' ) ) {
127 $origin = Origin::parseHeaderList( $request->getHeader(
'Origin' ) );
128 if ( $this->allowOrigin( $origin ) ) {
132 if ( $request->getMethod() ===
'OPTIONS' || $this->user->isRegistered() ) {
147 if ( $allowedOrigin !==
'*' ) {
148 $response->setHeader(
'Access-Control-Allow-Credentials',
'true' );
151 $response->setHeader(
'Access-Control-Allow-Origin', $allowedOrigin );
163 $response = $this->responseFactory->createNoContent();
164 $response->
setHeader(
'Access-Control-Allow-Methods', $allowedMethods );
166 $allowedHeaders = $this->options->get(
'AllowedCorsHeaders' );
167 $allowedHeaders = array_merge( $allowedHeaders, array_diff( [
176 ], $allowedHeaders ) );
177 $response->setHeader(
'Access-Control-Allow-Headers', $allowedHeaders );
wfParseUrl( $url)
parse_url() work-alike, but non-broken.
if(ini_get('mbstring.func_overload')) if(!defined('MW_ENTRY_POINT'))
Pre-config setup: Before loading LocalSettings.php.