Skip to main content

Adds a current_actor() function to SQLite that show's the current actor's ID.

Project description

datasette-current-actor

PyPI Changelog Tests License

Adds a current_actor() function to SQLite that show's the current actor's ID.

Installation

Install this plugin in the same environment as Datasette.

datasette install datasette-current-actor

Usage

Boring mode

SELECT current_actor() returns NULL if there's no currently-logged in actor, or the id of the actor.

You could put this in a canned query to provide limited access to tables.

Ludicrous mode

SQLite is flexible. It turns out you can refer to functions that don't exist when issuing DDL statements. As long as they exist when they're needed, it all works out.

Auditing

Create a trigger on a table that sets the last_edited_by column to current_actor().

Row-level security

Restrict what rows users can see:

CREATE VIEW rls AS
SELECT * FROM sensitive_data WHERE owner = current_actor()

Development

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

cd datasette-current-actor
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

datasette-current-actor-0.1.tar.gz (6.9 kB view hashes)

Uploaded Source

Built Distribution

datasette_current_actor-0.1-py3-none-any.whl (7.4 kB view hashes)

Uploaded Python 3

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