Skip to main content

datasette-sqlite-authorizer

PyPI Changelog Tests License

Configure Datasette to block operations using the SQLite set_authorizer mechanism

Installation

Install this plugin in the same environment as Datasette.

datasette install datasette-sqlite-authorizer

Usage

This plugin currently offers a single configuration option: read_only_tables. You can use this to specify a list of tables that should be read-only.

If a table is read-only, any attempt to write to it - insert, update, delete, drop table, alter table - will be denied with an error message.

To configure read-only tables, add the following to your metadata.yaml file:

plugins:
  datasette-sqlite-authorizer:
    read_only_tables:
    - table: my_table
      database: my_database

You can omit the database key if you want to apply the same rule to all databases.

Here's how to use this plugin to make all tables relating to Litestream synchronization read-only, across all attached databases:

plugins:
  datasette-sqlite-authorizer:
    read_only_tables:
    - table: _litestream_lock
    - table: _litestream_seq

Logging actions

To enable debug output (to standard error) for specific action checks, add them to a debug_actions list. For example, to log all SQLITE_INSERT actions:

plugins:
  datasette-sqlite-authorizer:
    debug_actions:
    - SQLITE_INSERT
    - SQLITE_DELETE

Logged output will look something like this:

authorizer: {"action": "SQLITE_INSERT", "arg1": "foo", "arg2": null, "db_name": "main", "trigger_name": null, "result": "OK"}
authorizer: {"action": "SQLITE_DELETE", "arg1": "foo", "arg2": null, "db_name": "main", "trigger_name": null, "result": "OK"}

Development

To set up this plugin locally, first checkout the code. Then create a new virtual environment:

cd datasette-sqlite-authorizer
python3 -m venv venv
source venv/bin/activate

Now install the dependencies and test dependencies:

pip install -e '.[test]'

To run the tests:

pytest

Metadata

Release files for datasette-sqlite-authorizer 0.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-sqlite-authorizer 0.2
File Size Uploaded Provenance Actions
datasette-sqlite-authorizer-0.2.tar.gz 8.1 kB Without provenance Details for datasette-sqlite-authorizer-0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for datasette-sqlite-authorizer 0.2
File Interpreter ABI Platform Actions
datasette_sqlite_authorizer-0.2-py3-none-any.whl Python 3 none any Details for datasette_sqlite_authorizer-0.2-py3-none-any.whl

Total release size: 16.0 kB

Release files / datasette-sqlite-authorizer-0.2.tar.gz

Download URL datasette-sqlite-authorizer-0.2.tar.gz
Size 8.1 kB
Tags Source
SHA-256 checksum
How to use checksums
cd4aec28e9bc86fc1856b88190e2ddd36b2796a321f7286448f861f0d51ffa0d
BLAKE2b-256 checksum
How to use checksums
bea060248eafcbbd6dc44dd87d0f1f3260b0890203270c2d0b3eb1457dcf51c4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/4.0.2 CPython/3.11.8

Release files / datasette_sqlite_authorizer-0.2-py3-none-any.whl

Download URL datasette_sqlite_authorizer-0.2-py3-none-any.whl
Size 7.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c24f641b234d72ad6c9e601e9ae1bdbe1a09049493367b422d6f75d12eedd395
BLAKE2b-256 checksum
How to use checksums
15685d214c257ee7e66c95b850e08a05c5d285d5cb39697ccb4a3744d900f8e9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/4.0.2 CPython/3.11.8

Security for datasette-sqlite-authorizer 0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2 This release

2 release files No provenance

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