Skip to content
Myr

Provide a configuration option to control automatic option responses

Before adoption: this commit came in with the history the project adopted, so no landing records it.

By default Flask will provide responses to OPTIONS requests that are automatically generated. These responses list the valid methods in the response headers. Whilst this is useful, it can be frowned on by auditors hence an ability to disable it wholesale is useful.

authored by pgjones · committed by Phil Jones · parent 0ce2727 · Browse files · 4 files+14 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

4 files+14 added−2 removed

  • other:+14 added−2 removed

4 files+14 added−2 removed

modified:docs/config.rst+10 added
278 unmodified lines
279 Warn if cookie headers are larger than this many bytes. Defaults to280 ``4093``. Larger cookies may be silently ignored by browsers. Set to281 ``0`` to disable the warning.282283.. py:data:: PROVIDE_AUTOMATIC_OPTIONS284285 Set to ``False`` to disable the automatic addition of OPTIONS286 responses. This can be overridden per route by altering the287 ``provide_automatic_options`` attribute.288289.. versionadded:: 0.4290 ``LOGGER_NAME``291292.. versionadded:: 0.5
43 unmodified lines
336337.. versionchanged:: 2.3338 ``ENV`` was removed.339340.. versionadded:: 3.10341 Added :data:`PROVIDE_AUTOMATIC_OPTIONS` to control the default342 addition of autogenerated OPTIONS responses.343344345Configuring from Python Files346-----------------------------347348Configuration becomes more useful if you can store it in a separate file, ideally
383 unmodified lines
modified:src/flask/sansio/app.py+1 added-1 removed
636 unmodified lines
637 view_func, "provide_automatic_options", None638 )639640 if provide_automatic_options is None:641 if "OPTIONS" not in methods:641 if "OPTIONS" not in methods and self.config["PROVIDE_AUTOMATIC_OPTIONS"]:642 provide_automatic_options = True643 required_methods.add("OPTIONS")644 else:645 provide_automatic_options = False
319 unmodified lines
modified:src/flask/app.py+1 added
196 unmodified lines
197 "EXPLAIN_TEMPLATE_LOADING": False,198 "PREFERRED_URL_SCHEME": "http",199 "TEMPLATES_AUTO_RELOAD": None,200 "MAX_COOKIE_SIZE": 4093,201 "PROVIDE_AUTOMATIC_OPTIONS": True,202 }203 )204205 #: The class that is used for request objects. See :class:`~flask.Request`
1294 unmodified lines
modified:CHANGES.rst+2 added-1 removed
1Version 3.1.02-------------34Unreleased4- Provide a configuration option to control automatic option5 responses. :pr:`5496`678Version 3.0.39-------------
1563 unmodified lines