blob: 6ff28062109d0cb2e1d0aee14ec4a6b72c2ca403 [file] [log] [blame]
// Copyright 2017 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
module network.mojom;
import "mojo/public/mojom/base/unguessable_token.mojom";
import "services/network/public/mojom/ip_address_space.mojom";
// A policy to decide if CORS-preflight fetch should be performed.
enum CorsPreflightPolicy {
kConsiderPreflight,
kPreventPreflight,
};
// Error conditions of the CORS check.
// These values are used for UMA. Entries should not be renumbered. Please keep
// in sync with "CorsAccessCheckError" in
// src/tools/metrics/histograms/enums.xml.
enum CorsError {
// Access control
kDisallowedByMode,
// This value is only used in warnings reported to DevTools. It indicates that
// the preflight request failed due to a non-CORS net error (for example,
// `net::ERR_EMPTY_RESPONSE`).
kInvalidResponse,
// Not allowed wildcard origin was found in Access-Control-Allow-Origin
// response header when the credentials mode is 'include'.
kWildcardOriginNotAllowed,
// Access-Control-Allow-Origin response header was not found.
kMissingAllowOriginHeader,
// Not allowed multiple origin values was found in Access-Control-Allow-Origin
// response header.
kMultipleAllowOriginValues,
// Invalid origin was found in Access-Control-Allow-Origin response header.
kInvalidAllowOriginValue,
// Not allowed by Access-Control-Allow-Origin response header.
kAllowOriginMismatch,
// Invalid value was found in Access-Control-Allow-Credentials response
// header.
kInvalidAllowCredentials,
// The scheme is not for CORS.
kCorsDisabledScheme,
// Preflight:
// Failed to check HTTP response ok status in a CORS-preflight response.
kPreflightInvalidStatus,
// Redirect is requested in CORS-preflight response, but not allowed.
kPreflightDisallowedRedirect,
// Not allowed wildcard origin was found in Access-Control-Allow-Origin
// CORS-preflight response header when the credentials mode is 'include'.
kPreflightWildcardOriginNotAllowed,
// Access-Control-Allow-Origin response header was not found in a
// CORS-preflight response.
kPreflightMissingAllowOriginHeader,
// Not allowed multiple origin values was found in Access-Control-Allow-Origin
// CORS-preflight response header.
kPreflightMultipleAllowOriginValues,
// Invalid origin was found in Access-Control-Allow-Origin CORS-preflight
// response header.
kPreflightInvalidAllowOriginValue,
// Not allowed by Access-Control-Allow-Origin CORS-preflight response header.
kPreflightAllowOriginMismatch,
// Invalid value was found in Access-Control-Allow-Credentials CORS-preflight
// response header.
kPreflightInvalidAllowCredentials,
// Failed to parse Access-Control-Allow-Methods response header field in
// CORS-preflight response.
kInvalidAllowMethodsPreflightResponse,
// Failed to parse Access-Control-Allow-Headers response header field in
// CORS-preflight response.
kInvalidAllowHeadersPreflightResponse,
// Not allowed by Access-Control-Allow-Methods in CORS-preflight response.
kMethodDisallowedByPreflightResponse,
// Not allowed by Access-Control-Allow-Headers in CORS-preflight response.
kHeaderDisallowedByPreflightResponse,
// Cross origin redirect location contains credentials such as 'user:pass'.
kRedirectContainsCredentials,
// Request client is not secure and less private than the request target.
// See: https://wicg.github.io/private-network-access/#secure-context-restriction
kInsecurePrivateNetwork,
// The request carried a `target_ip_address_space` which turned out to
// be different from the IP address space of the remote endpoint.
// See: https://wicg.github.io/private-network-access/#request-target-ip-address-space
kInvalidPrivateNetworkAccess,
// User did not grant permission to access the local network.
// See: https://wicg.github.io/local-network-access/
kLocalNetworkAccessPermissionDenied,
};
// Contains additional details about a CORS-related error.
//
// Used to pass extra error details to `URLLoaderClient`s via
// `URLLoaderCompletionStatus`.
struct CorsErrorStatus {
// The error itself.
CorsError cors_error;
// Contains request method name, or header name that didn't pass a CORS check.
string failed_parameter;
// The address space of the requested resource.
// This defaults to kUnknown, and is overridden iff `cors_error` is one of:
//
// - `kInsecurePrivateNetwork`
// - `kInvalidPrivateNetworkAccess`
// - `kLocalNetworkAccessPermissionDenied`
IPAddressSpace resource_address_space = IPAddressSpace.kUnknown;
// The other IP address space set on the URL request.
// This defaults to kUnknown, and is overridden iff `cors_error` is
// `kInvalidPrivateNetworkAccess`, which happens in 2 situations:
//
// * The request had a `required_address_space` set but the
// `resource_address_space` did not match. In this case, this will be set
// to the `required_address_space`.
// or
//
// * The request connects to two different IP address spaces. See the
// comment in services/network/private_network_access_checker.cc.
// In this case, this will be set to the second IP address space.
//
// TODO(crbug.com/394636065): consider using 2 separate fields for the two
// separate situations listed above.
IPAddressSpace inconsistent_address_space = IPAddressSpace.kUnknown;
// True when there is an "authorization" header on the request and it is
// covered by the wildcard in the preflight response.
// TODO(crbug.com/40168475): Remove this once the investigation is done.
bool has_authorization_covered_by_wildcard_on_preflight = false;
mojo_base.mojom.UnguessableToken issue_id;
};