https://github.com/mfa/datasette-auth-osm
Datasette plugin that authenticates users against OpenStreetmap
https://github.com/mfa/datasette-auth-osm
datasette datasette-plugin oauth2 openstreetmap-api
Last synced: 5 months ago
JSON representation
Datasette plugin that authenticates users against OpenStreetmap
- Host: GitHub
- URL: https://github.com/mfa/datasette-auth-osm
- Owner: mfa
- License: apache-2.0
- Created: 2023-04-10T18:47:02.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2025-08-08T15:47:14.000Z (10 months ago)
- Last Synced: 2025-09-13T05:33:52.788Z (9 months ago)
- Topics: datasette, datasette-plugin, oauth2, openstreetmap-api
- Language: Python
- Homepage: https://datasette-auth-osm-demo.fly.dev/
- Size: 31.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# datasette-auth-osm
[](https://pypi.org/project/datasette-auth-osm/)
[](https://github.com/mfa/datasette-auth-osm/actions?query=workflow%3ATest)
[](https://github.com/mfa/datasette-auth-osm/blob/main/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-demo.fly.dev](https://datasette-auth-osm-demo.fly.dev/) - click on the top right menu icon and select "Sign in with OpenStreetMap".
## Initial configuration
First, create a new application in [Openstreetmap - OAuth2 Applications](https://www.openstreetmap.org/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`:
```yaml
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
```
Once your Datasette instance is deployed, you will need to add its callback URL to the "Allowed Callback URLs" list your [OAuth2 application](https://www.openstreetmap.org/oauth2/applications) in OpenStreetMap.
The callback URL should be something like:
https://url-to-your-datasette/-/osm-callback
Example for a permission block to only allow logged in users to see the private.db:
``` yaml
databases:
private:
allow:
osm_id: "*"
```
The name of the actor field is not ``id`` as in the Datasette documentation, but ``osm_id``.
## 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