Skip to content

tartpvule/custom-cors-control

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Custom CORS Control - Advanced user control for CORS

Introduction

This extension aims to provide a user with complete control over the CORS mechanisms.

Misconfiguring the rules WILL break the protections offered by the Same-Origin Policy.

Only requests with an Origin header and a matching rule are modified at all by this extension.

AMO: https://addons.mozilla.org/en-US/firefox/addon/custom-cors-control/

Configuration

Warning Read first: https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS, and https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_settings_attributes.

{
  "Type1": {
    "Origin1": {
      "Target1": {
        "Path1": {
      	  "ACRH": [""],
      	  "ACAO": "allow",
      	  "ACEH": [""],
      	  "ACAC": false,
      	  "ACAM": ["GET", "POST"],
      	  "ACAH": [""]
      	}
      }
    }
  }
}
  1. Request Type

    One of the request types as documented at https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/webRequest/ResourceType.

    * matches everything, but only if no exact matches.

  2. Origin

    Evaluated one-by-one against the origin in details.originUrl with String#endsWith, but * matches everything.

  3. Target origin

    Evaluated one-by-one against the origin in details.targetUrl with String#endsWith, but * matches everything.

  4. Path

    Evaluated one-by-one against the path in details.targetUrl with String#startsWith, but * matches everything.

  • ACRH

    Array of values allowed to be present in the Access-Control-Request-Headers header in preflight request.

    Headers not present in this array will be omitted from subsequent requests.

  • ACAO

    "allow": Set Access-Control-Allow-Origin: <origin> in responses.

    "star": Set Access-Contorl-Allow-Origin: * in responses.

    "block": Cancel all requests.

  • ACEH

    An array of values allowed to be present in the Access-Control-Expose-Headers header in responses.

  • ACAC

    Set Access-Control-Allow-Credentials header in responses to the specified boolean value.

    Omit Authorization and Cookie headers from actual requests.

  • ACAM

    Array of allowed request methods. The request is canceled if not matched.

    For preflight requests, this is matched against Access-Control-Request-Method.

    For actual requests, this is matched against details.method.

  • ACAH

    Array of values allowed to be present in the Access-Control-Allow-Headers header in preflight responses.

Default Rules

{
  "font": {
    "*": {
      "*": {
        "*": {
          "ACAO": "star",
          "ACAC": false,
          "ACAM": ["GET"]
      	}
      }
    }
  }
}

Acknowledgments

License

The MIT License (MIT)

Copyright (c) 2019-2020 tartpvule

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

Advanced user control for CORS in Firefox

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published