Skip to main content

Datasette plugin that authenticates users against Openstreetmap

Project description

datasette-auth-osm

PyPI Tests License

Datasette plugin that authenticates users against OpenStreetMap

Installation

Install this plugin in the same environment as Datasette.

datasette install datasette-auth-osm

Demo

You can try this out at datasette-auth-osm.madflex.de - click on the top right menu icon and select "Sign in with OpenStreetMap".

Initial configuration

First, create a new application in Openstreetmap - OAuth2 Applications. You will need the client ID and client secret for that application.

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

Then configure these plugin secrets using metadata.yml:

plugins:
  datasette-auth-osm:
    client_id:
      "$env": OSM_CLIENT_ID
    client_secret:
      "$env": OSM_CLIENT_SECRET

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

OSM_CLIENT_ID="...client-id-goes-here..." \
OSM_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-osm \
--plugin-secret datasette-auth-osm client_id "your-client-id" \
--plugin-secret datasette-auth-osm client_secret "your-client-secret" \
--service datasette-auth-osm-demo

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

The callback URL should be something like:

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

Development

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

cd datasette-auth-osm
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


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-osm-0.2.tar.gz (8.6 kB view hashes)

Uploaded Source

Built Distribution

datasette_auth_osm-0.2-py3-none-any.whl (8.2 kB view hashes)

Uploaded Python 3

Supported by

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