Redirects
What Is a Redirect?
Redirect URIs are a required configuration for standard OpenID Connect (OIDC) redirect‑based authentication using the Authorization Code Flow. In OIDC and OAuth 2.0 terms, redirect URIs define where the authorization server is allowed to send users after successful authentication.
Why Redirect URIs Matter?
It is important to register redirect URIs as precisely and narrowly as possible. Overly permissive redirect settings can allow malicious actors to intercept authorization codes or tokens and gain unauthorized access to user data.
For additional background, see the Keycloak documentation.
Mininum Redirect Requirements
- At least one redirect URI is required for each environment: DEV, TEST, and PROD.
- If the exact redirect URI is not yet known for an environment, you may temporarily supply a placeholder and update it later.
- Suggested placeholder: 'http://localhost:1000'
- For local development,
localhostredirect URIs can be used, e.g.http://localhost:3000/*
Wildcards and Web Origins
- Wildcards (
*) may be used only at the end of a redirect URI path, for example:http://host.com/* - Redirect URIs are automatically copied into the Keycloak Web Origins configuration.
Valid Redirect URI Format
Redirect URIs are commonly used in a http(s) scheme (http(s)://) or custom scheme (scheme://path). The allowed URI syntax consists of:
Scheme- Must be greater than one character.
- Must start with an alphabet character followed by optional characters (
alphabets,hyphens(-), andperiods(.)).
Path- Must contain at least one character.
- Must not include
white spacesor#.
- Wildcard (
*) Rules by Scheme:-
HTTP(S) scheme (
http(s)://):- Wildcards may be used only in the path, not in the domain or subdomain.
- Examples:
- ✅
https://www.example.com/path*orhttps://www.example.com/path/* - ❌
https://www.example*.com
- ✅
- Examples:
- Wildcard (*) is allowed in Dev and Test environments to support various development workflows.
- Wildcard (*) is not allowed in Prod environments.
- Wildcards may be used only in the path, not in the domain or subdomain.
-
Custom schemes (
scheme://path):- If an application client is using non http(s) custom schemes, the custom schemes must be explicitly allowed in the redirect URI pattern.
- Supported examples include:
custom:/test,custom:/test/,custom:, orcustom:/test/*. - For security reasons, a general wildcard (
*) is no longer supported by keycloak. See details here.
-
Notes on Environment Exceptions
To support development workflows, wildcard (*) usage is permitted in DEV and TEST environments only. PROD configurations should always use explicit, tightly scoped redirect URIs.