Skip to main content

Datasette plugin for authenticating access using passwords

Project description

datasette-auth-passwords

PyPI Changelog License

Datasette plugin for authenticating access using passwords

Installation

Install this plugin in the same environment as Datasette.

$ pip install datasette-auth-passwords

Usage

This plugin works based on a list of username/password accounts that are hard-coded into the plugin configuration.

First, you'll need to create a password hash. You can do this using the tool located at /-/password-tool when the plugin is installed.

Now add the following to your metadata.json:

{
    "plugins": {
        "datasette-auth-passwords": {
            "someusername_password_hash": {
                "$env": "PASSWORD_HASH_1"
            }
        }
    }
}

The password hash can now be specified in an environment variable when you run Datasette. You can do that like so:

PASSWORD_HASH_1="pbkdf2_sha256$..." \
    datasette -m metadata.json

You will now be able to log in to your instance using the form at /-/login with someusername as the username and the password that you used to create your hash as the password.

You can include as many accounts as you like in the configuration, each with different usernames.

Specifying actors

By default, a logged in user will result in an actor block that just contains their username:

{
    "id": "someusername"
}

You can customize the actor that will be used for a username by including an "actors" configuration block, like this:

{
    "plugins": {
        "datasette-auth-passwords": {
            "someusername_password_hash": {
                "$env": "PASSWORD_HASH_1"
            },
            "actors": {
                "someusername": {
                    "id": "someusername",
                    "name": "Some user"
                }
            }
        }
    }
}

Using with datasette publish

If you are publishing data using a datasette publish command you can use the --plugin-secret option to securely configure your password hashes (see secret configuration values).

You would run the command something like this:

datasette publish cloudrun mydatabase.db \
    --install datasette-auth-passwords \
    --plugin-secret root_password_hash "pbkdf2_sha256$..." \
    --service datasette-auth-passwords-demo

Development

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

cd datasette-auth-passwords
python3 -mvenv venv
source venv/bin/activate

Or if you are using pipenv:

pipenv shell

Now install the dependencies and tests:

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-auth-passwords-0.2a0.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

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

datasette_auth_passwords-0.2a0-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file datasette-auth-passwords-0.2a0.tar.gz.

File metadata

  • Download URL: datasette-auth-passwords-0.2a0.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.3

File hashes

Hashes for datasette-auth-passwords-0.2a0.tar.gz
Algorithm Hash digest
SHA256 14bca6937d748a7a34c4deab4745715076d55e9d99e301483ce4b185a8d75c6b
MD5 fab1c0de9be768ce97dd73f755b27b26
BLAKE2b-256 5cfa7fb714fde0a2448e69470a6251943445ad8c4c7ed014e63d5ad55cca9fc4

See more details on using hashes here.

File details

Details for the file datasette_auth_passwords-0.2a0-py3-none-any.whl.

File metadata

  • Download URL: datasette_auth_passwords-0.2a0-py3-none-any.whl
  • Upload date:
  • Size: 4.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.3

File hashes

Hashes for datasette_auth_passwords-0.2a0-py3-none-any.whl
Algorithm Hash digest
SHA256 48b273a17b6ad86c37e6bc1681fe312320d6cc93cd81729313c0edb7ba8872f2
MD5 46c9335ed080173118a0135d83afc75a
BLAKE2b-256 c86e3d1a204db4349bb3c23c4f9b9867879e41557849c949f2598fe7c0c16b8b

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