From f81795d7454d9b1eb88874014ffd70b26289f905 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cristi=20V=C3=AEjdea?= Date: Tue, 2 Jan 2018 16:14:00 +0100 Subject: [PATCH] Always vary cached schema on Cookie and Authorization This is needed to play nice with session auth on the schema view and with CurrentUserDefault. --- README.rst | 6 +++--- src/drf_yasg/views.py | 3 +-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/README.rst b/README.rst index d86e08c..636cba9 100644 --- a/README.rst +++ b/README.rst @@ -251,9 +251,9 @@ caching the schema view in-memory, with some sane defaults: * caching is enabled by the `cache_page `__ 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 -* if `public` is set to ``False`` on the SchemaView, the cached schema varies on the ``Cookie`` and ``Authorization`` - HTTP headers to enable filtering of visible endpoints according to the authentication credentials of each user; note - that this means that every user accessing the schema will have a separate schema cached in memory. +* the cached schema varies on the ``Cookie`` and ``Authorization`` HTTP headers to enable filtering of visible endpoints + according to the authentication credentials of each user; note that this means that every user accessing the schema + will have a separate schema cached in memory. 4. Validation ============= diff --git a/src/drf_yasg/views.py b/src/drf_yasg/views.py index b05a54a..d71290b 100644 --- a/src/drf_yasg/views.py +++ b/src/drf_yasg/views.py @@ -94,8 +94,7 @@ def get_schema_view(info=None, url=None, patterns=None, urlconf=None, public=Fal 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 = deferred_never_cache(view) # disable in-browser caching return view