mattrobenolt / mattrobenolt/django-sudo

Support for AJAX requests?

Open
#6 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
279
Forks
25
PR merge metrics
No merged PRs in 30d

Description

I have a case where I would like to use sudo access for a REST API, but it doesn't appear that this will work nicely with this framework currently.

What I would propose is basically an addition to the sudo_required decorator:

if request.is_ajax():
    return HttpResponseForbidden(json.dumps({'message': 'Forbidden', 'sudo_required': True}), content_type='application/json')

There would also need to be a view which could receive an AJAX payload for authentication and return the appropriate cookie.

Is this something which would be in the scope of this project, or would it be more suited to something like a django-rest-framework-sudo package?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the sudo_required decorator and the view that handles sudo authentication. Review how request.is_ajax(), the proposed JSON 403 response, the AJAX payload, and the authentication cookie would fit together. The issue is done only after the project’s scope and the expected AJAX behavior are agreed.

Written by the indexing model from the issue text.

Assessment

Tech stack
django, python
Domain
api, authentication, backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.