OIDC Discovery: find and validate an OpenID Provider’s configuration
Learn the two discovery steps, construct the correct metadata URL for an issuer with a path, and validate issuer, TLS, endpoints, and optional WebFinger lookup safely.
OIDC Discovery: find and validate an OpenID Provider’s configuration
OpenID Connect (OIDC) Discovery lets a relying party (RP) find an OpenID Provider’s (OP’s) login and token endpoints, signing keys, and supported features from an issuer. Discovery reduces hard-coded configuration, but the returned document is not trusted automatically. Validate TLS and require the metadata issuer to exactly match the issuer used to retrieve it.
Two discovery steps
Issuer discovery finds an OP issuer from a user identifier. An RP can skip this step when its issuer is already configured or associated with a registered account. A service that accepts a user-entered email or URL may use WebFinger to discover an issuer.
Provider configuration discovery retrieves JSON metadata from a known issuer by appending /.well-known/openid-configuration. Metadata can list authorization_endpoint, token_endpoint, jwks_uri, supported scopes and response types, and ID Token signing algorithms.
Build the configuration URL
For issuer https://login.example, retrieve https://login.example/.well-known/openid-configuration. If the issuer contains a path, keep that path and remove its trailing slash before appending the well-known path:
issuer: https://login.example/tenant-a
metadata: https://login.example/tenant-a/.well-known/openid-configurationThis is the OIDC Discovery rule. OAuth Authorization Server Metadata (RFC 8414) has a different rule for issuer paths; do not mix the two URL patterns.
Validate metadata before using it
**Establish the issuer source.** Prefer an issuer from registration or trusted configuration. If user input drives lookup, implement the specified identifier normalization and WebFinger flow. Server-side WebFinger requests can create SSRF risk: require HTTPS, restrict ports and public destinations, inspect IPv4/IPv6 results, and prevent DNS rebinding by connecting to the address that was checked. Restrict network egress. OIDC Discovery permits redirects in WebFinger, so recheck every redirect destination and bound redirect hops, time, and response size. If these controls cannot be enforced, do not offer user-driven automatic discovery.
**Construct the OIDC URL** using the issuer path and trailing-slash rule above.
**Validate TLS.** Check the certificate when retrieving metadata. Never bypass certificate errors; an attacker could substitute endpoints or keys.
**Check the response.** Expect HTTP 200, `application/json`, and valid Discovery metadata. Stop dependent operations if required fields are missing or malformed.
**Compare issuer values exactly.** Metadata `issuer` must match the issuer used for lookup, and the ID Token’s `iss` must match that same issuer. Do not normalize away a trailing slash or ignore case.
**Apply endpoint and capability policy.** Use the advertised endpoints and confirm required response types, scopes, and signing algorithms. `claims_supported` lists claims the OP may provide; it does not promise every claim in every response.
**Manage updates.** Define metadata and key-cache refresh behavior. Do not keep old endpoints or arbitrary keys indefinitely to get around validation failures.
For an illustrative input alice@example.org, WebFinger may use resource acct:alice@example.org at host example.org to find the OIDC issuer relation. The returned issuer can differ from the email’s domain. Validate the returned HTTPS issuer and its provider configuration; do not assume the host must match. If automatic discovery is unnecessary, restrict users to registered providers or administrator-configured issuers.
OIDC Discovery versus OAuth metadata
RFC 8414 publishes OAuth authorization-server endpoints and capabilities. OIDC Discovery builds on that model and adds OIDC-specific configuration such as the UserInfo endpoint, subject types, ID Token algorithms, and WebFinger issuer discovery. An OP may support both standards, but their URL rules and required fields are not interchangeable.
Troubleshooting
**404 or JSON parse error:** recheck issuer scheme, path, trailing slash, and documented Discovery support; do not guess an endpoint.
**Issuer mismatch:** check tenant, test/production environment, proxy path, and slash configuration. Do not use the metadata or ID Token until resolved.
**TLS error:** check the certificate chain, hostname, system clock, and trust store; do not disable validation.
**Endpoint changed:** confirm an approved issuer change, then update cache refresh and RP allowlist policy together.
References
[OpenID Connect Discovery 1.0, errata set 2](https://openid.net/specs/openid-connect-discovery-1_0.html)
[RFC 8414 — OAuth 2.0 Authorization Server Metadata](https://www.rfc-editor.org/rfc/rfc8414.html)
[RFC 7033 — WebFinger](https://www.rfc-editor.org/rfc/rfc7033.html)
[OpenID Connect Core 1.0, errata set 2](https://openid.net/specs/openid-connect-core-1_0.html)