Skip to content

Commit

Permalink
WIP forward auth headers
Browse files Browse the repository at this point in the history
  • Loading branch information
simonw committed Feb 7, 2024
1 parent c0ab66b commit 0b9fac6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions datasette_graphql/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ async def view_graphql(request, datasette):
"num_queries_executed": 0,
"num_queries_limit": config.get("num_queries_limit")
or DEFAULT_NUM_QUERIES_LIMIT,
"request": request, # For authentication headers
}

result = await schema.execute_async(
Expand Down
10 changes: 9 additions & 1 deletion datasette_graphql/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,15 @@ async def resolve_table(
path_with_query_string,
)

data = (await datasette.client.get(path_with_query_string)).json()
headers = context["request"].headers
cookies = context["request"].cookies

response = await datasette.client.get(
path_with_query_string, headers=headers, cookies=cookies
)
if response.status_code != 200:
raise Exception(str(response.status_code) + response.text)
data = response.json()
# If any cells are $base64, decode them into bytes objects
for row in data["rows"]:
for key, value in row.items():
Expand Down

0 comments on commit 0b9fac6

Please sign in to comment.