Skip to main content

Authenticate a Datasette instance using headers set by an upstream proxy

Project description

datasette-auth-headers

PyPI Changelog Tests License

Authenticate a Datasette instance using headers set by an upstream proxy


This plugin is designed to work when Datasette is being run behind a reverse proxy, such as Caddy, that is performing authentication on behalf of the app and setting headers in the upstream request.

For example, when Caddy and Authentik's proxy provider are used together with a configuration like so:

example.com {
  forward_auth * authentik {
    // ...
  }
  reverse_proxy datasette
}

Authentik will set a number of headers in the upstream request, such as X-Authentik-User, to inform us who is authenticated. This plugin uses those headers to create a Datasette actor.

Installation

Install this plugin in the same environment as Datasette.

datasette install datasette-auth-headers

Usage

You must configure this plugin on the global level within Datasette. An example configuration that reads the X-Authentik-User header and uses it as the actor ID is:

{
  "plugins": {
    "datasette-auth-headers": {
      "id-header-name": "X-Authentik-User"
    }
  }
}

id-header-name is case-insensitive and is the only configuration option at this time.

Development

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

cd datasette-auth-headers
python -m venv venv
source venv/bin/activate

Now install the dependencies and test dependencies:

pip install -e '.[test]'

To run the tests:

python -m 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_headers-0.1.0.tar.gz (7.1 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_headers-0.1.0-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

Details for the file datasette_auth_headers-0.1.0.tar.gz.

File metadata

  • Download URL: datasette_auth_headers-0.1.0.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for datasette_auth_headers-0.1.0.tar.gz
Algorithm Hash digest
SHA256 fca2f55065bfbceb36b7fee2bbe68d70b0499e8a304f91446e3ca51f224b0702
MD5 6cc135c39ac3396fe3fdc65e1bcf4fab
BLAKE2b-256 887745a3ef1ba483a18aa1c3e7fe54dc8f65331119741a4899b397e63c5def8f

See more details on using hashes here.

Provenance

The following attestation bundles were made for datasette_auth_headers-0.1.0.tar.gz:

Publisher: publish.yml on codemicro/datasette-auth-headers

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file datasette_auth_headers-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for datasette_auth_headers-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9e171c8b50f0d651ddd298acba994c99084c21157a880a85b572a498a68ec7f0
MD5 7c55b8e2946263aeb002c288c5b318d0
BLAKE2b-256 01f3cecb0d769004bf8c15d527b44be1ad63639b3e6de7066c34ca67ccc44552

See more details on using hashes here.

Provenance

The following attestation bundles were made for datasette_auth_headers-0.1.0-py3-none-any.whl:

Publisher: publish.yml on codemicro/datasette-auth-headers

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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