Before Switching Identity Providers, Check Your OIDC Issuer and Discovery URLs

Troubleshoot an OIDC issuer URL mismatch by comparing application settings and discovery metadata before switching identity providers.

Published
Reading time
6 min read
Before Switching Identity Providers, Check Your OIDC Issuer and Discovery URLs
On this page

An OIDC issuer URL mismatch can stop authentication during an identity provider migration, even when the discovery endpoint responds successfully. The application must agree with the provider about which issuer it trusts—not just which URL is reachable.

This guide explains the URLs to compare and provides a diagnostic workflow that does not expose client secrets or tokens. The OpenID Connect Discovery specification was not available for consultation while preparing this article, so confirm the URL construction and validation requirements against the specification, your provider’s documentation, and your OIDC library before making migration changes.

Key Takeaways

  • Compare the application’s effective configured issuer with the issuer string in the discovery document. Treat differences in hostname, path, and trailing slash as significant.
  • The discovery document URL is a location for retrieving metadata; it is not necessarily the issuer itself.
  • Check the identity token’s iss claim as part of normal OIDC validation, but never bypass signature or issuer validation to make a migration work.
  • An HTTP status check alone cannot validate discovery JSON, signing keys, or an authentication flow.

How the issuer and discovery URLs relate

An application typically starts with a trusted issuer identifier or a discovery URL configured for its OIDC library. The discovery document supplies provider metadata, including an issuer value and endpoint locations. During authentication, the application also validates the iss claim in the identity token against the expected issuer.

For example, a fictional provider might use these values:

PurposeExample
Configured issuerhttps://id.example.com/tenant-a
Discovery document URLhttps://id.example.com/tenant-a/.well-known/openid-configuration
Discovery document issuerhttps://id.example.com/tenant-a

The configured issuer and the document’s issuer must match exactly. The discovery URL includes the well-known suffix and is not itself the issuer. If the provider gives you a discovery URL, check that it is the OIDC discovery URL for the intended tenant; do not assume every well-known URL follows the same path convention.

A trailing slash can be particularly confusing: constructing a discovery URL may involve removing a terminating slash before appending the well-known path, but that does not make two different issuer strings interchangeable. Use the provider’s exact issuer value in the application.

Advertisement

Diagnose an OIDC issuer URL mismatch

First, obtain the issuer and discovery URL intended for the new provider and tenant. Then identify the values actually loaded by the application in the affected environment. A deployment configuration, environment variable, secret-management system, or library-specific setting may override what is in the repository.

The following diagnostic uses curl and jq. Replace the fictional values with your provider’s public metadata URL and expected issuer. Run it only against an endpoint you are authorized to inspect. It does not require a client secret or token. The example has not been executed here.

#!/usr/bin/env bash
set -eu

EXPECTED_ISSUER='https://id.example.com/tenant-a'
DISCOVERY_URL='https://id.example.com/tenant-a/.well-known/openid-configuration'

metadata_file=$(mktemp)
trap 'rm -f "$metadata_file"' EXIT

if ! status=$(curl -sS --max-time 10 \
  -o "$metadata_file" -w '%{http_code}' -- "$DISCOVERY_URL"); then
  printf 'Could not retrieve discovery metadata.\n' >&2
  exit 1
fi

if [ "$status" != '200' ]; then
  printf 'Discovery endpoint returned HTTP %s; expected 200.\n' "$status" >&2
  exit 1
fi

if ! actual_issuer=$(jq -er '.issuer | select(type == "string" and length > 0)' "$metadata_file"); then
  printf 'Response is not usable discovery JSON with a non-empty issuer.\n' >&2
  exit 1
fi

printf 'Configured issuer: %s\n' "$EXPECTED_ISSUER"
printf 'Document issuer:   %s\n' "$actual_issuer"

if [ "$EXPECTED_ISSUER" != "$actual_issuer" ]; then
  printf 'Issuer mismatch. Check the effective application configuration.\n' >&2
  exit 1
fi

printf 'Issuer strings match; further OIDC validation is still required.\n'

This script deliberately does not follow redirects. A 3xx response should prompt you to check the provider’s documented endpoint and your library’s redirect behavior rather than silently treating the response as discovery metadata. A 200 response containing an HTML login page or invalid JSON will fail the jq check.

If the strings match, inspect the discovery document’s endpoint and key-set locations against the provider’s documentation and test a complete sign-in in a controlled environment. A matching issuer alone does not prove that the metadata, keys, token validation, or callback configuration is correct.

Advertisement

Migration issues to investigate

Trailing slash or path difference

https://id.example.com/tenant-a and https://id.example.com/tenant-a/ are different issuer strings. Copy the issuer from the intended provider’s authoritative configuration and update the application accordingly. Do not independently trim slashes from the issuer to make a comparison pass.

Hostname change

A move from an old identity hostname to a new one can change the issuer even when both hosts serve the same organization. Confirm which hostname the new provider uses in its discovery document and issued tokens. An alias or redirect being reachable does not establish that it is the issuer your application should trust.

Incorrect well-known path

A tenant or realm path may be part of the issuer. Fetching a discovery document from the host root instead of the intended tenant path can return metadata for a different issuer—or a response that is not OIDC metadata at all. Use the provider’s documented OIDC discovery URL and compare its issuer with the application’s configured value.

Stale environment or cached configuration

A changed configuration file may not be the value used by a running instance. Check deployment variables and overrides in each environment, restart or refresh components as required by your platform, and account for any discovery or key caches in your OIDC library. During a rollout, verify that all instances received the intended configuration.

Existing sessions and tokens issued by the old provider may also behave differently after the switch. Plan how they will expire or be handled, and test rollback rather than assuming that changing the issuer preserves existing authentication.

What an HTTP status check can—and cannot—tell you

An HTTP status check is useful for detecting an unreachable endpoint or an unexpected status such as a redirect or server error. It does not establish that the response is valid discovery JSON, that its issuer is correct, or that the advertised signing keys can validate a token. It also cannot prove that authorization, callback handling, and token validation work end to end.

Keep secrets and tokens out of status-check URLs, examples, screenshots, and logs. Discovery metadata is typically public, but application configuration and authentication responses may contain sensitive information.

Common Mistakes

  • Comparing the configured issuer with the discovery URL instead of the document’s issuer value.
  • Assuming a successful HTTP response means the response came from the intended tenant or contains valid metadata.
  • Treating hostname or trailing-slash differences as harmless normalization.
  • Updating a local setting while a production environment override still points to the old provider.
  • Disabling issuer or signature validation to get past an error.

Best Practices

  • Record the intended issuer and discovery URL for each environment, and verify the effective settings during deployment.
  • Test the new provider with a controlled sign-in before switching traffic. Ensure the OIDC library validates the token’s signature and relevant claims, including issuer and audience.
  • Review the advertised endpoints and signing-key location; use trusted provider configuration rather than accepting arbitrary discovery URLs from users.
  • Plan for key rotation, cache refresh, existing sessions, and rollback according to the provider and library in use.
  • If a server fetches configurable metadata URLs, restrict destinations and outbound network access. Parsing a URL or checking its hostname alone is not a complete defense against server-side request forgery.

Conclusion

Before switching providers, compare the application’s effective issuer with the discovery document’s exact issuer value, then test the full authentication flow. Reachability is a useful first check, but it is not proof that the new provider is correctly configured or trusted.

What would your domain sell for?

A free TidyURLs account unlocks the Domain Estimator. It prices a name from 191,011 real domain sales.