tornadoweb / tornadoweb/tornado
web.authenticated: allow 403 without redirection
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 22.2k
- Forks
- 5.6k
- Avg merge
- 3h 42m
- Merged PRs (30d)
- 16
Description
The @web.authenticated decorator will always redirect with a 302 when the user is not logged in and the method is GET or HEAD. There is currently no way to return a 403 error for GET/HEAD requests using the decorator.
This is OK if the request comes form a web browser that expects HTML, but not if you are developing an API that's meant to be consumed using other methods.
Here's my proposal:
- Allow the
get_login_url()method to returnNone. Have the default implementation returnNonewhenlogin_urlis not set in the config instead of raising an exception. - Have
@web.authenticatedreturn a 403 whenget_login_url()returnsNoneinstead of redirecting.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the web.authenticated decorator and get_login_url implementation in the Tornado source, then inspect their existing authentication tests. Verify the behavior for GET and HEAD requests with and without a configured login URL; done means an unset URL produces a 403 while configured URLs retain the current redirect behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api, authentication, backend
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100