Changes between Initial Version and Version 1 of ServerOperators


Ignore:
Timestamp:
2026-11-28T16:41:26+01:00 (3 hours ago)
Author:
wangi
Comment:

Update for auth simplification #24928

Legend:

Unmodified
Added
Removed
Modified
  • ServerOperators

    v1 v1  
     1[[TranslatedPages]]
     2= Using JOSM with your own OSM server =
     3[[PageOutline(2-3,Table of Contents)]]
     4
     5This page is for people who run a server with the OSM website software, [https://github.com/openstreetmap/openstreetmap-website 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 [wikitr:/Help/Preferences/Connection Preferences > OSM Server].
     6
     7== In short ==
     8 1. Serve the OAuth metadata at `/.well-known/oauth-authorization-server` on the host of your API URL.
     9 1. 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`.
     10 1. Give your users its Client ID, or ask for it to be built into JOSM.
     11
     12== Authentication ==
     13JOSM authenticates with [https://oauth.net/2 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.
     14
     15Basic 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.
     16
     17JOSM keeps its OAuth settings and the Access Token per server, by the host name of the API URL.
     18
     19=== OAuth metadata (RFC 8414) ===#Metadata
     20JOSM looks up the endpoints of the server in its OAuth 2.0 authorization server metadata ([https://www.rfc-editor.org/rfc/rfc8414 RFC 8414]), at
     21{{{
     22<scheme>://<host>[:<port>]/.well-known/oauth-authorization-server
     23}}}
     24where scheme, host and port are those of the **API URL**. openstreetmap-website answers this request itself, for instance:
     25{{{
     26https://www.openstreetmap.org/.well-known/oauth-authorization-server
     27}}}
     28JOSM 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.
     29
     30If 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`:
     31{{{
     32<website>/oauth2/authorize
     33<website>/oauth2/token
     34}}}
     35So 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.
     36
     37=== The OAuth 2.0 application for JOSM ===#Application
     38A 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:
     39
     40||= Setting =||= Value =||
     41|| Name || JOSM ||
     42|| Confidential application || No. JOSM is a desktop application and cannot keep a secret; it uses PKCE instead. ||
     43|| Redirect URIs || `http://127.0.0.1:8111/oauth_authorization` — JOSM receives the authorization by [wikitr:/Help/Preferences/RemoteControl Remote Control] on this address. ||
     44|| Permissions || `read_prefs`, `write_prefs`, `write_api`, `read_gpx`, `write_gpx` and `write_notes` ||
     45
     46JOSM 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.
     47
     48Then either:
     49* **publish the Client ID** for your users, who untick ''Use default settings'' in [wikitr:/Help/Preferences/Connection#AdvancedOAuthParameters Preferences > OSM Server] and enter it in the field **Client ID**; or
     50* **ask for it to be built into JOSM**, so that ''Authorize now'' works for your server without any setting: [/newticket 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.
     51
     52Without 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.
     53
     54=== Tokens obtained outside JOSM ===
     55A 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.
     56
     57== Checking the setup ==
     58 1. In JOSM, enter your API URL in [wikitr:/Help/Preferences/Connection Preferences > OSM Server] and click **Validate**.
     59 1. 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.
     60 1. Click **Authorize now**, authorize JOSM in the browser, then click **Test Access Token**: it should show your user name.
     61 1. If authorization fails, start JOSM with `--debug`: the log shows the requests JOSM makes, with credentials stripped (since r19711).
     62
     63----
     64Back to [wikitr:/Help/Preferences/Connection Preferences > OSM Server] \\
     65Back to [wikitr:/Help Main Help]