Always vary cached schema on Cookie and Authorization
This is needed to play nice with session auth on the schema view and with CurrentUserDefault.openapi3
parent
caa397b906
commit
f81795d745
|
|
@ -251,9 +251,9 @@ caching the schema view in-memory, with some sane defaults:
|
||||||
* caching is enabled by the `cache_page <https://docs.djangoproject.com/en/1.11/topics/cache/#the-per-view-cache>`__
|
* caching is enabled by the `cache_page <https://docs.djangoproject.com/en/1.11/topics/cache/#the-per-view-cache>`__
|
||||||
decorator, using the default Django cache backend, can be changed using the ``cache_kwargs`` argument
|
decorator, using the default Django cache backend, can be changed using the ``cache_kwargs`` argument
|
||||||
* HTTP caching of the response is blocked to avoid confusing situations caused by being shown stale schemas
|
* HTTP caching of the response is blocked to avoid confusing situations caused by being shown stale schemas
|
||||||
* if `public` is set to ``False`` on the SchemaView, the cached schema varies on the ``Cookie`` and ``Authorization``
|
* the cached schema varies on the ``Cookie`` and ``Authorization`` HTTP headers to enable filtering of visible endpoints
|
||||||
HTTP headers to enable filtering of visible endpoints according to the authentication credentials of each user; note
|
according to the authentication credentials of each user; note that this means that every user accessing the schema
|
||||||
that this means that every user accessing the schema will have a separate schema cached in memory.
|
will have a separate schema cached in memory.
|
||||||
|
|
||||||
4. Validation
|
4. Validation
|
||||||
=============
|
=============
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,6 @@ def get_schema_view(info=None, url=None, patterns=None, urlconf=None, public=Fal
|
||||||
|
|
||||||
Arguments described in :meth:`.as_cached_view`.
|
Arguments described in :meth:`.as_cached_view`.
|
||||||
"""
|
"""
|
||||||
if not cls.public:
|
|
||||||
view = vary_on_headers('Cookie', 'Authorization')(view)
|
view = vary_on_headers('Cookie', 'Authorization')(view)
|
||||||
view = cache_page(cache_timeout, **cache_kwargs)(view)
|
view = cache_page(cache_timeout, **cache_kwargs)(view)
|
||||||
view = deferred_never_cache(view) # disable in-browser caching
|
view = deferred_never_cache(view) # disable in-browser caching
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue