wiki:ServerOperators

Version 1 (modified by wangi, 3 hours ago) ( diff )

Update for auth simplification #24928

Using JOSM with your own OSM server

This page is for people who run a server with the OSM website software, ​openstreetmap-website, other than openstreetmap.org: a project of its own, a regional or test instance, or a development installation. It says what JOSM needs to download from, and upload to, such a server. For the settings a JOSM user makes, see Preferences > OSM Server.

In short

  1. Serve the OAuth metadata at /.well-known/oauth-authorization-server on the host of your API URL.
  2. Register an OAuth 2.0 application for JOSM: public (not confidential), with the redirect URL http://127.0.0.1:8111/oauth_authorization and the permissions read_gpx, write_gpx, read_prefs, write_prefs, write_api and write_notes.
  3. Give your users its Client ID, or ask for it to be built into JOSM.

Authentication

JOSM authenticates with ​OAuth 2.0: the user authorizes JOSM in the web browser, on your website, and JOSM receives an Access Token for the server. The authorization uses PKCE, so a public client works without a client secret.

Basic authentication, with user name and password, is also available in JOSM, in expert mode, as a quick way to test a server; it is not offered for openstreetmap.org and OpenGeofiction, which do not accept it. It is not meant for a server with users of its own.

JOSM keeps its OAuth settings and the Access Token per server, by the host name of the API URL.

OAuth metadata (RFC 8414)

JOSM looks up the endpoints of the server in its OAuth 2.0 authorization server metadata (​RFC 8414), at

<scheme>://<host>[:<port>]/.well-known/oauth-authorization-server

where scheme, host and port are those of the API URL. openstreetmap-website answers this request itself, for instance:

https://www.openstreetmap.org/.well-known/oauth-authorization-server

JOSM reads authorization_endpoint and token_endpoint from it. If the API is served from a host other than the website, the API host has to answer this request too, directly or with a redirect to the website, as api.openstreetmap.org does.

If JOSM gets no metadata, it falls back to the endpoints of openstreetmap-website, below the address of the website, which is taken to be the API URL without the trailing /api:

<website>/oauth2/authorize
<website>/oauth2/token

So a server whose API URL is https://example.org/api works with JOSM's defaults even without the metadata. Users can enter different endpoints in the advanced OAuth parameters, but each user would have to.

The OAuth 2.0 application for JOSM

A Client ID is needed in any case: the metadata does not provide one. Register an application for JOSM on your server, on openstreetmap-website under My Settings > OAuth 2 applications, with:

Setting Value
Name JOSM
Confidential application No. JOSM is a desktop application and cannot keep a secret; it uses PKCE instead.
Redirect URIs http://127.0.0.1:8111/oauth_authorization — JOSM receives the authorization by Remote Control on this address.
Permissions read_prefs, write_prefs, write_api, read_gpx, write_gpx and write_notes

JOSM asks for all six permissions when it authorizes. An application allowed fewer is rejected by the server when JOSM authorizes; a token issued with fewer permissions and pasted into JOSM works only for what it allows.

Then either:

  • publish the Client ID for your users, who untick Use default settings in Preferences > OSM Server and enter it in the field Client ID; or
  • ask for it to be built into JOSM, so that Authorize now works for your server without any setting: open a ticket with the API URL of your server and the Client ID of an application registered as above. JOSM has built-in Client IDs for openstreetmap.org, the OSM development servers, OpenHistoricalMap and OpenGeofiction.

Without a Client ID, JOSM does not send the user to the browser, but says that it has no OAuth Client ID for the server and offers to open the preferences.

Tokens obtained outside JOSM

A user can also paste an Access Token obtained in another way into the field Access Token of the OSM Server preferences; nothing else needs to be set for it to work. JOSM sends it as a bearer token.

Checking the setup

  1. In JOSM, enter your API URL in Preferences > OSM Server and click Validate.
  2. Untick Use default settings if JOSM has no built-in Client ID for your server, and enter it; the endpoints should already show those of your server.
  3. Click Authorize now, authorize JOSM in the browser, then click Test Access Token: it should show your user name.
  4. If authorization fails, start JOSM with --debug: the log shows the requests JOSM makes, with credentials stripped (since r19711).

Back to Preferences > OSM Server
Back to Main Help

Note: See TracWiki for help on using the wiki.