Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@simonw
Created July 14, 2019 01:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simonw/46e39495761e63c7ede2811c0782ac07 to your computer and use it in GitHub Desktop.
Save simonw/46e39495761e63c7ede2811c0782ac07 to your computer and use it in GitHub Desktop.
datasette_auth_github middleware example, from https://simonwillison.net/2019/Jul/14/sso-asgi/
from datasette_auth_github import GitHubAuth
from starlette.applications import Starlette
from starlette.responses import HTMLResponse
import uvicorn
app = Starlette(debug=True)
@app.route("/")
async def homepage(request):
return HTMLResponse("Hello, {}".format(
repr(request.scope["auth"])
))
authenticated_app = GitHubAuth(
app,
client_id="986f5d837b45e32ee6dd",
client_secret="...",
require_auth=True,
allow_users=["simonw"],
)
if __name__ == "__main__":
uvicorn.run(authenticated_app, host="0.0.0.0", port=8000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment