Skip to content

Document that authentication should not depend on the HTTP method - #10105

Merged
browniebroke merged 1 commit into
encode:mainfrom
jankesec:docs-authentication-http-method
Nov 12, 2026
Merged

browniebroke merged 1 commit into
encode:mainfrom
jankesec:docs-authentication-http-method

Conversation

@jankesec

Copy link
Copy Markdown
Contributor

Adds two short warnings to the docs.

In the "Custom authentication" section of the authentication guide: don't make the result of .authenticate() depend on the HTTP method, and put rules like that in a permission class. REST framework sometimes makes a copy of the request with a different method (browsable API, AdminRenderer, OPTIONS metadata). Permissions are checked again for the copy, but authentication is not, so the copy keeps the request.user and request.auth of the original request.

Under AdminRenderer in the renderers guide: the simulated GET it makes for a 400 Bad Request response keeps the request.user and request.auth of the original request, so method-dependent rules belong in permission classes.

Docs only, no code changes.

🤖 Generated with Claude Code

Add a warning to the "Custom authentication" section of the authentication
guide, and a short note under AdminRenderer in the renderers guide.

REST framework sometimes clones the current request with a different method,
for example in the browsable API, AdminRenderer and OPTIONS metadata.
Permissions are checked again for the clone, but authentication is not, so
the clone keeps the user and credentials of the original request. An
authenticator whose result depends on the HTTP method is therefore not
supported, and rules like that belong in permission classes.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@browniebroke
browniebroke merged commit f9c0ec5 into encode:main Nov 12, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants