oauth via github

This commit is contained in:
knst-kotov
2021-07-09 07:14:16 +00:00
parent e6b0866f6e
commit 571dad6f60
6 changed files with 76 additions and 31 deletions

View File

@@ -5,6 +5,7 @@ from ariadne.asgi import GraphQL
from starlette.applications import Starlette
from starlette.middleware import Middleware
from starlette.middleware.authentication import AuthenticationMiddleware
from starlette.middleware.sessions import SessionMiddleware
from starlette.routing import Route
from auth.authenticate import JWTAuthenticate
@@ -15,8 +16,10 @@ from resolvers.base import resolvers
import_module('resolvers')
schema = make_executable_schema(load_schema_from_path("schema/"), resolvers)
middleware = [Middleware(AuthenticationMiddleware, backend=JWTAuthenticate())]
middleware = [
Middleware(AuthenticationMiddleware, backend=JWTAuthenticate()),
Middleware(SessionMiddleware, secret_key="!secret")
]
async def start_up():
await redis.connect()
@@ -30,6 +33,5 @@ routes = [
Route("/authorize", endpoint=oauth_authorize)
]
app = Starlette(debug=True, on_startup=[start_up], on_shutdown=[shutdown], middleware=middleware, routes=routes)
app.mount("/", GraphQL(schema, debug=True))