Skip to content

OpenID Connect Configuration

TiTiler-OpenEO supports OpenID Connect (OIDC) authentication following the OpenEO authentication model. The implementation supports the OpenID Connect Authorization Code Flow with PKCE.

The implementation is available in titiler/openeo/auth.py with the main class being OIDCAuth.

OpenEO Authentication Model

TiTiler-OpenEO follows the OpenEO authentication specification where tokens are provided in the format:

Bearer oidc/{provider_id}/{actual_token}

The token structure consists of three parts:

  1. Authentication method (oidc)
  2. Provider identifier: TITILER_OPENEO_AUTH_OIDC_PROVIDER_ID, oidc by default
  3. The actual OIDC token

Token parsing is handled by the AuthToken class.

Configuration

The OIDC configuration is managed through OIDCConfig in the settings. To enable OpenID Connect authentication, configure the following environment variables:

TITILER_OPENEO_AUTH_METHOD=oidc
TITILER_OPENEO_AUTH_OIDC_CLIENT_ID="your-client-id"
TITILER_OPENEO_AUTH_OIDC_WK_URL="https://your-provider/.well-known/openid-configuration"
TITILER_OPENEO_AUTH_OIDC_REDIRECT_URL="your-redirect-url"  # One URL, or several separated by spaces

Optional configuration:

TITILER_OPENEO_AUTH_OIDC_SCOPES="openid email profile"  # Space-separated list (default)
TITILER_OPENEO_AUTH_OIDC_NAME_CLAIM="name"  # Claim to use for user name (default)
TITILER_OPENEO_AUTH_OIDC_TITLE="OIDC"  # Provider title (default)
TITILER_OPENEO_AUTH_OIDC_DESCRIPTION="OpenID Connect (OIDC) Authorization Code Flow with PKCE"  # Provider description (default)
TITILER_OPENEO_AUTH_OIDC_AUDIENCES=""  # Space-separated extra accepted `aud` values
TITILER_OPENEO_AUTH_OIDC_USER_ID_CLAIM="sub"  # Claim used as User.user_id (default)
TITILER_OPENEO_AUTH_OIDC_ALLOWED_TENANTS=""  # Space-separated Entra tenant ids; empty = all
TITILER_OPENEO_AUTH_OIDC_PROVIDER_ID="oidc"  # Provider id, 1-20 letters, digits or underscores (default)
TITILER_OPENEO_AUTH_OIDC_GRANT_TYPES="authorization_code+pkce urn:ietf:params:oauth:grant-type:device_code+pkce refresh_token"  # (default)

All the values in REDIRECT_URL are advertised to openEO clients as the redirect_urls of the default client in GET /credentials/oidc. Add https://editor.openeo.org/ to let the openEO Web Editor log in with the default client. If no redirect URL matches the Web Editor, it asks the user to type a client ID.

At the provider, allow the same URLs as redirect URIs of the client, but without the trailing slash: https://editor.openeo.org. The Web Editor strips the slash from the redirect URI it sends, and a provider that compares redirect URIs exactly, as Keycloak (and so CDSE) does, otherwise refuses the login with "Invalid parameter: redirect_uri". Keep the slash in REDIRECT_URL.

PROVIDER_ID is the provider id in GET /credentials/oidc. It identifies the provider, not the protocol: use a name such as CDSE. openEO clients send it back as the middle part of the bearer token. Changing it on a running deployment breaks:

  • scripts that name the old id, as in authenticate_oidc(provider_id="oidc");
  • client settings saved for the old id, such as those of openeo-auth add-oidc, which the client then ignores;
  • open connections, which keep sending the old id and get a 403 until they connect again.

Stored refresh tokens keep working: the openEO Python client keys them on the issuer and the client ID, not on the provider id.

GRANT_TYPES lists the flows advertised for the default client. List only the flows that the client registration at the provider allows, each once. The openEO clients use the default client as follows:

  • The Python client's authenticate_oidc() uses it only when the list has refresh_token and a device code flow (urn:ietf:params:oauth:grant-type:device_code+pkce or urn:ietf:params:oauth:grant-type:device_code). Otherwise authenticate_oidc() fails with "No client_id found", even for a user who has a stored refresh token. Without the device code flow, Python users call authenticate_oidc_authorization_code() instead. It needs authorization_code+pkce in the list, and opens a browser that redirects to the client on http://localhost, so the provider must allow a http://localhost redirect URI.
  • The Web Editor uses it for authorization_code+pkce, when a REDIRECT_URL value matches the editor.

