{ "info": { "author": "P G Jones", "author_email": "philip.graham.jones@googlemail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Environment :: Web Environment", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.7", "Topic :: Internet :: WWW/HTTP :: Dynamic Content", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "Quart-CORS\n==========\n\n|Build Status| |pypi| |python| |license|\n\nQuart-CORS is an extension for `Quart\n`_ to enable and control `Cross\nOrigin Resource Sharing `_, CORS (also\nknown as access control).\n\nCORS is required to share resources in browsers due to the `Same\nOrigin Policy `_\nwhich prevents resources being used from a different origin. An origin\nin this case is defined as the scheme, host and port combined and a\nresource corresponds to a path.\n\nIn practice the Same Origin Policy means that a browser visiting\n``http://quart.com`` will prevent the response of ``GET\nhttp://api.com`` being read. It will also prevent requests such as\n``POST http://api.com``. Note that CORS applies to browser initiated\nrequests, non-browser clients such as ``requests`` are not subject to\nCORS restrictions.\n\nCORS allows a server to indicate to a browser that certain resources\ncan be used, contrary to the Same Origin Policy. It does so via\naccess-control headers that inform the browser how the resource can be\nused. For GET requests these headers are sent in the response. For\nnon-GET requests the browser must ask the server for the\naccess-control headers before sending the actual request, it does so\nvia a preflight OPTIONS request.\n\nThe Same Origin Policy does not apply to WebSockets, and hence there\nis no need for CORS. Instead the server alone is responsible for\ndeciding if the WebSocket is allowed and it should do so by inspecting\nthe WebSocket-request origin header.\n\nSimple (GET) requests should return CORS headers specifying the\norigins that are allowed to use the resource (response). This can be\nany origin, ``*`` (wildcard), or a list of specific origins. The\nresponse should also include a CORS header specifying whether\nresponse-credentials e.g. cookies can be used. Note that if credential\nsharing is allowed the allowed origins must be specific and not a\nwildcard.\n\nPreflight requests should return CORS headers specifying the origins\nallowed to use the resource, the methods and headers allowed to be\nsent in a request to the resource, whether response credentials can be\nused, and finally which response headers can be used.\n\nNote that certain actions are allowed in the Same Origin Policy such\nas embedding e.g. ```` and simple\nPOSTs. For the purposes of this readme though these complications are\nignored.\n\nThe CORS access control response headers are,\n\n================================ ===========================================================\nHeader name Meaning\n-------------------------------- -----------------------------------------------------------\nAccess-Control-Allow-Origin Origins that are allowed to use the resource.\nAccess-Control-Allow-Credentials Can credentials be shared.\nAccess-Control-Allow-Methods Methods that may be used in requests to the resource.\nAccess-Control-Allow-Headers Headers that may be sent in requests to the resource.\nAccess-Control-Expose-Headers Headers that may be read in the response from the resource.\nAccess-Control-Max-Age Maximum age to cache the CORS headers for the resource.\n================================ ===========================================================\n\nQuart-CORS uses the same naming (without the Access-Control prefix)\nfor it's arguments and settings when they relate to the same meaning.\n\nUsage\n-----\n\nTo add CORS access control headers to all of the routes in the\napplication, simply apply the ``cors`` function to the application, or\nto a specific blueprint,\n\n.. code-block:: python\n\n app = Quart(__name__)\n app = cors(app, **settings)\n\n blueprint = Blueprint(__name__)\n blueprint = cors(blueprint, **settings)\n\nalternatively if you wish to add CORS selectively by resource, apply\nthe ``route_cors`` function to a route, or the ``websocket_cors``\nfunction to a WebSocket,\n\n.. code-block:: python\n\n @app.route('/')\n @route_cors(**settings)\n async def handler():\n ...\n\n @app.websocket('/')\n @websocket_cors(allow_origin=...)\n async def handler():\n ...\n\nThe ``settings`` are these arguments,\n\n================= ===========================\nArgument type\n----------------- ---------------------------\nallow_origin Union[Set[str], str]\nallow_credentials bool\nallow_methods Union[Set[str], str]\nallow_headers Union[Set[str], str]\nexpose_headers Union[Set[str], str]\nmax_age Union[int, flot, timedelta]\n================= ===========================\n\nwhich correspond to the CORS headers noted above. Note that all\nsettings are optional and defaults can be specified in the application\nconfiguration,\n\n============================ ========\nConfiguration key type\n---------------------------- --------\nQUART_CORS_ALLOW_ORIGIN Set[str]\nQUART_CORS_ALLOW_CREDENTIALS bool\nQUART_CORS_ALLOW_METHODS Set[str]\nQUART_CORS_ALLOW_HEADERS Set[str]\nQUART_CORS_EXPOSE_HEADERS Set[str]\nQUART_CORS_MAX_AGE float\n============================ ========\n\nThe ``websocket_cors`` decorator only takes an ``allow_origin``\nargument which defines the origins that are allowed to use the\nWebSocket. A WebSocket request from a disallowed origin will be\nresponded to with a 400 response.\n\nSimple examples\n~~~~~~~~~~~~~~~\n\nTo allow an app to be used from any origin (not recommended as it is\ntoo permissive),\n\n.. code-block:: python\n\n app = Quart(__name__)\n app = cors(app, allow_origin=\"*\")\n\nTo allow a route or WebSocket to be used from another specific domain,\n``https://quart.com``,\n\n.. code-block:: python\n\n @app.route('/')\n @route_cors(allow_origin=\"https://quart.com\")\n async def handler():\n ...\n\n @app.websocket('/')\n @websocket_cors(allow_origin=\"https://quart.com\")\n async def handler():\n ...\n\nTo allow a JSON POST request to an API route, from ``https://quart.com``,\n\n.. code-block:: python\n\n @app.route('/', methods=[\"POST\"])\n @route_cors(\n allow_headers=[\"content-type\"],\n allow_methods=[\"POST\"],\n allow_origin=[\"https://quart.com\"],\n )\n async def handler():\n data = await request.get_json()\n ...\n\nContributing\n------------\n\nQuart-CORS is developed on `GitLab\n`_. You are very welcome to\nopen `issues `_ or\npropose `merge requests\n`_.\n\nTesting\n~~~~~~~\n\nThe best way to test Quart-CORS is with Tox,\n\n.. code-block:: console\n\n $ pip install tox\n $ tox\n\nthis will check the code style and run the tests.\n\nHelp\n----\n\nThis README is the best place to start, after that try opening an\n`issue `_.\n\n\n.. |Build Status| image:: https://gitlab.com/pgjones/quart-cors/badges/master/build.svg\n :target: https://gitlab.com/pgjones/quart-cors/commits/master\n\n.. |pypi| image:: https://img.shields.io/pypi/v/quart-cors.svg\n :target: https://pypi.python.org/pypi/Quart-CORS/\n\n.. |python| image:: https://img.shields.io/pypi/pyversions/quart-cors.svg\n :target: https://pypi.python.org/pypi/Quart-CORS/\n\n.. |license| image:: https://img.shields.io/badge/license-MIT-blue.svg\n :target: https://gitlab.com/pgjones/quart-cors/blob/master/LICENSE\n\n\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://gitlab.com/pgjones/quart-cors/", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "Quart-CORS", "package_url": "https://pypi.org/project/Quart-CORS/", "platform": "", "project_url": "https://pypi.org/project/Quart-CORS/", "project_urls": { "Homepage": "https://gitlab.com/pgjones/quart-cors/" }, "release_url": "https://pypi.org/project/Quart-CORS/0.2.0/", "requires_dist": [ "Quart (>=0.6.11)" ], "requires_python": ">=3.7.0", "summary": "A Quart extension to provide Cross Origin Resource Sharing, access control, support.", "version": "0.2.0" }, "last_serial": 5624162, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "d3b37d138b08a78ead4dacea0899ed56", "sha256": "e66ea9a371d58356277ef1661fdcc8c25e796b5a269c4493d59472a18aa8ba32" }, "downloads": -1, "filename": "Quart_CORS-0.1.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "d3b37d138b08a78ead4dacea0899ed56", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=3.6.1", "size": 5462, "upload_time": "2018-06-11T16:17:20", "url": "https://files.pythonhosted.org/packages/63/b0/334d44e57d76201b6d0c09e2c52adeb7a6987614dc71ffa81df794833b20/Quart_CORS-0.1.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "394278a546d28ec5a19136596b4ec4d1", "sha256": "8727d56c91c8056b605cfd63774c9953215d955604a2a59fa23d1187b3a8728f" }, "downloads": -1, "filename": "Quart-CORS-0.1.0.tar.gz", "has_sig": false, "md5_digest": "394278a546d28ec5a19136596b4ec4d1", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6.1", "size": 7792, "upload_time": "2018-06-11T16:17:21", "url": "https://files.pythonhosted.org/packages/f3/ab/e564a6271b7ee76be7672327dbbb78a6ba187c4497aa1d3f4d948c121228/Quart-CORS-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "cc5af656912b278f36ba40a9cb5bd9e3", "sha256": "29d6e42d0ccec6a5b9d1c5b2dcb80d5e93efac740fe6cf5ff1b891ef67a36928" }, "downloads": -1, "filename": "Quart_CORS-0.1.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "cc5af656912b278f36ba40a9cb5bd9e3", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=3.6.1", "size": 6303, "upload_time": "2018-12-09T15:23:25", "url": "https://files.pythonhosted.org/packages/43/cc/16fff1b566bb54722f098bd8ea51e896fddfe4f18d836ce08649719ee4ec/Quart_CORS-0.1.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "add279a0e480c97331a54796e119c864", "sha256": "605d4239ab89c216c87165653cbd5405f508e68674ef133a40176ce464ef52c7" }, "downloads": -1, "filename": "Quart-CORS-0.1.1.tar.gz", "has_sig": false, "md5_digest": "add279a0e480c97331a54796e119c864", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6.1", "size": 7994, "upload_time": "2018-12-09T15:23:26", "url": "https://files.pythonhosted.org/packages/bd/e2/a07b929f9e0096e25c3da69656e1c55b00b2c678e280fb3764d01e86044c/Quart-CORS-0.1.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "d4ee6c1470c0dae2b85b0cb9a8467882", "sha256": "b38e88224c7fc2bd116d30ee41f13fdc4d480a8873ea0f97adb4498dd94baf44" }, "downloads": -1, "filename": "Quart_CORS-0.1.2-py3-none-any.whl", "has_sig": false, "md5_digest": "d4ee6c1470c0dae2b85b0cb9a8467882", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6.1", "size": 6318, "upload_time": "2019-01-29T15:31:54", "url": "https://files.pythonhosted.org/packages/19/70/a58527754d9fcbfe98522e841886a85900790ca07e86a30126853e5344df/Quart_CORS-0.1.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "699be40b500914692ccecd7512ae374d", "sha256": "054a5c9dc5c6a44a11af20f803037f92515a8086f388fda0e9a7a9f6ee4f3b7b" }, "downloads": -1, "filename": "Quart-CORS-0.1.2.tar.gz", "has_sig": false, "md5_digest": "699be40b500914692ccecd7512ae374d", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6.1", "size": 7957, "upload_time": "2019-01-29T15:31:55", "url": "https://files.pythonhosted.org/packages/48/7c/a5c612766237e42fbedc0a4e74808db9d2346253c397ba98e09ceab430ff/Quart-CORS-0.1.2.tar.gz" } ], "0.1.3": [ { "comment_text": "", "digests": { "md5": "b1b514909e51620973324820a2f6bb9d", "sha256": "fb4766f9b3134e2f4d1c49c17d95d9a2b60965c0b53a06fbb798f92b0356e7d6" }, "downloads": -1, "filename": "Quart_CORS-0.1.3-py3-none-any.whl", "has_sig": false, "md5_digest": "b1b514909e51620973324820a2f6bb9d", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6.1", "size": 6334, "upload_time": "2019-04-22T12:56:21", "url": "https://files.pythonhosted.org/packages/6f/40/808bfec481d8123865e1f55cec48126c4d03999386787f7b64b52294448f/Quart_CORS-0.1.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "e25e8913918683e8a5b9388cbe8afcce", "sha256": "149604c950c7c839089c8ec4128df98e93130201c128a214630656d18fada42d" }, "downloads": -1, "filename": "Quart-CORS-0.1.3.tar.gz", "has_sig": false, "md5_digest": "e25e8913918683e8a5b9388cbe8afcce", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6.1", "size": 8311, "upload_time": "2019-04-22T12:56:22", "url": "https://files.pythonhosted.org/packages/97/dc/b6d04e7c444302e18554eb1986805975a8d0fee7fc486da39e0b73b7c36f/Quart-CORS-0.1.3.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "74c14c69f3164f7ebdaee46ae8187852", "sha256": "b45367f4b4b198bfb2884038a6ab14f7ea82fbb03ce7def7233dfd5d2a8220cd" }, "downloads": -1, "filename": "Quart_CORS-0.2.0-py3-none-any.whl", "has_sig": false, "md5_digest": "74c14c69f3164f7ebdaee46ae8187852", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.7.0", "size": 7547, "upload_time": "2019-08-02T13:11:30", "url": "https://files.pythonhosted.org/packages/3b/c5/7ad74cccd56c80bd0f6c1ea62ba637fba785a7d094a008e7a6c16356ce73/Quart_CORS-0.2.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "5fdefaf4dad409c47e1e98c76a65bf9e", "sha256": "3b9e7fee3b564249c9264677c45417f3cdba2531db3b3d2b2b863bde75a34297" }, "downloads": -1, "filename": "Quart-CORS-0.2.0.tar.gz", "has_sig": false, "md5_digest": "5fdefaf4dad409c47e1e98c76a65bf9e", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.7.0", "size": 9958, "upload_time": "2019-08-02T13:11:31", "url": "https://files.pythonhosted.org/packages/79/ca/159e76e531696625751b4df78eeadf98d8108b4beef5bf5c723803cd9ffa/Quart-CORS-0.2.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "74c14c69f3164f7ebdaee46ae8187852", "sha256": "b45367f4b4b198bfb2884038a6ab14f7ea82fbb03ce7def7233dfd5d2a8220cd" }, "downloads": -1, "filename": "Quart_CORS-0.2.0-py3-none-any.whl", "has_sig": false, "md5_digest": "74c14c69f3164f7ebdaee46ae8187852", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.7.0", "size": 7547, "upload_time": "2019-08-02T13:11:30", "url": "https://files.pythonhosted.org/packages/3b/c5/7ad74cccd56c80bd0f6c1ea62ba637fba785a7d094a008e7a6c16356ce73/Quart_CORS-0.2.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "5fdefaf4dad409c47e1e98c76a65bf9e", "sha256": "3b9e7fee3b564249c9264677c45417f3cdba2531db3b3d2b2b863bde75a34297" }, "downloads": -1, "filename": "Quart-CORS-0.2.0.tar.gz", "has_sig": false, "md5_digest": "5fdefaf4dad409c47e1e98c76a65bf9e", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.7.0", "size": 9958, "upload_time": "2019-08-02T13:11:31", "url": "https://files.pythonhosted.org/packages/79/ca/159e76e531696625751b4df78eeadf98d8108b4beef5bf5c723803cd9ffa/Quart-CORS-0.2.0.tar.gz" } ] }