Package org.openremote.manager.security
Class ManagerKeycloakIdentityProvider
java.lang.Object
org.openremote.container.security.keycloak.KeycloakIdentityProvider
org.openremote.manager.security.ManagerKeycloakIdentityProvider
- All Implemented Interfaces:
org.openremote.container.security.IdentityProvider,ManagerIdentityProvider
public class ManagerKeycloakIdentityProvider
extends org.openremote.container.security.keycloak.KeycloakIdentityProvider
implements ManagerIdentityProvider
All keycloak interaction is done through the admin-cli client; security is implemented downstream of here; anything
in the same process as this service has privileged access to keycloak.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected AssetStorageServiceprotected ClientEventServiceprotected ConsoleAppServiceprotected org.openremote.model.Containerstatic final Stringstatic final Stringprotected Stringprotected Stringprotected org.openremote.container.message.MessageBrokerServicestatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringprotected org.openremote.container.persistence.PersistenceServicestatic final Stringprotected org.openremote.container.timer.TimerServiceFields inherited from class org.openremote.container.security.keycloak.KeycloakIdentityProvider
ADMIN_CLI_CLIENT_ID, authProxyHandler, DEFAULT_CLIENTS, httpClient, KEYCLOAK_CLIENT_POOL_SIZE, KEYCLOAK_CLIENT_POOL_SIZE_DEFAULT, KEYCLOAK_CONNECT_TIMEOUT, KEYCLOAK_CONNECT_TIMEOUT_DEFAULT, KEYCLOAK_REQUEST_TIMEOUT, KEYCLOAK_REQUEST_TIMEOUT_DEFAULT, keycloakConfigResolver, keycloakDeploymentCache, keycloakServiceUri, keycloakTarget, notAuthenticatedKeycloakDeployment, oAuthGrant, OR_IDENTITY_SESSION_MAX_MINUTES, OR_IDENTITY_SESSION_MAX_MINUTES_DEFAULT, OR_IDENTITY_SESSION_OFFLINE_TIMEOUT_MINUTES, OR_IDENTITY_SESSION_OFFLINE_TIMEOUT_MINUTES_DEFAULT, OR_KEYCLOAK_HOST, OR_KEYCLOAK_HOST_DEFAULT, OR_KEYCLOAK_PATH, OR_KEYCLOAK_PATH_DEFAULT, OR_KEYCLOAK_PORT, OR_KEYCLOAK_PORT_DEFAULT, realmsResourcePool, sessionMaxSeconds, sessionOfflineTimeoutSeconds, sessionTimeoutSecondsFields inherited from interface org.openremote.container.security.IdentityProvider
OR_ADMIN_PASSWORD, OR_ADMIN_PASSWORD_DEFAULT -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddClientRedirectUris(String client, List<String> redirectUrls, boolean devMode) protected voidaddDefaultRoles(org.keycloak.admin.client.resource.RolesResource rolesResource) addLDAPConfiguration(String realm, org.keycloak.representations.idm.ComponentRepresentation componentRepresentation) addLDAPMapper(String realm, org.keycloak.representations.idm.ComponentRepresentation componentRepresentation) booleancanSubscribeWith(org.openremote.container.security.AuthContext auth, org.openremote.model.event.shared.RealmFilter<?> filter, org.openremote.model.security.ClientRole... requiredRoles) Superusers can subscribe to all events, regular users must be in the same realm as the filter and any required roles must match.protected voidconfigureRealm(org.keycloak.representations.idm.RealmRepresentation realmRepresentation) org.openremote.model.security.RealmcreateRealm(org.openremote.model.security.Realm realm) org.keycloak.representations.idm.ClientRepresentationcreateUpdateClient(String realm, org.keycloak.representations.idm.ClientRepresentation client) org.openremote.model.security.UsercreateUpdateUser(String realm, org.openremote.model.security.User user, String passwordSecret, boolean allowUpdate) voiddeleteClient(String realm, String clientId) voiddeleteRealm(String realmName) voiddeleteUser(String realm, String userId) org.keycloak.representations.idm.ClientRepresentationprotected org.openremote.model.auth.OAuthGrantgenerateStoredCredentials(org.openremote.model.Container container) org.keycloak.representations.idm.ClientRepresentationorg.openremote.model.security.Role[]getClientRoles(String realm, String client) org.keycloak.representations.idm.ClientRepresentation[]getClients(String realm) Returns the frontend URL to be used for frontend apps to authenticateorg.openremote.model.security.Realmorg.openremote.model.security.Realm[]protected org.openremote.model.auth.OAuthGrantgetStoredCredentials(org.openremote.model.Container container) org.openremote.model.security.Userorg.openremote.model.security.UsergetUserByUsername(String realm, String username) String[]getUserClientRoles(String realm, String userId, String client) String[]getUserRealmRoles(String realm, String userId) voidinit(org.openremote.model.Container container) static booleanisBuiltInRealmRole(String realmRole) booleanisMasterRealmAdmin(String userId) booleanisRealmActiveAndAccessible(org.openremote.container.security.AuthContext authContext, String realm) booleanisRealmActiveAndAccessible(org.openremote.container.security.AuthContext authContext, org.openremote.model.security.Realm realm) booleanisRestrictedUser(org.openremote.container.security.AuthContext authContext) booleanisUserInRealm(String userId, String realm) org.openremote.model.security.User[]queryUsers(org.openremote.model.query.UserQuery userQuery) booleanrealmExists(String realm) voidresetPassword(String realm, String userId, org.openremote.model.security.Credential credential) resetSecret(String realm, String userId, String secret) protected org.keycloak.representations.idm.RoleRepresentationsaveClientRole(org.keycloak.admin.client.resource.RealmResource realmResource, org.keycloak.admin.client.resource.ClientResource clientResource, org.openremote.model.security.Role role, org.keycloak.representations.idm.RoleRepresentation representation) voidstart(org.openremote.model.Container container) toString()voidupdateClientRoles(String realm, String clientId, org.openremote.model.security.Role[] roles) voidupdateRealm(org.openremote.model.security.Realm realm) voidupdateUserClientRoles(@NotNull String realm, @NotNull String userId, @NotNull String client, String... roles) voidupdateUserRealmRoles(String realm, String userId, String... roles) protected <T> TwithClientResource(String realm, String client, org.keycloak.admin.client.resource.RealmsResource realmsResource, BiFunction<org.keycloak.representations.idm.ClientRepresentation, org.keycloak.admin.client.resource.ClientResource, T> clientResourceConsumer, Supplier<T> notFoundProvider) Methods inherited from class org.openremote.container.security.keycloak.KeycloakIdentityProvider
createKeycloakDeploymentCache, enableAuthProxy, getAccessTokenSupplier, getDefaultKeycloakGrant, getKeycloak, getKeycloakDeployment, getRealms, getSecurityContext, getSubjectId, getSubjectName, getSubjectName, getSubjectNameAndRealm, getSubjectNameAndRealm, getTokenUri, isSuperUser, secureDeployment, setActiveCredentials, stop, syncUsersMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.openremote.container.security.IdentityProvider
secureDeployment, stopMethods inherited from interface org.openremote.manager.security.ManagerIdentityProvider
addUserRealmRoles
-
Field Details
-
REALM_KEYCLOAK_THEME_SUFFIX
- See Also:
-
DEFAULT_REALM_KEYCLOAK_THEME
- See Also:
-
DEFAULT_REALM_KEYCLOAK_THEME_DEFAULT
- See Also:
-
OR_KEYCLOAK_GRANT_FILE
- See Also:
-
OR_KEYCLOAK_GRANT_FILE_DEFAULT
- See Also:
-
OR_KEYCLOAK_PUBLIC_URI
- See Also:
-
OR_KEYCLOAK_PUBLIC_URI_DEFAULT
- See Also:
-
OR_KEYCLOAK_ENABLE_DIRECT_ACCESS_GRANT
- See Also:
-
BUILT_IN_REALM_ROLES
-
persistenceService
protected org.openremote.container.persistence.PersistenceService persistenceService -
assetStorageService
-
timerService
protected org.openremote.container.timer.TimerService timerService -
messageBrokerService
protected org.openremote.container.message.MessageBrokerService messageBrokerService -
clientEventService
-
consoleAppService
-
keycloakAdminPassword
-
container
protected org.openremote.model.Container container -
frontendURI
-
validRedirectUris
-
realmCache
-
-
Constructor Details
-
ManagerKeycloakIdentityProvider
public ManagerKeycloakIdentityProvider()
-
-
Method Details
-
init
public void init(org.openremote.model.Container container) - Specified by:
initin interfaceorg.openremote.container.security.IdentityProvider- Overrides:
initin classorg.openremote.container.security.keycloak.KeycloakIdentityProvider
-
start
public void start(org.openremote.model.Container container) - Specified by:
startin interfaceorg.openremote.container.security.IdentityProvider- Overrides:
startin classorg.openremote.container.security.keycloak.KeycloakIdentityProvider
-
getStoredCredentials
protected org.openremote.model.auth.OAuthGrant getStoredCredentials(org.openremote.model.Container container) - Specified by:
getStoredCredentialsin classorg.openremote.container.security.keycloak.KeycloakIdentityProvider
-
generateStoredCredentials
protected org.openremote.model.auth.OAuthGrant generateStoredCredentials(org.openremote.model.Container container) - Specified by:
generateStoredCredentialsin classorg.openremote.container.security.keycloak.KeycloakIdentityProvider
-
addClientRedirectUris
- Specified by:
addClientRedirectUrisin classorg.openremote.container.security.keycloak.KeycloakIdentityProvider
-
withClientResource
protected <T> T withClientResource(String realm, String client, org.keycloak.admin.client.resource.RealmsResource realmsResource, BiFunction<org.keycloak.representations.idm.ClientRepresentation, org.keycloak.admin.client.resource.ClientResource, T> clientResourceConsumer, Supplier<T> notFoundProvider) -
queryUsers
public org.openremote.model.security.User[] queryUsers(org.openremote.model.query.UserQuery userQuery) - Specified by:
queryUsersin interfaceManagerIdentityProvider
-
getUser
- Specified by:
getUserin interfaceManagerIdentityProvider
-
getUserByUsername
- Specified by:
getUserByUsernamein interfaceManagerIdentityProvider
-
createUpdateUser
public org.openremote.model.security.User createUpdateUser(String realm, org.openremote.model.security.User user, String passwordSecret, boolean allowUpdate) throws jakarta.ws.rs.WebApplicationException - Specified by:
createUpdateUserin interfaceManagerIdentityProvider- Throws:
jakarta.ws.rs.WebApplicationException
-
deleteUser
- Specified by:
deleteUserin interfaceManagerIdentityProvider
-
resetPassword
public void resetPassword(String realm, String userId, org.openremote.model.security.Credential credential) - Specified by:
resetPasswordin interfaceManagerIdentityProvider
-
resetSecret
- Specified by:
resetSecretin interfaceManagerIdentityProvider
-
getClientRoles
- Specified by:
getClientRolesin interfaceManagerIdentityProvider
-
updateClientRoles
public void updateClientRoles(String realm, String clientId, org.openremote.model.security.Role[] roles) - Specified by:
updateClientRolesin interfaceManagerIdentityProvider
-
saveClientRole
protected org.keycloak.representations.idm.RoleRepresentation saveClientRole(org.keycloak.admin.client.resource.RealmResource realmResource, org.keycloak.admin.client.resource.ClientResource clientResource, org.openremote.model.security.Role role, org.keycloak.representations.idm.RoleRepresentation representation) -
getUserClientRoles
- Specified by:
getUserClientRolesin interfaceManagerIdentityProvider
-
getUserRealmRoles
- Specified by:
getUserRealmRolesin interfaceManagerIdentityProvider
-
updateUserClientRoles
public void updateUserClientRoles(@NotNull @NotNull String realm, @NotNull @NotNull String userId, @NotNull @NotNull String client, String... roles) - Specified by:
updateUserClientRolesin interfaceManagerIdentityProvider
-
updateUserRealmRoles
- Specified by:
updateUserRealmRolesin interfaceManagerIdentityProvider
-
isMasterRealmAdmin
- Specified by:
isMasterRealmAdminin interfaceManagerIdentityProvider
-
getRealms
public org.openremote.model.security.Realm[] getRealms()- Specified by:
getRealmsin interfaceManagerIdentityProvider
-
getRealm
- Specified by:
getRealmin interfaceManagerIdentityProvider
-
updateRealm
public void updateRealm(org.openremote.model.security.Realm realm) - Specified by:
updateRealmin interfaceManagerIdentityProvider
-
createRealm
public org.openremote.model.security.Realm createRealm(org.openremote.model.security.Realm realm) - Specified by:
createRealmin interfaceManagerIdentityProvider
-
deleteRealm
- Specified by:
deleteRealmin interfaceManagerIdentityProvider
-
generateOpenRemoteClientRepresentation
public org.keycloak.representations.idm.ClientRepresentation generateOpenRemoteClientRepresentation() -
getClient
-
getClients
-
createUpdateClient
public org.keycloak.representations.idm.ClientRepresentation createUpdateClient(String realm, org.keycloak.representations.idm.ClientRepresentation client) -
deleteClient
-
isRealmActiveAndAccessible
public boolean isRealmActiveAndAccessible(org.openremote.container.security.AuthContext authContext, org.openremote.model.security.Realm realm) - Specified by:
isRealmActiveAndAccessiblein interfaceManagerIdentityProvider- Returns:
trueif the user is the superuser (admin) or if the user is authenticated in the same realm as the realm and the realm is active.
-
isRealmActiveAndAccessible
public boolean isRealmActiveAndAccessible(org.openremote.container.security.AuthContext authContext, String realm) - Specified by:
isRealmActiveAndAccessiblein interfaceManagerIdentityProvider- Returns:
trueif the user is the superuser (admin) or if the user is authenticated in the same realm and the realm is active.
-
realmExists
- Specified by:
realmExistsin interfaceManagerIdentityProvider
-
isRestrictedUser
public boolean isRestrictedUser(org.openremote.container.security.AuthContext authContext) - Specified by:
isRestrictedUserin interfaceManagerIdentityProvider
-
isUserInRealm
- Specified by:
isUserInRealmin interfaceManagerIdentityProvider
-
getFrontendURI
Description copied from interface:ManagerIdentityProviderReturns the frontend URL to be used for frontend apps to authenticate- Specified by:
getFrontendURIin interfaceManagerIdentityProvider
-
configureRealm
protected void configureRealm(org.keycloak.representations.idm.RealmRepresentation realmRepresentation) -
addDefaultRoles
protected void addDefaultRoles(org.keycloak.admin.client.resource.RolesResource rolesResource) -
addLDAPConfiguration
-
addLDAPMapper
-
isBuiltInRealmRole
-
toString
-