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

fastapi.security support #33

Closed
lukas-koschmieder opened this issue Dec 15, 2022 · 3 comments
Closed

fastapi.security support #33

lukas-koschmieder opened this issue Dec 15, 2022 · 3 comments
Assignees
Labels
documentation Improvements or additions to documentation question Further information is requested

Comments

@lukas-koschmieder
Copy link

lukas-koschmieder commented Dec 15, 2022

Following the FastAPI-SSO documentation, I have managed to configure a working SSO. I had to define a custom SSO provider but it still works perfectly. My current setup includes a login route (redirecting to my OAuth server) and callback route (returning some user information). Next, I would like to somehow integrate my custom SSOProvider into the FastAPI security mechanism. I'm not an expert on this topic but the driving idea seems to be that you inject your auth provider as dependencies into your FastAPI routers/apps (using fastapi.Depends). Does FastAPI-SSO support this mechanism as well?

@lukas-koschmieder lukas-koschmieder changed the title Applying FastAPI-SSO auth to (specific) routes fastapi.security support Dec 19, 2022
@tomasvotava
Copy link
Owner

Hi @lukas-koschmieder and thanks for your question. I am not ignoring it but I've been quite busy and fail to provide you with a full example.

The thing is fastapi-sso doesn't solve login for you, it only solves the part where you authenticate your user with a login provider. What you do next in your application is up to you. What I usually do is create a JWT (using python-jose) and return it in a cookie for the user. Then you can use ApiKeyCookie from fastapi.security as your dependency for protected endpoints which will add the lock icon into your Swagger documentation.

I'll try to come up with a code example ASAP, sorry for keeping you waiting.

@tomasvotava tomasvotava added the question Further information is requested label Jan 18, 2023
@tomasvotava tomasvotava self-assigned this Jan 18, 2023
@PySchilling
Copy link

@tomasvotava
Hi! Is there already a code example for the login you mentioned?

@tomasvotava tomasvotava added the documentation Improvements or additions to documentation label Oct 9, 2023
@tomasvotava
Copy link
Owner

With the exact speed of 19 characters per day I have finished writing this article. Sorry for taking this long.

https://tomasvotava.github.io/fastapi-sso/how-to-guides/use-with-fastapi-security/

Let me know if that's not sufficient and I'll gladly reopen this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants