Skip to main content

UI for setting cookies to populate magic parameters

Project description

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

Project details


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

File details

Details for the file datasette-cookies-for-magic-parameters-0.1.tar.gz.

File metadata

File hashes

Hashes for datasette-cookies-for-magic-parameters-0.1.tar.gz
Algorithm Hash digest
SHA256 a0b1e8defe8e6152ce567cc17a8ccfabce9fc0499926929f19381f13bb4049f9
MD5 8aa8931d4aeb2b2cbce4eb245f8ccaa0
BLAKE2b-256 ecc51ef67fa594c9ed6ceeb3a83d9e2b9c7cf50508f5ba98fef0ca3cd9f329bd

See more details on using hashes here.

File details

Details for the file datasette_cookies_for_magic_parameters-0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for datasette_cookies_for_magic_parameters-0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 cfa31f387f1d7bee620587a9719462e5c5fc73d91fb6be7a211907aae8936a4c
MD5 e28169900e37e78fd1d4dc97f51718bc
BLAKE2b-256 445078bdcb3b495cd46a04b0fd27be5d2511cadeb04b8adeb2e6e35866966866

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page