Skip to main content

datasette-auth0

PyPI Changelog Tests License

Datasette plugin that authenticates users using Auth0

See Simplest possible OAuth authentication with Auth0 for more about how this plugin works.

Installation

Install this plugin in the same environment as Datasette.

$ datasette install datasette-auth0

Demo

You can try this out at datasette-auth0-demo.datasette.io - click on the top right menu icon and select "Sign in with Auth0".

Initial configuration

First, create a new application in Auth0. You will need the domain, client ID and client secret for that application.

The domain should be something like mysite.us.auth0.com.

Add http://127.0.0.1:8001/-/auth0-callback to the list of Allowed Callback URLs.

Then configure these plugin secrets using metadata.yml:

plugins:
  datasette-auth0:
    domain:
      "$env": AUTH0_DOMAIN
    client_id:
      "$env": AUTH0_CLIENT_ID
    client_secret:
      "$env": AUTH0_CLIENT_SECRET

Only the client_secret needs to be kept secret, but for consistency I recommend using the $env mechanism for all three.

In development, you can run Datasette and pass in environment variables like this:

AUTH0_DOMAIN="your-domain.us.auth0.com" \
AUTH0_CLIENT_ID="...client-id-goes-here..." \
AUTH0_CLIENT_SECRET="...secret-goes-here..." \
datasette -m metadata.yml

If you are deploying using datasette publish you can pass these using --plugin-secret. For example, to deploy using Cloud Run you might run the following:

datasette publish cloudrun mydatabase.db \
--install datasette-auth0 \
--plugin-secret datasette-auth0 domain "your-domain.us.auth0.com" \
--plugin-secret datasette-auth0 client_id "your-client-id" \
--plugin-secret datasette-auth0 client_secret "your-client-secret" \
--service datasette-auth0-demo

Once your Datasette instance is deployed, you will need to add its callback URL to the "Allowed Callback URLs" list in Auth0.

The callback URL should be something like:

https://url-to-your-datasette/-/auth0-callback

Usage

Once installed, a "Sign in with Auth0" menu item will appear in the Datasette main menu.

You can sign in and then visit the /-/actor page to see full details of the auth0 profile that has been authenticated.

You can then use Datasette permissions to grant or deny access to different parts of Datasette based on the authenticated user.

Development

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

cd datasette-auth0
python3 -mvenv 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-auth0 0.1

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-auth0 0.1
File Size Uploaded
datasette-auth0-0.1.tar.gz 8.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for datasette-auth0 0.1
File Interpreter ABI Platform
datasette_auth0-0.1-py3-none-any.whl Python 3 none any Details

Total release size: 16.5 kB

Release files / datasette-auth0-0.1.tar.gz

Download URL datasette-auth0-0.1.tar.gz
Size 8.0 kB
Tags Source
SHA-256 checksum
How to use checksums
e85e7dd2a23534b5a8b8578d8389576c67e6cc6195dbdab517a6da2a2a9a12c5
BLAKE2b-256 checksum
How to use checksums
31f5ad9f4cc2f940b72992020cfc9e656cc0c1393fbd42e32dee677a84af2711
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2

Release files / datasette_auth0-0.1-py3-none-any.whl

Download URL datasette_auth0-0.1-py3-none-any.whl
Size 8.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
371d1f36f636907f26389a5e1e2ebf7d792cc6be1ee31c75e6b6521bd7a8375e
BLAKE2b-256 checksum
How to use checksums
e89aefbbf636371f05bacbd6800deea2eb81f889887baa8765a822aa465d518e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2

Release history Release notifications | RSS feed

This release

0.1 This release

2 release files

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