Skip to content

Commit

Permalink
feat: update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
ccrvlh committed Nov 3, 2024
1 parent 8f2047a commit cf5fadf
Showing 1 changed file with 63 additions and 23 deletions.
86 changes: 63 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,39 +1,79 @@
# 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)
![Tests Workflow Status](https://img.shields.io/github/actions/workflow/status/tomasvotava/litestar-sso/test.yml?label=tests)
![Lint Workflow Status](https://img.shields.io/github/actions/workflow/status/tomasvotava/litestar-sso/lint.yml?label=ruff)
![Mypy Workflow Status](https://img.shields.io/github/actions/workflow/status/tomasvotava/litestar-sso/lint.yml?label=mypy)
![Black Workflow Status](https://img.shields.io/github/actions/workflow/status/tomasvotava/litestar-sso/lint.yml?label=black)
![CodeQL Workflow Status](https://img.shields.io/github/actions/workflow/status/tomasvotava/litestar-sso/codeql-analysis.yml?label=CodeQL)
![PyPi weekly downloads](https://img.shields.io/pypi/dw/litestar-sso)
![Project License](https://img.shields.io/github/license/tomasvotava/litestar-sso)
![PyPi Version](https://img.shields.io/pypi/v/litestar-sso)

Litestar plugin to enable SSO to most common providers (such as Facebook login, Google login and login via
# FastAPI SSO

![Supported Python Versions](https://img.shields.io/pypi/pyversions/fastapi-sso)
[![Test coverage](https://codecov.io/gh/tomasvotava/fastapi-sso/graph/badge.svg?token=SIFCTVSSOS)](https://codecov.io/gh/tomasvotava/fastapi-sso)
![Tests Workflow Status](https://img.shields.io/github/actions/workflow/status/tomasvotava/fastapi-sso/test.yml?label=tests)
![Lint Workflow Status](https://img.shields.io/github/actions/workflow/status/tomasvotava/fastapi-sso/lint.yml?label=ruff)
![Mypy Workflow Status](https://img.shields.io/github/actions/workflow/status/tomasvotava/fastapi-sso/lint.yml?label=mypy)
![Black Workflow Status](https://img.shields.io/github/actions/workflow/status/tomasvotava/fastapi-sso/lint.yml?label=black)
![CodeQL Workflow Status](https://img.shields.io/github/actions/workflow/status/tomasvotava/fastapi-sso/codeql-analysis.yml?label=CodeQL)
![PyPi weekly downloads](https://img.shields.io/pypi/dw/fastapi-sso)
![Project License](https://img.shields.io/github/license/tomasvotava/fastapi-sso)
![PyPi Version](https://img.shields.io/pypi/v/fastapi-sso)

> [!IMPORTANT]
> This is a fork of the FastAPI SSO library, originally designed by [tomasvotava](https://tomasvotava.github.io).
> The only modification is that this was adapted to work with Litestar, and PR #189 was merged into this fork.
> Currently, this is best suited as building block, rather than a standalone library.
FastAPI 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
backend very easily.

**Documentation**: [https://tomasvotava.github.io/litestar-sso/](https://tomasvotava.github.io/litestar-sso/)
**Documentation**: [https://tomasvotava.github.io/fastapi-sso/](https://tomasvotava.github.io/fastapi-sso/)

**Source Code**: [https://github.com/tomasvotava/litestar-sso](https://github.com/tomasvotava/litestar-sso/)
**Source Code**: [https://github.com/tomasvotava/fastapi-sso](https://github.com/tomasvotava/fastapi-sso/)

## Example:

```python
import os
from litestar import Litestar, Request, get
from litestar_sso.sso.google import GoogleSSO

CLIENT_ID = os.environ["CLIENT_ID"]
CLIENT_SECRET = os.environ["CLIENT_SECRET"]

app = Litestar()

sso = GoogleSSO(
client_id=CLIENT_ID,
client_secret=CLIENT_SECRET,
redirect_uri="http://localhost:5000/auth/callback",
allow_insecure_http=True,
)


@get("/auth/login")
async def auth_init():
"""Initialize auth and redirect"""
async with sso:
return await sso.get_login_redirect(params={"prompt": "consent", "access_type": "offline"})


@get("/auth/callback")
async def auth_callback(request: Request):
"""Verify login"""
async with sso:
user = await sso.verify_and_process(request)
return user
```

## Demo site

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 Litestar and Litestar SSO.
Medium articles about FastAPI and FastAPI SSO.

Be sure to see his tutorials, follow him and show him some appreciation!

Please see his [announcement](https://github.com/tomasvotava/litestar-sso/discussions/150) with all the links.
Please see his [announcement](https://github.com/tomasvotava/fastapi-sso/discussions/150) with all the links.

Quick links for the eager ones:

- [Demo site](https://litestar-sso-example.vercel.app/)
- [Demo site](https://fastapi-sso-example.vercel.app/)
- [Medium articles](https://medium.com/@christos.karvouniaris247)

## Security warning
Expand Down Expand Up @@ -64,7 +104,7 @@ I tend to process Pull Requests faster when properly caffeinated 😉.
- Spotify
- Fitbit
- Github (credits to [Brandl](https://github.com/Brandl) for hint using `accept` header)
- generic (see [docs](https://tomasvotava.github.io/litestar-sso/reference/sso.generic/))
- generic (see [docs](https://tomasvotava.github.io/fastapi-sso/reference/sso.generic/))
- Notion
- Twitter (X)

Expand All @@ -85,16 +125,16 @@ See [Contributing](#contributing) for a guide on how to contribute your own logi
### Install using `pip`

```console
pip install litestar-sso
pip install fastapi-sso
```

### Install using `poetry`

```console
poetry add litestar-sso
poetry add fastapi-sso
```

## Contributing

If you'd like to contribute and add your specific login provider, please see
[Contributing](https://tomasvotava.github.io/litestar-sso/contributing) file.
[Contributing](https://tomasvotava.github.io/fastapi-sso/contributing) file.

0 comments on commit cf5fadf

Please sign in to comment.