Repository navigation
Drop unused Django contrib apps and middleware - #591
Merged
Merged
Conversation
The API does not use admin, auth, sessions, or messages. Clear DRF's default session authentication so requests do not import django.contrib.auth. Co-authored-by: Joseph Rhoads <jrhoads@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
Remove Django contrib apps and middleware that this API does not use, without changing token-authenticated JSON requests.
Approach
Edit
INSTALLED_APPSandMIDDLEWAREinrorapi/settings.pyonly, plus the DRF defaults those removals require. Dropadmin,auth,sessions, andmessages, and the session, CSRF, authentication, messages, andX-Frame-Optionsmiddleware. Keepcontenttypes,staticfiles, and the singleCommonMiddlewareentry. Set DRF authentication to an empty list andUNAUTHENTICATED_USER/UNAUTHENTICATED_TOKENtoNone, because the framework defaults importdjango.contrib.auth.Key Modifications
django.contrib.admin,auth,sessions, andmessagesfromINSTALLED_APPS.SessionMiddleware,CsrfViewMiddleware,AuthenticationMiddleware,MessageMiddleware, andXFrameOptionsMiddleware.DEFAULT_AUTHENTICATION_CLASSESto[]and the unauthenticated user and token toNone.Important Technical Details
OurTokenPermissionand theRoute-User/TOKENheaders. It does not use Django users or sessions.AnonRateThrottleon client registration still throttles requests with no authenticated user, which is every request under these DRF defaults.CommonMiddlewarestays.contenttypesandstaticfilesstay.X-Frame-Options. This API returns JSON and does not render browser pages.Types of changes
Test plan
tests_uniton this PRmanage.py checkandmakemigrations --checksucceedReviewer, please remember our guidelines: