Skip to content

Conversation

@ofr1tz
Copy link
Collaborator

@ofr1tz ofr1tz commented May 21, 2025

MapSwipe app allows for authentication through OpenStreetMap OAuth2 for a while already, the MapSwipe web application lacks this feature so far.

Two different Firebase functions (redirect and token) are currently provided to enable OSM authentication for the smartphone app. This PR provides the additional two respective Firebase functions redirectweb and tokenweb to allow for OSM authentication through the web app.

The additional functions work pretty much the same as the existing ones, but use a different OSM OAuth client with a different redirect link. This is necessary, as the redirect URL has to be the same as the one defined for the OSM OAuth client.

In addition to that, this PR includes a fix to an existing bug to avoid that OSM authenticated profiles are overwritten on Firebase RTDB with each new log in.

Prerequisites

This introduces four new .env variables that need to be set:

  • OSM_OAUTH_REDIRECT_URI_WEB: The URI to redirect to after authorizing the client with OSM. Should be https://auth.mapswipe.org/tokenweb (https://dev-auth.mapswipe.org/tokenweb for the dev instance)
  • OSM_OAUTH_CLIENT_ID_WEB: The client ID of the client registered with OSM OAuth2
  • OSM_OAUTH_CLIENT_SECRET_WEB: The client secret of the client registered with OSM OAuth2. Note that the client for MapSwipe dev instance is not registered on openstreetmap.org, but on OSM dev instance (master.apis.dev.openstreetmap.org/)
  • OSM_OAUTH_APP_LOGIN_LINK_WEB: The URI to redirect to from tokenweb. Should be https://web.mapswipe.org/#/osm-callback (https://web.mapswipe.org/dev/#/osm-callback for MapSwipe dev instance)

Deployment

To properly deploy the updated functions on the server, make sure to remove the firebase_deploy image first:

docker rmi python-mapswipe-workers-firebase_deploy
make update_firebase_functions_and_db_rules

Test


Fixes #1030

@ofr1tz ofr1tz requested a review from frozenhelium May 21, 2025 11:44
@ofr1tz ofr1tz merged commit 9380c13 into dev Jun 3, 2025
1 check passed
@ofr1tz ofr1tz deleted the osm-login-web branch June 3, 2025 09:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Group memberships not persistent on sign in for OSM profile

3 participants