Reputation: 1258
I wondering what best practices are with regards to deleting something in the database.
When a user wants to delete a ticket in my database, he clicks on a link that POSTs to the URL:
username/tickets/{ticket_id}
The POST contains nothing more session information and a CSRF token. As it stands right now, the id of the ticket that is actually deleted is captured from the url. Is this okay? It's typical to handle POSTs in Django using forms. Should I make a form for deleting tickets and then include the ticket_id in the POST body even though there is almost no input sanitation required? Is what I am doing now considered a hack?
Thank you Nick
Upvotes: 0
Views: 92
Reputation: 3435
HYour question goes beyond Django in particular and my guess is this is simply a matter of best practices and security on the web (regardless of framework or language used).
What you are doing is basically correct (and sane!), given that you take the below writing into consideration.
First, the handling of the data from the client to your server-side app:
POST
reachable URLs via session tokens (Is the user logged in or not? Are they known to your app?)POST
only (no GET
, PATCH
, ...).Then, regarding input sanitation. This can be dealt with on at least two levels:
If you have got all that setup, I think you have a solid base.
Upvotes: 1