No slash, csrf exempt and ensure json serializer gets a dict, take two. - #4
Open
timnbraun wants to merge 8 commits into
Open
No slash, csrf exempt and ensure json serializer gets a dict, take two.#4timnbraun wants to merge 8 commits into
timnbraun wants to merge 8 commits into
Conversation
…a dict." There's a thinko in this. This reverts commit ba209d6.
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.
These changes allow me to use django_cap in my django based website. I'm not sure how it would have worked without them.
The slash redirect middleware in django didn't seem to retain the csrf token. If there's another way around this, let me know. Since the API is accessed by code on the same site, we can guard against cross-site contamination by setting the CAP_SITES_ENABLED appropriately.
The second commit turns off the CSRF token checking in the API views.
The third commit was needed since the Json response refused to accept the result dataclass as it didn't look like a dict. The one-line change forces the RedeemResult to become a dict() for serializing into a JsonResponse().
This fix may be a 'belt and suspenders' fix, but in my environment (vanilla django 6.0.4 startproject) all three commits were needed to avoid an error 400.
The previous pull request didn't include a version bump, and did have an error in the dict access of the dataclass in the redeem_challenge view.