Package org.keycloak.urls
Interface HostnameProvider
- All Superinterfaces:
Provider
- All Known Implementing Classes:
HostnameV2Provider
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 voidclose()default StringgetContextPath(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 StringgetContextPath(jakarta.ws.rs.core.UriInfo originalUriInfo, UrlType type) Returns the context-path for Keycloak.default StringgetHostname(jakarta.ws.rs.core.UriInfo originalUriInfo) Returns the host.default StringgetHostname(jakarta.ws.rs.core.UriInfo originalUriInfo, UrlType type) Returns the host.default intgetPort(jakarta.ws.rs.core.UriInfo originalUriInfo) Returns the port (or -1 for default port).default intReturns the port (or -1 for default port).default StringgetScheme(jakarta.ws.rs.core.UriInfo originalUriInfo) Returns the URL scheme.default StringReturns 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()
-