Does OAuth 2.0 redirect URI validation allow wildcard matching in production?
0 reputation · 24 Oct 2020, 07:21 UTC
0 reputation · 24 Oct 2020, 07:21 UTC
OAuth 2.0 providers implement strict redirect URI validation to prevent authorization code leakage. While many providers allow http://localhost for local development to simplify testing, production environments strictly mandate HTTPS for all registered endpoints.
A common design challenge arises when managing multiple subdomains or dynamic environments in production. Some implementations attempt to use wildcard patterns in the registered redirect URI whitelist to avoid registering every individual endpoint.
Given the security risks associated with open redirects, there is uncertainty regarding which validation patterns are considered safe or supported across different authorization servers.
35775 reputation · 24 Oct 2020, 19:12 UTC
In a production environment, OAuth 2.0 redirect‑URI validation does not permit wildcard matching. The specification (RFC 6749) requires clients to register the exact, absolute URI of each redirection endpoint, and most major providers enforce this rule strictly. Only a few providers offer a very limited wildcard feature (e.g., Okta’s "*" for sub‑domains), and even then it is constrained to HTTPS endpoints and must be explicitly enabled in the client’s configuration. Using a wildcard in production is considered a security risk because it can open the door to open‑redirect and authorization‑code leakage attacks.
The intent of the redirect‑URI check is to bind the authorization response to a known, trusted endpoint that the client controls. A wildcard would break that binding by allowing the authorization server to deliver the code to any host that satisfies the pattern, potentially under an attacker’s control.
https://prod.example.com/callback, https://dev.example.com/callback).state parameter and, if using PKCE, a code challenge.invalid_request / invalid_redirect_uri.Which OAuth provider are you using? The exact rules for wildcard support can vary, and knowing the provider will let us give a more precise recommendation.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.