From d94e45f3d6eb85333a433ef8d0155e740411740d Mon Sep 17 00:00:00 2001 From: Piotr Staroszczyk Date: Mon, 4 May 2020 12:13:45 +0200 Subject: [PATCH] Requires decorator redirects with 303 status_code instead of 307 #927 (#929) --- starlette/authentication.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/starlette/authentication.py b/starlette/authentication.py index 1fc6acae..db0b74fe 100644 --- a/starlette/authentication.py +++ b/starlette/authentication.py @@ -62,7 +62,9 @@ def requires( if not has_required_scope(request, scopes_list): if redirect is not None: - return RedirectResponse(url=request.url_for(redirect)) + return RedirectResponse( + url=request.url_for(redirect), status_code=303 + ) raise HTTPException(status_code=status_code) return await func(*args, **kwargs) @@ -77,7 +79,9 @@ def requires( if not has_required_scope(request, scopes_list): if redirect is not None: - return RedirectResponse(url=request.url_for(redirect)) + return RedirectResponse( + url=request.url_for(redirect), status_code=303 + ) raise HTTPException(status_code=status_code) return func(*args, **kwargs)