Skip to main content

datasette-cookies-for-magic-parameters

PyPI Changelog Tests License

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

Release files for datasette-cookies-for-magic-parameters 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for datasette-cookies-for-magic-parameters 0.1.2
File Size Uploaded
datasette-cookies-for-magic-parameters-0.1.2.tar.gz 8.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for datasette-cookies-for-magic-parameters 0.1.2
File Interpreter ABI Platform
datasette_cookies_for_magic_parameters-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 16.6 kB

Release files / datasette-cookies-for-magic-parameters-0.1.2.tar.gz

Download URL datasette-cookies-for-magic-parameters-0.1.2.tar.gz
Size 8.0 kB
Tags Source
SHA-256 checksum
How to use checksums
0e16376e9217b0c8749b5148ccecc59f16f70e0275359857fe5ff6dabdedd3b4
BLAKE2b-256 checksum
How to use checksums
dc789d0f2f8ae1f5b609358cfcdb8affaa88cffe8d11f1492eb40d86ba93d3f1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.1

Release files / datasette_cookies_for_magic_parameters-0.1.2-py3-none-any.whl

Download URL datasette_cookies_for_magic_parameters-0.1.2-py3-none-any.whl
Size 8.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
45d79e11e08efa38c108f12fc32fddea7d16ce84c22d2199e7dd6e64be34442d
BLAKE2b-256 checksum
How to use checksums
7042f4163ba1b15801bdf5c8d4a397ccdfc577dd9c6ff823ba4dce6a537b6c91
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.1

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page