Package org.keycloak.urls
Interface HostnameProvider
- All Superinterfaces:
Provider
- All Known Implementing Classes:
DefaultHostnameProvider
,FixedHostnameProvider
,RequestHostnameProvider
The Hostname provider is used by Keycloak to decide URLs for frontend and backend requests. A provider can either
base the URL on the request (Host header for example) or based on hard-coded URLs. Further, it is possible to have
different URLs on frontend requests and backend requests.
Note: Do NOT use
KeycloakContext.getUri()
within a Hostname provider. It will result in an infinite loop.-
Method Summary
Modifier and TypeMethodDescriptiondefault void
close()
default String
getContextPath
(jakarta.ws.rs.core.UriInfo originalUriInfo) Returns the context-path for Keycloak This is useful when Keycloak is exposed on a different context-path on a reverse proxy.default String
getContextPath
(jakarta.ws.rs.core.UriInfo originalUriInfo, UrlType type) Returns the context-path for Keycloak.default String
getHostname
(jakarta.ws.rs.core.UriInfo originalUriInfo) Returns the host.default String
getHostname
(jakarta.ws.rs.core.UriInfo originalUriInfo, UrlType type) Returns the host.default int
getPort
(jakarta.ws.rs.core.UriInfo originalUriInfo) Returns the port (or -1 for default port).default int
Returns the port (or -1 for default port).default String
getScheme
(jakarta.ws.rs.core.UriInfo originalUriInfo) Returns the URL scheme.default String
Returns the URL scheme.
-
Method Details
-
getScheme
Returns the URL scheme. If not implemented will delegate togetScheme(UriInfo)
.- Parameters:
originalUriInfo
- the original URItype
- type of the request- Returns:
- the schema
-
getScheme
Returns the URL scheme. If not implemented will get the scheme from the request.- Parameters:
originalUriInfo
- the original URI- Returns:
- the schema
-
getHostname
Returns the host. If not implemented will delegate togetHostname(UriInfo)
.- Parameters:
originalUriInfo
- the original URItype
- type of the request- Returns:
- the host
-
getHostname
Returns the host. If not implemented will get the host from the request.- Parameters:
originalUriInfo
-- Returns:
- the host
-
getPort
Returns the port (or -1 for default port). If not implemented will delegate togetPort(UriInfo)
- Parameters:
originalUriInfo
- the original URItype
- type of the request- Returns:
- the port
-
getPort
default int getPort(jakarta.ws.rs.core.UriInfo originalUriInfo) Returns the port (or -1 for default port). If not implemented will get the port from the request.- Parameters:
originalUriInfo
- the original URI- Returns:
- the port
-
getContextPath
Returns the context-path for Keycloak. This is useful when Keycloak is exposed on a different context-path on a reverse proxy. If not implemented will delegate togetContextPath(UriInfo)
- Parameters:
originalUriInfo
- the original URItype
- type of the request- Returns:
- the context-path
-
getContextPath
Returns the context-path for Keycloak This is useful when Keycloak is exposed on a different context-path on a reverse proxy. If not implemented will use the context-path from the request, which by default is /auth- Parameters:
originalUriInfo
- the original URI- Returns:
- the context-path
-
close
default void close()
-