Class KeycloakIdentityProvider
java.lang.Object
org.openremote.container.security.keycloak.KeycloakIdentityProvider
- All Implemented Interfaces:
IdentityProvider
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
protected io.undertow.server.HttpHandler
protected org.jboss.resteasy.client.jaxrs.ResteasyClient
static final String
static final int
static final String
static final int
static final String
static final int
protected org.keycloak.adapters.KeycloakConfigResolver
protected com.google.common.cache.LoadingCache<KeycloakRealmClient,
org.keycloak.adapters.KeycloakDeployment> protected jakarta.ws.rs.core.UriBuilder
protected org.jboss.resteasy.client.jaxrs.ResteasyWebTarget
protected final org.keycloak.adapters.KeycloakDeployment
protected org.openremote.model.auth.OAuthGrant
static final String
static final int
static final String
static final int
static final String
static final String
static final String
static final String
static final String
static final int
protected ConcurrentLinkedQueue<org.keycloak.admin.client.resource.RealmsResource>
protected int
protected int
protected int
Fields inherited from interface org.openremote.container.security.IdentityProvider
OR_ADMIN_PASSWORD, OR_ADMIN_PASSWORD_DEFAULT
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
The suppliedOAuthGrant
will be used to authenticate with keycloak so we can programmatically make changes. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract void
addClientRedirectUris
(String client, List<String> redirectUrls, boolean devMode) There must be _some_ valid redirect URIs for the application or authentication will not be possible.protected com.google.common.cache.LoadingCache<KeycloakRealmClient,
org.keycloak.adapters.KeycloakDeployment> protected void
enableAuthProxy
(WebService webService, String keycloakPath) protected abstract org.openremote.model.auth.OAuthGrant
generateStoredCredentials
(org.openremote.model.Container container) Generate and store credentials for connecting to the Keycloak admin APIgetAccessTokenSupplier
(org.openremote.model.auth.OAuthGrant grant) Convenience method for generating access tokens from a given OAuth compliant serverorg.openremote.model.auth.OAuthPasswordGrant
getDefaultKeycloakGrant
(org.openremote.model.Container container) org.keycloak.adapters.KeycloakDeployment
getKeycloakDeployment
(String realm, String clientId) final <T> T
static org.keycloak.KeycloakSecurityContext
getSecurityContext
(Subject subject) protected abstract org.openremote.model.auth.OAuthGrant
getStoredCredentials
(org.openremote.model.Container container) Get any stored credentials for connecting to the Keycloak admin APIstatic String
getSubjectId
(Subject subject) static String
getSubjectName
(Principal principal) static String
getSubjectName
(Subject subject) static String
getSubjectNameAndRealm
(Principal principal) static String
getSubjectNameAndRealm
(Subject subject) getTokenUri
(String realm) void
init
(org.openremote.model.Container container) static boolean
isSuperUser
(org.keycloak.KeycloakSecurityContext securityContext) void
secureDeployment
(io.undertow.servlet.api.DeploymentInfo deploymentInfo) boolean
setActiveCredentials
(org.openremote.model.auth.OAuthGrant grant) Update the active credentials used to perform keycloak API actions; the token endpoint will be overwritten with this instances keycloak server URI and for the master realm.void
start
(org.openremote.model.Container container) void
stop
(org.openremote.model.Container container) protected void
-
Field Details
-
ADMIN_CLI_CLIENT_ID
- See Also:
-
DEFAULT_CLIENTS
-
OR_KEYCLOAK_HOST
- See Also:
-
OR_KEYCLOAK_HOST_DEFAULT
- See Also:
-
OR_KEYCLOAK_PORT
- See Also:
-
OR_KEYCLOAK_PORT_DEFAULT
public static final int OR_KEYCLOAK_PORT_DEFAULT- See Also:
-
OR_KEYCLOAK_PATH
- See Also:
-
OR_KEYCLOAK_PATH_DEFAULT
- See Also:
-
KEYCLOAK_CONNECT_TIMEOUT
- See Also:
-
KEYCLOAK_CONNECT_TIMEOUT_DEFAULT
public static final int KEYCLOAK_CONNECT_TIMEOUT_DEFAULT- See Also:
-
KEYCLOAK_REQUEST_TIMEOUT
- See Also:
-
KEYCLOAK_REQUEST_TIMEOUT_DEFAULT
public static final int KEYCLOAK_REQUEST_TIMEOUT_DEFAULT- See Also:
-
KEYCLOAK_CLIENT_POOL_SIZE
- See Also:
-
KEYCLOAK_CLIENT_POOL_SIZE_DEFAULT
public static final int KEYCLOAK_CLIENT_POOL_SIZE_DEFAULT- See Also:
-
OR_IDENTITY_SESSION_MAX_MINUTES
- See Also:
-
OR_IDENTITY_SESSION_MAX_MINUTES_DEFAULT
public static final int OR_IDENTITY_SESSION_MAX_MINUTES_DEFAULT- See Also:
-
OR_IDENTITY_SESSION_OFFLINE_TIMEOUT_MINUTES
- See Also:
-
OR_IDENTITY_SESSION_OFFLINE_TIMEOUT_MINUTES_DEFAULT
public static final int OR_IDENTITY_SESSION_OFFLINE_TIMEOUT_MINUTES_DEFAULT- See Also:
-
keycloakServiceUri
protected jakarta.ws.rs.core.UriBuilder keycloakServiceUri -
sessionTimeoutSeconds
protected int sessionTimeoutSeconds -
sessionMaxSeconds
protected int sessionMaxSeconds -
sessionOfflineTimeoutSeconds
protected int sessionOfflineTimeoutSeconds -
notAuthenticatedKeycloakDeployment
protected final org.keycloak.adapters.KeycloakDeployment notAuthenticatedKeycloakDeployment -
httpClient
protected org.jboss.resteasy.client.jaxrs.ResteasyClient httpClient -
keycloakTarget
protected org.jboss.resteasy.client.jaxrs.ResteasyWebTarget keycloakTarget -
oAuthGrant
protected org.openremote.model.auth.OAuthGrant oAuthGrant -
realmsResourcePool
protected ConcurrentLinkedQueue<org.keycloak.admin.client.resource.RealmsResource> realmsResourcePool -
keycloakDeploymentCache
protected com.google.common.cache.LoadingCache<KeycloakRealmClient,org.keycloak.adapters.KeycloakDeployment> keycloakDeploymentCache -
keycloakConfigResolver
protected org.keycloak.adapters.KeycloakConfigResolver keycloakConfigResolver -
authProxyHandler
protected io.undertow.server.HttpHandler authProxyHandler
-
-
Constructor Details
-
KeycloakIdentityProvider
protected KeycloakIdentityProvider()The suppliedOAuthGrant
will be used to authenticate with keycloak so we can programmatically make changes. It must be credentials for the master realm for a user with `admin` role so that they can perform CRUD on realms, clients and users.
-
-
Method Details
-
getDefaultKeycloakGrant
public org.openremote.model.auth.OAuthPasswordGrant getDefaultKeycloakGrant(org.openremote.model.Container container) -
init
public void init(org.openremote.model.Container container) - Specified by:
init
in interfaceIdentityProvider
-
start
public void start(org.openremote.model.Container container) - Specified by:
start
in interfaceIdentityProvider
-
stop
public void stop(org.openremote.model.Container container) - Specified by:
stop
in interfaceIdentityProvider
-
secureDeployment
public void secureDeployment(io.undertow.servlet.api.DeploymentInfo deploymentInfo) - Specified by:
secureDeployment
in interfaceIdentityProvider
-
getKeycloak
-
syncUsers
-
getRealms
public final <T> T getRealms(Function<org.keycloak.admin.client.resource.RealmsResource, T> consumer) -
getKeycloakDeployment
-
getTokenUri
-
getAccessTokenSupplier
Convenience method for generating access tokens from a given OAuth compliant server -
setActiveCredentials
public boolean setActiveCredentials(org.openremote.model.auth.OAuthGrant grant) Update the active credentials used to perform keycloak API actions; the token endpoint will be overwritten with this instances keycloak server URI and for the master realm. -
getStoredCredentials
protected abstract org.openremote.model.auth.OAuthGrant getStoredCredentials(org.openremote.model.Container container) Get any stored credentials for connecting to the Keycloak admin API- Returns:
- credentials or null if none defined.
-
generateStoredCredentials
protected abstract org.openremote.model.auth.OAuthGrant generateStoredCredentials(org.openremote.model.Container container) Generate and store credentials for connecting to the Keycloak admin API- Returns:
- credentials or null if generation/storage failed.
-
createKeycloakDeploymentCache
protected com.google.common.cache.LoadingCache<KeycloakRealmClient,org.keycloak.adapters.KeycloakDeployment> createKeycloakDeploymentCache() -
enableAuthProxy
-
addClientRedirectUris
protected abstract void addClientRedirectUris(String client, List<String> redirectUrls, boolean devMode) There must be _some_ valid redirect URIs for the application or authentication will not be possible. -
getSecurityContext
-
getSubjectName
-
getSubjectName
-
getSubjectNameAndRealm
-
getSubjectNameAndRealm
-
getSubjectId
-
isSuperUser
public static boolean isSuperUser(org.keycloak.KeycloakSecurityContext securityContext)
-