Recommende way to implement authentication
For Flask, there are some authentication snippets e.g. basic authentication
I did not find any authentication example in Responder project.
Is there any?
Might be related to #232
It does reference sessions in the docs, but not how to authenticate
This is how it's been done on starlette https://www.starlette.io/authentication/
I think you can call api.add_middleware and it'll work the same as starlette.
Starlette's AuthenticationMiddleware would work fine, and would add auth into the ASGI scope,
but you also need to implement permissions, that determine what to do, given the authentication/user credentials. (ie. Statlette's @requires decorator.)
If responder added an auth property on the request (returning the auth item from the ASGI scope) then I think the @requires decorator would work just fine.
What should exactly happen so that we can leverage starlette's authentication facility? cc @kenneth-reitz
Note: I had to reimplement responder's session handling inside of my custom middleware as the session management from starlette's middleware is incompatible. I'm not sure what the best way forward here is in light of that.
Love to see a best practice implementation here. I have implemented an authenticate decorator using functools wraps like I use in Flask. This works fine for bearer tokens and basic authentication.