{"html_url": "https://github.com/simonw/datasette/issues/1020#issuecomment-712482504", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1020", "id": 712482504, "node_id": "MDEyOklzc3VlQ29tbWVudDcxMjQ4MjUwNA==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-10-19T22:45:01Z", "updated_at": "2020-10-19T22:45:01Z", "author_association": "OWNER", "body": "I'm having trouble coming up with the syntax for this. Here's one option:\r\n```python\r\nresponse = await datasette.client.get(path, request=request)\r\n```\r\nBut this feels confusing to me. We're not using the `request=` argument as a request - we're using it as a source of some default request values (the cookies and incoming headers, but not the path).\r\n\r\nWe're essentially combining that request with the other arguments passed to `.get()`.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 721068929, "label": "Method for datasette.client() to forward on authentication"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1020#issuecomment-712482015", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1020", "id": 712482015, "node_id": "MDEyOklzc3VlQ29tbWVudDcxMjQ4MjAxNQ==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-10-19T22:43:24Z", "updated_at": "2020-10-19T22:43:24Z", "author_association": "OWNER", "body": "... unless I want to support authentication mechanisms that work based on incoming IP address instead, in which case there's an argument for copying more over from the incoming request.\r\n\r\nTailscale is a good example of a system where authentication based on IP address can actually work well, so this is worth doing. Also, there might be authentication mechanisms which work by setting a custom header on the incoming request (not to mention the `Authorization` header).", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 721068929, "label": "Method for datasette.client() to forward on authentication"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1020#issuecomment-712481568", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1020", "id": 712481568, "node_id": "MDEyOklzc3VlQ29tbWVudDcxMjQ4MTU2OA==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-10-19T22:41:59Z", "updated_at": "2020-10-19T22:41:59Z", "author_association": "OWNER", "body": "It turns out this works just fine:\r\n```python\r\nresponse = await datasette.client.get(path, cookies=request.cookies)\r\n```\r\nSo I don't need a mechanism for this. I'm going to add this to the documentation instead.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 721068929, "label": "Method for datasette.client() to forward on authentication"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1020#issuecomment-708670392", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1020", "id": 708670392, "node_id": "MDEyOklzc3VlQ29tbWVudDcwODY3MDM5Mg==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-10-14T21:29:22Z", "updated_at": "2020-10-14T21:29:22Z", "author_association": "OWNER", "body": "I should also verify (and probably unit-test) that things like the `?_trace=1` mechanism work across the internal request boundary.\r\n\r\n`/-/permissions` appears to work across this boundary, but again a test would be useful confirmation.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 721068929, "label": "Method for datasette.client() to forward on authentication"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1020#issuecomment-708669778", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1020", "id": 708669778, "node_id": "MDEyOklzc3VlQ29tbWVudDcwODY2OTc3OA==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-10-14T21:27:58Z", "updated_at": "2020-10-14T21:27:58Z", "author_association": "OWNER", "body": "Maybe these internal requests should have some kind of flag that lets the underlying code tell that it's being called internally.\r\n\r\nOne option: add a `x-internal: 1` request header - and ensure that any requests from outside Datasette have that header stripped.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 721068929, "label": "Method for datasette.client() to forward on authentication"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1020#issuecomment-708669178", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1020", "id": 708669178, "node_id": "MDEyOklzc3VlQ29tbWVudDcwODY2OTE3OA==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-10-14T21:26:37Z", "updated_at": "2020-10-14T21:26:37Z", "author_association": "OWNER", "body": "One option: add an optional request=... parameter which can be passed the current request, and will use that to populate the mock request with the exception of the bits that are passed explicitly (like the path):\r\n\r\n```python\r\nresponse = await datasette.client.get(\"/db/table.json\", request=request)\r\n```", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 721068929, "label": "Method for datasette.client() to forward on authentication"}, "performed_via_github_app": null}