UI for setting cookies to populate magic parameters
Project description
datasette-cookies-for-magic-parameters
UI for setting cookies to populate magic parameters
Installation
Install this plugin in the same environment as Datasette.
datasette install datasette-cookies-for-magic-parameters
Usage
This plugin only affects canned queries. If you have a canned query configured like this:
databases:
mydatabase:
queries:
api_query:
sql: select 'Your API key is' || :_cookie_openai_api_token;
Then the /mydatabase/api_query
page will include a new interface for setting the openapi_api_token
cookie, or unsetting it if it has already been set.
Why use this?
This plugin was initially developed to use with datasette-openai - a plugin that provides custom SQL functions that take an API token as one of their parameters.
Passing these API tokens in a GET query string is unsafe, as they may leak through referrers or other log files.
Instead, this plugin enables them to be set and passed using a cookie, which is much less likely to be logged.
This pattern takes advantage of the :_cookie_x
feature of Datasette's magic parameters mechanism.
Development
To set up this plugin locally, first checkout the code. Then create a new virtual environment:
cd datasette-cookies-for-magic-parameters
python3 -m venv venv
source venv/bin/activate
Now install the dependencies and test dependencies:
pip install -e '.[test]'
To run the tests:
pytest
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for datasette-cookies-for-magic-parameters-0.1.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0d900f8a45350310deeb35b5280b2a9030580cf87a8627aa58349e8f615c99ac |
|
MD5 | 70491feb2c4295147545e7ad1fe0da8a |
|
BLAKE2b-256 | d5a85c37ecec1c4dd29778459663b7e1b33f420e9dfa63b0a7e3da62b0e8b02b |
Hashes for datasette_cookies_for_magic_parameters-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5233dd6e8b32af0c58ea3854dee92dbb9b9611fa57b6fdad89904bf9990098a4 |
|
MD5 | a51a66138f1eb7f5223b35a4f7e009a2 |
|
BLAKE2b-256 | e9526e19f80ba7f82e944c65b382ca705d14c80afdf7685d13f988e0d49397f6 |