TITILER_OPENEO_AUTH_METHOD=oidc is validated at startup: the backend refuses to start if CLIENT_ID or WK_URL is unset, if PROVIDER_ID is not 1 to 20 ASCII letters, digits or underscores, or if GRANT_TYPES lists a flow twice or only refresh_token, rather than failing on the first request. It logs a warning if GRANT_TYPES lists an authorization code flow while REDIRECT_URL is empty: the openEO API requires redirect URLs for it. The OIDC settings are read only for this method: with basic, they are ignored.

The backend removes the whitespace around each value, such as the trailing newline of a Helm | block or of a Secret built from a file. A variable that is empty or holds only whitespace keeps the default.

USER_ID_CLAIM is not safe to change on a running deployment

Services, UDPs and tile assignments are all keyed on User.user_id. Changing which claim produces it orphans everything already stored.

Copernicus Data Space Ecosystem (CDSE)

Request a dedicated public client in the CDSE realm from CDSE support. Give the grant types, the redirect URIs and the web origins that your deployment needs, for example:

  • the grant types: authorization code with PKCE, device code and refresh token;
  • the redirect URI and the web origin of the Web Editor, https://editor.openeo.org, without a trailing slash (see above);
  • a http://localhost redirect URI, if Python users log in with the authorization code flow.

Then advertise exactly the grant types that CDSE enabled for the client:

TITILER_OPENEO_AUTH_METHOD=oidc
TITILER_OPENEO_AUTH_OIDC_CLIENT_ID="<your CDSE client id>"
TITILER_OPENEO_AUTH_OIDC_WK_URL="https://identity.dataspace.copernicus.eu/auth/realms/CDSE/.well-known/openid-configuration"
TITILER_OPENEO_AUTH_OIDC_REDIRECT_URL="https://editor.openeo.org/"
TITILER_OPENEO_AUTH_OIDC_GRANT_TYPES="authorization_code+pkce urn:ietf:params:oauth:grant-type:device_code+pkce refresh_token"
TITILER_OPENEO_AUTH_OIDC_PROVIDER_ID="CDSE"
TITILER_OPENEO_AUTH_OIDC_TITLE="CDSE"
TITILER_OPENEO_AUTH_OIDC_DESCRIPTION="Copernicus Data Space Ecosystem"

Do not use the shared cdse-public client. Its redirect URI allow-list can change without notice, and it does not allow the device code flow. If you must use it, set TITILER_OPENEO_AUTH_OIDC_GRANT_TYPES="authorization_code+pkce refresh_token". Python users then log in with authenticate_oidc_authorization_code(), not authenticate_oidc() (see GRANT_TYPES above).

Microsoft Entra ID

Microsoft Entra ID works with the configuration above. Select one of the two well-known URLs.

Single tenant. Only the accounts of one organization can sign in:

TITILER_OPENEO_AUTH_OIDC_WK_URL="https://login.microsoftonline.com/<tenant_id>/v2.0/.well-known/openid-configuration"

Multi-tenant (common). Work and school accounts of all organizations, and personal Microsoft accounts, can sign in:

TITILER_OPENEO_AUTH_OIDC_WK_URL="https://login.microsoftonline.com/common/v2.0/.well-known/openid-configuration"
TITILER_OPENEO_AUTH_OIDC_ALLOWED_TENANTS=""  # Empty = all tenants

