Adds a current_actor() function to SQLite that show's the current actor's ID.
Project description
datasette-current-actor
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
Release history Release notifications | RSS feed
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
Hashes for datasette-current-actor-0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 587c6b8ae532681af7d6e37409364861abaea621ea5d56eef28d16be9d7d5490 |
|
MD5 | 4b506dbada0bf6785d37dc850e8fac1a |
|
BLAKE2b-256 | 2db18a064da45001399b0ea3f3d09cd5e071289d61d73f475b36450d173575bc |
Hashes for datasette_current_actor-0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | af30b62fb0c239e910402f567c0d6c4e128cb5b3a97d8e3bd2745246c1e23046 |
|
MD5 | 0531d1a0d6470e1ab689397ce4621cc1 |
|
BLAKE2b-256 | e27ec447b66e490c6a1e8b4a3e41b1fbf394234c0f980772a176fae0a96d4be6 |