Drop API token requirement from API explorer, refs #1871

This commit is contained in:
Simon Willison 2022-10-30 13:09:55 -07:00
commit 9eb9ffae3d
2 changed files with 13 additions and 9 deletions

View file

@ -131,3 +131,12 @@ def register_commands(cli):
if debug:
click.echo("\nDecoded:\n")
click.echo(json.dumps(ds.unsign(token, namespace="token"), indent=2))
@hookimpl
def skip_csrf(scope):
# Skip CSRF check for requests with content-type: application/json
if scope["type"] == "http":
headers = scope.get("headers") or {}
if dict(headers).get(b"content-type") == b"application/json":
return True