Interface HostnameProvider

  • All Superinterfaces:
    Provider
    All Known Implementing Classes:
    DefaultHostnameProvider, FixedHostnameProvider, RequestHostnameProvider

    public interface HostnameProvider
    extends Provider
    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

      All Methods Instance Methods Default Methods 
      Modifier and Type Method Description
      default void close()  
      default String getContextPath​(javax.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​(javax.ws.rs.core.UriInfo originalUriInfo, UrlType type)
      Returns the context-path for Keycloak.
      default String getHostname​(javax.ws.rs.core.UriInfo originalUriInfo)
      Returns the host.
      default String getHostname​(javax.ws.rs.core.UriInfo originalUriInfo, UrlType type)
      Returns the host.
      default int getPort​(javax.ws.rs.core.UriInfo originalUriInfo)
      Returns the port (or -1 for default port).
      default int getPort​(javax.ws.rs.core.UriInfo originalUriInfo, UrlType type)
      Returns the port (or -1 for default port).
      default String getScheme​(javax.ws.rs.core.UriInfo originalUriInfo)
      Returns the URL scheme.
      default String getScheme​(javax.ws.rs.core.UriInfo originalUriInfo, UrlType type)
      Returns the URL scheme.
    • Method Detail

      • getScheme

        default String getScheme​(javax.ws.rs.core.UriInfo originalUriInfo,
                                 UrlType type)
        Returns the URL scheme. If not implemented will delegate to getScheme(UriInfo).
        Parameters:
        originalUriInfo - the original URI
        type - type of the request
        Returns:
        the schema
      • getScheme

        default String getScheme​(javax.ws.rs.core.UriInfo originalUriInfo)
        Returns the URL scheme. If not implemented will get the scheme from the request.
        Parameters:
        originalUriInfo - the original URI
        Returns:
        the schema
      • getHostname

        default String getHostname​(javax.ws.rs.core.UriInfo originalUriInfo,
                                   UrlType type)
        Returns the host. If not implemented will delegate to getHostname(UriInfo).
        Parameters:
        originalUriInfo - the original URI
        type - type of the request
        Returns:
        the host
      • getHostname

        default String getHostname​(javax.ws.rs.core.UriInfo originalUriInfo)
        Returns the host. If not implemented will get the host from the request.
        Parameters:
        originalUriInfo -
        Returns:
        the host
      • getPort

        default int getPort​(javax.ws.rs.core.UriInfo originalUriInfo,
                            UrlType type)
        Returns the port (or -1 for default port). If not implemented will delegate to getPort(UriInfo)
        Parameters:
        originalUriInfo - the original URI
        type - type of the request
        Returns:
        the port
      • getPort

        default int getPort​(javax.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

        default String getContextPath​(javax.ws.rs.core.UriInfo originalUriInfo,
                                      UrlType type)
        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 to getContextPath(UriInfo)
        Parameters:
        originalUriInfo - the original URI
        type - type of the request
        Returns:
        the context-path
      • getContextPath

        default String getContextPath​(javax.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. 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()
        Specified by:
        close in interface Provider