Skip to content

Commit

Permalink
Ensure admin API always uses SessionAuthentication backend
Browse files Browse the repository at this point in the history
Fixes #5585 and (at least partly) #5628
  • Loading branch information
gasman committed Oct 22, 2019
1 parent 741c763 commit 53f5b1a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions wagtail/admin/api/endpoints.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from collections import OrderedDict

from rest_framework.authentication import SessionAuthentication

from wagtail.api.v2.endpoints import PagesAPIEndpoint
from wagtail.api.v2.filters import (
ChildOfFilter, DescendantOfFilter, FieldsFilter, ForExplorerFilter, OrderingFilter,
Expand All @@ -13,6 +15,7 @@

class PagesAdminAPIEndpoint(PagesAPIEndpoint):
base_serializer_class = AdminPageSerializer
authentication_classes = [SessionAuthentication]

# Use unrestricted child_of/descendant_of filters
# Add has_children filter
Expand Down
10 changes: 10 additions & 0 deletions wagtail/tests/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,3 +216,13 @@
'WIDGET': 'wagtail.tests.testapp.rich_text.CustomRichTextArea'
},
}


# Set a non-standard DEFAULT_AUTHENTICATION_CLASSES value, to verify that the
# admin API still works with session-based auth regardless of this setting
# (see https://github.com/wagtail/wagtail/issues/5585)
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': [
'rest_framework.authentication.BasicAuthentication',
]
}

0 comments on commit 53f5b1a

Please sign in to comment.