datasette-sqlite-debug-authorizer by datasette

17 downloads this week        Star

README source code

datasette-sqlite-debug-authorizer

PyPI Changelog Tests License

Debug SQLite authorizer calls

Installation

Install this plugin in the same environment as Datasette.

datasette install datasette-sqlite-debug-authorizer

Usage

Once installed, every SQLite permission check using the conn.set_authorizer() API will be logged to standard error.

This is useful for if you want to use that authorizer API to implement your own custom permissions, and need to see what calls are being made to the authorizer.

Example output (it's generally a lot noisier than this) for select * from sqlite_master:

SQLITE_SELECT: 
SQLITE_READ:  table="sqlite_master" column="type" db_name=main
SQLITE_READ:  table="sqlite_master" column="name" db_name=main
SQLITE_READ:  table="sqlite_master" column="tbl_name" db_name=main
SQLITE_READ:  table="sqlite_master" column="rootpage" db_name=main
SQLITE_READ:  table="sqlite_master" column="sql" db_name=main

See sqlite-authorizer-examples for more detailed documentation on what to expect from these calls.

Development

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

cd datasette-sqlite-debug-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