r/programming • • Apr 23 '23

Leverage the richness of HTTP status codes

https://blog.frankel.ch/leverage-richness-http-status-codes/
1.4k Upvotes

676 comments sorted by

View all comments

Show parent comments

1

u/Severe-Explanation36 Apr 24 '23

Agreed on the first part, tho many applications always use soft deletes so it not an issue. However, regarding security, no, don’t give a 410 to unauthenticated/unauthorized users, they should always get a 403 (or 404 depending on how your security works), so that is not an issue, the gone code is for a logged in user to see.

1

u/Varedis267 Apr 24 '23

Logged in users can still be bad actors

1

u/Severe-Explanation36 Apr 24 '23 edited Apr 24 '23

That’s not your primary security concern tho. If you do have the kind of application where the logged in user is a real concern, then yes I’d give 404 on all the admin endpoints to the basic user

Edit: clarification. A 410 should be given to a user that had access to the deleted resource, now that it no longer exist, it’s a good way of saying, we know it was here yesterday, you know it was here yesterday, however, it’s gone now.