tornadoweb / tornadoweb/tornado

web.authenticated: allow 403 without redirection

Open
#1,099 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

web
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 return None. Have the default implementation return None when login_url is not set in the config instead of raising an exception.
  • Have @web.authenticated return a 403 when get_login_url() returns None instead of redirecting.

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 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.