The common discovery document gives an issuer template, https://login.microsoftonline.com/{tenantid}/v2.0. The backend puts the token's tid claim into the template and compares the result with the token's iss. Thus:

  • A token whose iss and tid do not agree is rejected ("Invalid issuer").
  • A v1.0 token (iss = https://sts.windows.net/<tid>/) is rejected.
  • The issuer that the JWKS gives to the signing key is also checked. Some keys in the common JWKS sign only personal-account tokens.

To limit the tenants that can sign in, set ALLOWED_TENANTS to a space-separated list of tenant ids. Personal Microsoft accounts all have the tenant id 9188040d-6c67-4c5b-b112-36a304b66dad:

# One organization, plus personal accounts
TITILER_OPENEO_AUTH_OIDC_ALLOWED_TENANTS="<tenant_id> 9188040d-6c67-4c5b-b112-36a304b66dad"

When ALLOWED_TENANTS is set, a token without a tid claim is rejected. Do not set it for a provider that is not Entra.

GET /credentials/oidc advertises the authority from WK_URL (the URL without /.well-known/openid-configuration), for example https://login.microsoftonline.com/common/v2.0. It does not advertise the discovery issuer, because clients cannot resolve the {tenantid} template. For a single-tenant or Keycloak provider, the two values are the same.

A typical configuration:

TITILER_OPENEO_AUTH_METHOD=oidc
TITILER_OPENEO_AUTH_OIDC_CLIENT_ID="<application (client) ID>"
TITILER_OPENEO_AUTH_OIDC_WK_URL="https://login.microsoftonline.com/common/v2.0/.well-known/openid-configuration"
TITILER_OPENEO_AUTH_OIDC_REDIRECT_URL="https://editor.openeo.org/ http://localhost:8080/"
TITILER_OPENEO_AUTH_OIDC_NAME_CLAIM="preferred_username"
TITILER_OPENEO_AUTH_OIDC_TITLE="Microsoft Entra ID"

For the multi-tenant case, the app registration must have Supported account types = Accounts in any organizational directory and personal Microsoft accounts ("signInAudience": "AzureADandPersonalMicrosoftAccount"). If the app registration is single-tenant, Entra refuses the common sign-in with "AADSTS50059: No tenant-identifying information found", before the backend is involved.

Expose an API scope, and mint the token out-of-band

openEO clients send the access token, never the ID token. With only openid profile email requested, Entra issues an access token audienced at Microsoft Graph, and those cannot be validated by anyone but Graph: they carry a nonce in the JWT header and their signature will not verify against the tenant's published JWKS. The symptom is a 403 TokenInvalid with "Token signature verification failed".

Entra must therefore issue a token audienced at this backend:

  1. App registration → Expose an API → Set the Application ID URI → accept the default api://<client_id>.
  2. Add a scope, e.g. openeo, with admin and user consent enabled.
  3. Manifest → set "requestedAccessTokenVersion": 2. Without this Entra issues a v1 access token whose iss is https://sts.windows.net/<tenant>/, which will not match the v2 discovery document's issuer and fails the iss check with "Invalid issuer".
TITILER_OPENEO_AUTH_OIDC_AUDIENCES="api://<client_id>"

The openEO Python client before 0.52 drops this scope

openeo before 0.52.0 intersects the scopes a backend advertises with the provider's own scopes_supported (openeo/rest/auth/oidc.py, OidcProviderInfo.__init__): {"openid"}.union(scopes).intersection(self._supported_scopes). Microsoft Entra advertises a fixed ["openid", "profile", "email", "offline_access"] — static platform metadata that by construction never lists an app's custom API scopes — so api://<client_id>/openeo is silently dropped and Entra falls back to a Graph-audienced token. scopes_supported is RECOMMENDED and informational per RFC 8414, so this client-side filtering is arguably too strict. Microsoft has confirmed that Entra will never advertise custom scopes, so this cannot be fixed from the provider side.

openeo 0.52.0 fixes this (openeo-python-client#930): it no longer drops requested scopes. With openeo>=0.52, no patch is necessary, and authenticate_oidc() (device code flow) works with work and personal accounts.

For an older client, undo the intersection with the helper this project ships. Call it once, before connecting — from any notebook or script:

from titiler.openeo.client_compat import patch_openeo_client_scopes

patch_openeo_client_scopes()

import openeo
connection = openeo.connect("http://127.0.0.1:8083/").authenticate_oidc()

The call is idempotent, so re-running a cell is harmless, and importing the module patches nothing on its own. _scopes is computed once in OidcProviderInfo.__init__, so this covers every flow — authorization code, device code and refresh token all read it through get_scopes_string.

With it in place TITILER_OPENEO_AUTH_OIDC_SCOPES works as documented and the ordinary authenticate_oidc() flow succeeds, keeping refresh-token caching. Patch at runtime rather than editing the installed package — uv sync reverts a site-packages edit.

The upstream report is drafted at docs/adr/upstream/openeo-python-client-scope-intersection.md; drop the helper once a release carrying a fix is the minimum this project supports.

If you would rather not patch a third-party class, mint the token out-of-band with MSAL and hand it over with authenticate_oidc_access_token() (openeo >= 0.31); this also needs no redirect URI:

import msal, openeo

TENANT, CLIENT_ID = "<tenant_id>", "<client_id>"
app = msal.PublicClientApplication(
    CLIENT_ID, authority=f"https://login.microsoftonline.com/{TENANT}"
)
flow = app.initiate_device_flow(scopes=[f"api://{CLIENT_ID}/openeo"])
print(flow["message"])          # sign in at microsoft.com/devicelogin
token = app.acquire_token_by_device_flow(flow)["access_token"]

connection = openeo.connect("http://127.0.0.1:8083/").authenticate_oidc_access_token(token)

In the Entra app registration:

  • Register a public client; both grants openEO clients use — authorization code with PKCE, and device code — are supported.
  • Add your openEO client's redirect URL (the Web Editor's is its own origin). For a browser client such as the Web Editor, add it on the Single-page application platform, not on Web or Mobile and desktop applications. Otherwise Entra refuses the token request with "AADSTS9002326: Cross-origin token redemption is permitted only for the 'Single-Page Application' client-type". Keep Allow public client flows on for the device code flow. Also list the URL in TITILER_OPENEO_AUTH_OIDC_REDIRECT_URL.
  • If your clients present access tokens audienced at your own API rather than ID tokens, add that audience: TITILER_OPENEO_AUTH_OIDC_AUDIENCES="api://<client_id>".

Entra's sub is pairwise: stable for a given user in a given app registration, and different if you re-register the app. If you expect to re-register, consider pinning identity to the tenant-stable object id with TITILER_OPENEO_AUTH_OIDC_USER_ID_CLAIM="oid" — but decide before going live, per the warning above.

With the multi-tenant common URL, keep the default sub. An oid is unique only in its tenant, so two users of different tenants can have the same oid.

For asset access on Microsoft Planetary Computer, see Microsoft Planetary Computer. Note that Entra identifies your users; it does not change what they can read there.

GET /credentials/oidc returns 404

That is expected when the backend is not configured for OIDC. openEO backends advertise only the authentication method they actually support, so /credentials/oidc and /credentials/basic are mutually exclusive — the one that does not apply is never registered:

TITILER_OPENEO_AUTH_METHOD Registered route
basic (default) /credentials/basic
oidc /credentials/oidc

Set TITILER_OPENEO_AUTH_METHOD=oidc together with CLIENT_ID and WK_URL. If any of those are missing the backend now refuses to start and names the variable, rather than starting and failing on the first request.

Token Validation

Validation is performed in the _verify_token and _verify_claims methods:

  1. The header's alg must be RS256, the only algorithm this backend verifies.
  2. The signature is verified against the provider's JWKS. If the token's key id is not in the cached key set, the JWKS is refetched once — providers rotate signing keys continuously, and Entra publishes six at a time.
  3. iss must match the discovery document's issuer. If the issuer is an Entra template ({tenantid}), the token's tid is put into it first. If the JWKS gives an issuer to the signing key, iss must match it too. If ALLOWED_TENANTS is set, tid must be in it.
  4. aud must contain the client ID or one of the configured AUDIENCES, or azp must equal one of them.
  5. exp is required, and checked with 60 seconds of clock-skew allowance. nbf is checked when present.

A token that fails any of these checks, or cannot be parsed, gets 403 with the openEO error code TokenInvalid, as the openEO API specifies. On that answer the openEO Python client (0.13.0 and later) refreshes the access token and retries. If the provider cannot be reached, the answer is 503 instead: a new token would not help.

The discovery document is cached for an hour rather than for the life of the process, so a provider that moves its jwks_uri does not break a running deployment permanently.

User Information

Upon successful validation, a User object is created with:

  • user_id: the claim named by USER_ID_CLAIM (defaults to sub)
  • email: Email claim if available
  • name: Value from the configured name claim (defaults to "name")

Security Considerations

  • Keep your client ID secure
  • Configure appropriate token expiration times
  • Use HTTPS in production
  • Review and limit the requested scopes
  • Regularly rotate any client secrets if used

For more details on the implementation, see the auth module source code.