Details
-
Feature Request
-
Resolution: Done
-
Major
-
None
-
None
-
None
-
NEW
-
NEW
Description
Keycloak needs to know its public URL for a number of reasons. For example in the OIDC well-known endpoint, issuer in tokens and emails sent to users.
At the moment we retrieve this from the request headers and have documented how to block requests with invalid URLs (https://www.keycloak.org/docs/latest/server_admin/index.html#host). The latter is important in production installations.
There's two problems with the current approach:
1) Clients in the same subnet can't use internal IP to communicate with Keycloak
2) Configuring the valid URLs is an important step to secure a production installation, but the current approach is probably not well known and is rather messy to configure
I propose we introduce an Hostname SPI to allow a flexible way to determine the base URL. We would add two implementations OOTB:
1) Request - this would be set as the default-provider and would determine the base url from request headers as we do today
2) Fixed - this would allow setting a hardcoded public URL
In standalone.xml it would look like this:
<spi name="baseURL"> <default-provider>request</default-provider> <provider name="fixed"> <properties> <property name="hostname" value="localhost"/> <property name="httpPort" value="-1"/> <property name="httpsPort" value="-1"/> </properties> </provider> </spi>
For production the default-provider should be changed to fixed and the hostname value should be changed. This can be handled either through manual editing standalone.xml or with jboss-cli. If allowRealmOverride is set to true it should be possible to configure a base url for a realm that will override the global base url.
Once this is incorporated it will make it easy to add support for backchannel URL back to the adapters to allow adapters to use internal IP address when communicating with Keycloak.
Implementation shouldn't be hard. It's mainly about making sure that UriInfo is retrieved from KeycloakSession#KeycloakContext and not injected directly.
If anyone has more complex requirements for determining the public URL they can implement their own provider to handle it.
Attachments
Issue Links
- causes
-
KEYCLOAK-7989 Running server config migration fails due the Hostname SPI
-
- Closed
-
-
KEYCLOAK-8310 Fixed Hostname provider SPI doesn't support URL schema
-
- Closed
-
- incorporates
-
KEYCLOAK-7874 Allow invoking token introspection and review endpoints through a different URL
-
- Closed
-
- relates to
-
KEYCLOAK-6073 Add support for OpenID Connect Discovery to Java adapters
-
- Closed
-
-
KEYCLOAK-7731 KeycloakUriBuilder removes well known ports (80 / 443) even if the issuer url in the token includes it
-
- Closed
-