GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - python-gino/authlib-gino: OpenID Connect provider implemented with Authlib and GINO.

BranchesTags
Open more actions menu

Latest commit

 

History

10 Commits
10 Commits

Folders and files

NameName
Last commit message
Last commit date
src/authlib_gino
src/authlib_gino
 
 
.gitignore
.gitignore
 
 
README.md
README.md
 
 
alembic.ini
alembic.ini
 
 
poetry.lock
poetry.lock
 
 
pyproject.toml
pyproject.toml
 
 

Repository files navigation

Authlib-GINO

This experimental and transitional library provides:

  • starlette_oauth2 - OAuth2 Provider using Starlette
  • gino_oauth2 - OAuth2 model mixins using GINO
  • async_grants - Asynchronous Authlib grants for OAuth2 and OpenID Connect
  • fastapi_session - A GINO App extension for session management using OpenID Connect / public client / PKCE

CAUTION: Code is copy'n'pasted from Authlib and modified for async. CAUTION: fastapi_session contains lots of assumptions.

Async OAuth2 Provider

README TBD

GINO App

GINO App is a loosely-defined FastAPI application that can be built with extensions from multiple repositories. A GINO App should provide these entry points under gino.app section:

  • db - a global gino.Gino instance
  • config - a global starlette.config.Config instance

They will be used in extensions to add more config, define additional models and run queries. An example GINO App looks like this example/app.py:

from gino.ext.starlette import Gino
from starlette.config import Config

db = Gino(...)
config = Config(...)

Then define the entry points in pyprorject.toml if Poetry is used:

[tool.poetry.plugins."gino.app"]
"db" = "example.app:db"
"config" = "example.app:config"

FastAPI Session

$ poetry add authlib-gino -E app

FastAPI Session module provides these GINO App extensions as entry points under gino.app.extensions section:

  • session.oidc - Includes OpenID Connect endpoints, model implementation and migration
  • session.admin - Includes session management endpoints
  • session.demo - A demo login endpoint

In order to utilize these extensions, create a FastAPI application and feed it to:

from importlib.metadata import entry_points
from fastapi import FastAPI

ENABLED_EXTENSIONS = {"session.oidc", "session.admin"}

app = FastAPI(...)
for ep in entry_points()["gino.app.extensions"]:
    if ep.name in ENABLED_EXTENSIONS:
        ep.load()(app)

Extension defines database schema migrations with entry points of the same name under gino.app.migrations section. To include them in your project, initialize an Alembic environment and add this to env.py:

from importlib.metadata import entry_points
from importlib.resources import path
from example.app import ENABLED_EXTENSIONS

for ep in entry_points()["gino.app.migrations"]:
    if ep.name in ENABLED_EXTENSIONS:
        with path(*ep.value.split(":", maxsplit=1)) as loc:
            context.script.version_locations.append(str(loc / "versions"))

As we are appending to version_locations, alembic.ini also needs the initial local location (change example below to match your layout):

[alembic]
version_locations = migrations/versions

Then run alembic upgrade heads (not head) to apply the migrations. Read more about working with multiple bases in Alembic.

About

OpenID Connect provider implemented with Authlib and GINO.

Resources

Readme
Activity
Custom properties

Stars

3 stars

Watchers

1 watching

Forks

1 fork
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.