diff --git a/README.md b/README.md index 5f86a59..767777e 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# FastAPI SSO +# Litestar SSO ![Supported Python Versions](https://img.shields.io/pypi/pyversions/litestar-sso) [![Test coverage](https://codecov.io/gh/tomasvotava/litestar-sso/graph/badge.svg?token=SIFCTVSSOS)](https://codecov.io/gh/tomasvotava/litestar-sso) @@ -11,7 +11,7 @@ ![Project License](https://img.shields.io/github/license/tomasvotava/litestar-sso) ![PyPi Version](https://img.shields.io/pypi/v/litestar-sso) -FastAPI plugin to enable SSO to most common providers (such as Facebook login, Google login and login via +Litestar plugin to enable SSO to most common providers (such as Facebook login, Google login and login via Microsoft Office 365 account). This allows you to implement the famous `Login with Google/Facebook/Microsoft` buttons functionality on your @@ -25,7 +25,7 @@ backend very easily. An awesome demo site was created and is maintained by even awesomer [Chris Karvouniaris (@chrisK824)](https://github.com/chrisK824). Chris has also posted multiple -Medium articles about FastAPI and FastAPI SSO. +Medium articles about Litestar and Litestar SSO. Be sure to see his tutorials, follow him and show him some appreciation! diff --git a/docs/how-to-guides/state-return-url.md b/docs/how-to-guides/state-return-url.md index 2d95235..05837cd 100644 --- a/docs/how-to-guides/state-return-url.md +++ b/docs/how-to-guides/state-return-url.md @@ -8,8 +8,8 @@ Example: ```python -from fastapi import Request -from fastapi.responses import RedirectResponse +from litestar import Request +from litestar.responses import RedirectResponse google_sso = GoogleSSO("client-id", "client-secret") diff --git a/docs/how-to-guides/use-with-fastapi-security.md b/docs/how-to-guides/use-with-fastapi-security.md index e95f40b..ad5bb2b 100644 --- a/docs/how-to-guides/use-with-fastapi-security.md +++ b/docs/how-to-guides/use-with-fastapi-security.md @@ -1,15 +1,15 @@ -# Using with fastapi's Security +# Using with litestar's Security Even though `litestar-sso` does not try to solve login and authentication, it is clear that you will probably mostly use it to protect your endpoints. This is why it is important to know how -to use it with fastapi's security. +to use it with litestar's security. You were asking how to put the lock 🔒 icon to your Swagger docs in [this issue](https://github.com/tomasvotava/litestar-sso/issues/33). This is how you do it. ## Requirements -- `fastapi` - obviously +- `litestar` - obviously - `litestar-sso` - duh - `python-jose[cryptography]` - to sign and verify our JWTs @@ -27,15 +27,15 @@ the token was not changed. This makes JWTs very helpful, because it's the thing that comes from the user that you can actually trust. In this example, we will save the JWT into a cookie so that the user sends it with every request. We will -also use fastapi's `Depends` to make sure that the user is authenticated before accessing the endpoint. +also use litestar's `Depends` to make sure that the user is authenticated before accessing the endpoint. ## Example ```python import datetime # to calculate expiration of the JWT -from fastapi import FastAPI, Depends, HTTPException, Security, Request -from fastapi.responses import RedirectResponse -from fastapi.security import APIKeyCookie # this is the part that puts the lock icon to the docs +from litestar import Litestar, Depends, HTTPException, Security, Request +from litestar.responses import RedirectResponse +from litestar.security import APIKeyCookie # this is the part that puts the lock icon to the docs from litestar_sso.sso.google import GoogleSSO # pip install litestar-sso from litestar_sso.sso.base import OpenID @@ -112,7 +112,7 @@ if __name__ == "__main__": Visit [`http://127.0.0.1:5000/docs/`](http://127.0.0.1:5000/docs/) -![Swagger docs with lock icon](./fastapi-security.png) +![Swagger docs with lock icon](./litestar-security.png) ### Accessing the `/protected` endpoint before login diff --git a/docs/tutorials.md b/docs/tutorials.md index a478a96..60cc5aa 100644 --- a/docs/tutorials.md +++ b/docs/tutorials.md @@ -13,7 +13,7 @@ Fill in the `Authorized redirect URIs` field with `http://localhost:3000/google/ Then, copy the `Client ID` and `Client secret` and paste them into the following code: ```python -from fastapi import FastAPI +from litestar import Litestar from starlette.requests import Request from litestar_sso.sso.google import GoogleSSO @@ -46,12 +46,12 @@ You should be redirected to Google login page. After successful login, you shoul ## Using SSO as a dependency -You may use SSO as a dependency in your FastAPI application. +You may use SSO as a dependency in your Litestar application. This is useful if you want to use the same SSO instance in multiple endpoints and make sure the state is cleared after the request is processed. You may even omit the `with` statement in this case. ```python -from fastapi import Depends, FastAPI, Request +from litestar import Depends, Litestar, Request from litestar_sso.sso.google import GoogleSSO app = Litestar() diff --git a/litestar_sso/__init__.py b/litestar_sso/__init__.py index 1bccf25..ae3fb29 100644 --- a/litestar_sso/__init__.py +++ b/litestar_sso/__init__.py @@ -1,4 +1,4 @@ -"""FastAPI plugin to enable SSO to most common providers. +"""Litestar plugin to enable SSO to most common providers. (such as Facebook login, Google login and login via Microsoft Office 365 account) """ diff --git a/litestar_sso/sso/base.py b/litestar_sso/sso/base.py index 9552465..9ef82b0 100644 --- a/litestar_sso/sso/base.py +++ b/litestar_sso/sso/base.py @@ -79,7 +79,7 @@ def wrapper(*args: P.args, **kwargs: P.kwargs) -> T: if not args[0]._in_stack: warnings.warn( "Please make sure you are using SSO provider in an async context (using 'async with provider:'). " - "See https://github.com/tomasvotava/fastapi-sso/issues/186 for more information.", + "See https://github.com/tomasvotava/litestar-sso/issues/186 for more information.", category=SecurityWarning, stacklevel=1, ) @@ -357,10 +357,10 @@ async def verify_and_process( redirect_uri: Optional[str] = None, convert_response: Union[Literal[True], Literal[False]] = True, ) -> Union[Optional[OpenID], Optional[Dict[str, Any]]]: - """Processes the login given a FastAPI (Starlette) Request object. This should be used for the /callback path. + """Processes the login given a Litestar (Starlette) Request object. This should be used for the /callback path. Args: - request (Request): FastAPI or Starlette request object. + request (Request): Litestar or Starlette request object. params (Optional[Dict[str, Any]]): Additional query parameters to pass to the provider. headers (Optional[Dict[str, Any]]): Additional headers to pass to the provider. redirect_uri (Optional[str]): Overrides the `redirect_uri` specified on this instance. @@ -404,7 +404,7 @@ async def verify_and_process( def __enter__(self) -> "SSOBase": warnings.warn( "SSO Providers are supposed to be used in async context, please change 'with provider' to " - "'async with provider'. See https://github.com/tomasvotava/fastapi-sso/issues/186 for more information.", + "'async with provider'. See https://github.com/tomasvotava/litestar-sso/issues/186 for more information.", DeprecationWarning, stacklevel=1, ) @@ -495,7 +495,7 @@ async def process_login( Args: code (str): The authorization code. - request (Request): FastAPI or Starlette request object. + request (Request): Litestar or Starlette request object. params (Optional[Dict[str, Any]]): Additional query parameters to pass to the provider. additional_headers (Optional[Dict[str, Any]]): Additional headers to be added to all requests. redirect_uri (Optional[str]): Overrides the `redirect_uri` specified on this instance. diff --git a/mkdocs.yml b/mkdocs.yml index fe50a6d..eb526c3 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -90,6 +90,6 @@ nav: - how-to-guides/http-development.md - how-to-guides/redirect-uri-request-time.md - how-to-guides/state-return-url.md - - how-to-guides/use-with-fastapi-security.md + - how-to-guides/use-with-litestar-security.md - how-to-guides/key-error.md - contributing.md diff --git a/pyproject.toml b/pyproject.toml index ff3ff2f..720104f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [tool.poetry] name = "litestar-sso" -version = "0.15.0" -description = "FastAPI plugin to enable SSO to most common providers (such as Facebook login, Google login and login via Microsoft Office 365 Account)" +version = "0.16.0" +description = "litestar plugin to enable SSO to most common providers (such as Facebook login, Google login and login via Microsoft Office 365 Account)" authors = ["Tomas Votava "] readme = "README.md" license = "MIT" @@ -9,7 +9,7 @@ repository = "https://github.com/tomasvotava/litestar-sso" homepage = "https://tomasvotava.github.io/litestar-sso/" documentation = "https://tomasvotava.github.io/litestar-sso/" keywords = [ - "fastapi", + "litestar", "sso", "oauth", "google", diff --git a/tests/test_race_condition.py b/tests/test_race_condition.py index 3356886..5e2a605 100644 --- a/tests/test_race_condition.py +++ b/tests/test_race_condition.py @@ -1,4 +1,4 @@ -# See [!186](https://github.com/tomasvotava/fastapi-sso/issues/186) +# See [!186](https://github.com/tomasvotava/litestar-sso/issues/186) # Author: @parikls import asyncio