Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature] Add CookieToAuth2 middleware to convert cookies to Authorization header #11684

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

LainezDev
Copy link

@LainezDev LainezDev commented Jun 5, 2024

Allows developers to use cookies and authorization headers without changing authentication settings. OAuth2PasswordBearer is designed to look for the token in the authorization header of the request. The middleware that converts the token cookie into an Authorization header ensuring that when OAuth2PasswordBearer inspects the request, it finds the necessary header in the correct format. It is a simple proposal to several discussions about the use of cookies for authorization of web pages with FastAPI.

I'm looking forward to your feedback

from fastapi import FastAPI
from fastapi.middleware.cookietoauth2 import CookieToAuth2Middleware

app = FastAPI()

app.add_middleware(CookieToAuth2Middleware, cookie_name="cookie_name")

@alejsdev alejsdev added the feature New feature or request label Jun 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants