mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Implemented actor_from_request with tests, refs #699
Also added datasette argument to permission_allowed hook
This commit is contained in:
parent
060a56735c
commit
461c82838d
6 changed files with 80 additions and 2 deletions
|
|
@ -798,7 +798,18 @@ class DatasetteRouter(AsgiRouter):
|
|||
and scope.get("scheme") != "https"
|
||||
):
|
||||
scope = dict(scope, scheme="https")
|
||||
return await super().route_path(scope, receive, send, path)
|
||||
# Handle authentication
|
||||
actor = None
|
||||
for actor in pm.hook.actor_from_request(
|
||||
datasette=self.ds, request=Request(scope, receive)
|
||||
):
|
||||
if callable(actor):
|
||||
actor = actor()
|
||||
if asyncio.iscoroutine(actor):
|
||||
actor = await actor
|
||||
if actor:
|
||||
break
|
||||
return await super().route_path(dict(scope, actor=actor), receive, send, path)
|
||||
|
||||
async def handle_404(self, scope, receive, send, exception=None):
|
||||
# If URL has a trailing slash, redirect to URL without it
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue