Skip to content

feat(db): allow overriding OIDC scopes via OIDC_SCOPES - #1027

Open
mfuhrmann wants to merge 3 commits into
open-wanderer:devfrom
osm-fulda:fix/osm-oidc-username
Open

feat(db): allow overriding OIDC scopes via OIDC_SCOPES#1027
mfuhrmann wants to merge 3 commits into
open-wanderer:devfrom
osm-fulda:fix/osm-oidc-username

Conversation

@mfuhrmann

@mfuhrmann mfuhrmann commented May 29, 2026

Copy link
Copy Markdown

What changed

Adds an OIDC_SCOPES environment variable for the db service. When set, it replaces the scopes requested by the oidc, oidc2 and oidc3 providers with a comma-separated list. When unset, the PocketBase defaults are used, so existing installations are unaffected.

Why

wanderer requests openid, profile and email from every OIDC provider. Some providers reject an authorization request that carries scopes they do not recognise, rather than ignoring the unknown ones — the login then fails before the user ever reaches the consent screen.

OpenStreetMap is such a provider: it accepts neither profile nor email, which makes it unusable as an OIDC provider today. With OIDC_SCOPES: "openid,read_prefs" it works.

PocketBase itself offers no way to configure this. core.OAuth2ProviderConfig (v0.38.0) exposes PKCE, the endpoint URLs, client credentials, display name and an Extra map, but no scope field — scopes come from the provider factory in tools/auth, which is why this is an override of the factory rather than a settings change.

How it was tested

  • db/main_test.go covers the unset case, a single scope, a comma-separated list, surrounding whitespace, empty entries, and a separators-only value. The last two fall back to the provider defaults.
  • Running against a live OpenStreetMap OIDC app on a self-hosted instance: login fails without the variable and succeeds with openid,read_prefs.

Notes

Whitespace around entries is trimmed and empty entries are dropped, so "openid, read_prefs" behaves as expected.

The scope list applies to all three OIDC provider slots. Configuring them separately would mean three variables; that seemed like the wrong trade until someone actually needs two different OIDC providers with two different non-default scope sets.

This PR previously also mapped the OAuth2 username from preferred_username. That has been split out — testing showed it needs sanitising against the username field pattern before it is safe, since OSM display names may contain spaces and other characters the field rejects. It will follow as a separate PR.

Addresses root cause 1 of #1026. Root cause 2 (the discarded display name) is left for a separate PR.

@Flomp
Flomp changed the base branch from main to dev August 7, 2026 17:12
wanderer requests openid, profile and email from every OIDC provider.
Some providers reject an authorization request carrying scopes they do
not know rather than ignoring them, so login fails before the consent
screen is shown. OpenStreetMap accepts neither profile nor email and is
therefore unusable as an OIDC provider today.

Setting OIDC_SCOPES to a comma separated list replaces the scopes for
the oidc, oidc2 and oidc3 providers. When unset, the PocketBase defaults
are kept.
@mfuhrmann
mfuhrmann force-pushed the fix/osm-oidc-username branch from 76680f9 to fb1447a Compare August 10, 2026 11:05
@mfuhrmann mfuhrmann changed the title Set OAuth2 username from preferred_username and add OIDC_SCOPES env var feat(db): allow overriding OIDC scopes via OIDC_SCOPES Aug 10, 2026
@mfuhrmann

Copy link
Copy Markdown
Author

@Flomp I rebased #1027 onto dev. The conflict is resolved and this PR now covers only the OIDC_SCOPES change. The username half is split into #1159. Both address #1026.

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.

1 participant