Skip to main content

Datasette plugin that authenticates users using Auth0

Project description

datasette-auth0

PyPI Changelog Tests License

Datasette plugin that authenticates users using Auth0

Installation

Install this plugin in the same environment as Datasette.

$ datasette install datasette-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-auth-passwords \
--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

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-auth0-0.1a0.tar.gz (7.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

datasette_auth0-0.1a0-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file datasette-auth0-0.1a0.tar.gz.

File metadata

  • Download URL: datasette-auth0-0.1a0.tar.gz
  • Upload date:
  • Size: 7.9 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for datasette-auth0-0.1a0.tar.gz
Algorithm Hash digest
SHA256 b20f176b69e965ff793022021ded5b86c0944e0a18c240c9194089aa5084a0bb
MD5 1987c8860c90594ba8fffad82f3e383d
BLAKE2b-256 1f91cccb17bef1f37c513aa552b8034626e5c582b2626c2a0abcb15aa6709c69

See more details on using hashes here.

File details

Details for the file datasette_auth0-0.1a0-py3-none-any.whl.

File metadata

  • Download URL: datasette_auth0-0.1a0-py3-none-any.whl
  • Upload date:
  • Size: 8.4 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for datasette_auth0-0.1a0-py3-none-any.whl
Algorithm Hash digest
SHA256 6d48d5252d6b2446db4bfd9eab61ded7776ed616a9595acab1613b627ad4ba3a
MD5 be1e349cf7a7bacc4ed7c29823691fa0
BLAKE2b-256 2d09311ba725556a80b52d53f13c6ee1f40e58a9944ee8d34f9d5bb91c852550

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page