diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/base/EntityMapper.xml b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/base/EntityMapper.xml new file mode 100644 index 000000000..eb7a7714a --- /dev/null +++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/base/EntityMapper.xml @@ -0,0 +1,123 @@ + + + + + + + + + + ( + ${column} = ${entityID} + + OR ${column} IN ( + SELECT guacamole_entity.entity_id + FROM guacamole_entity + JOIN guacamole_user_group ON guacamole_user_group.entity_id = guacamole_entity.entity_id + WHERE + type = 'USER_GROUP' + AND name IN + + #{effectiveGroup,jdbcType=VARCHAR} + + AND disabled = false + ) + + ) + + + + + + + + + INSERT INTO guacamole_entity ( + name, + type + ) + VALUES ( + #{entity.identifier,jdbcType=VARCHAR}, + #{entity.entityType,jdbcType=VARCHAR} + ) + + + + diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/connection/ConnectionMapper.xml b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/connection/ConnectionMapper.xml index e5fd2f03f..391e90d30 100644 --- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/connection/ConnectionMapper.xml +++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/connection/ConnectionMapper.xml @@ -68,7 +68,11 @@ SELECT connection_id FROM guacamole_connection_permission WHERE - user_id = #{user.objectID,jdbcType=INTEGER} + + + + + AND permission = 'READ' @@ -89,7 +93,11 @@ WHERE parent_id = #{parentIdentifier,jdbcType=VARCHAR} parent_id IS NULL - AND user_id = #{user.objectID,jdbcType=INTEGER} + AND + + + + AND permission = 'READ' @@ -165,7 +173,11 @@ open="(" separator="," close=")"> #{identifier,jdbcType=VARCHAR} - AND guacamole_connection_permission.user_id = #{user.objectID,jdbcType=INTEGER} + AND + + + + AND permission = 'READ' GROUP BY guacamole_connection.connection_id; @@ -177,7 +189,11 @@ open="(" separator="," close=")"> #{identifier,jdbcType=VARCHAR} - AND user_id = #{user.objectID,jdbcType=INTEGER} + AND + + + + AND permission = 'READ'; SELECT @@ -191,7 +207,11 @@ open="(" separator="," close=")"> #{identifier,jdbcType=VARCHAR} - AND user_id = #{user.objectID,jdbcType=INTEGER} + AND + + + + AND permission = 'READ'; diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/connection/ConnectionRecordMapper.xml b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/connection/ConnectionRecordMapper.xml index 287ca02fa..d74d4c4cb 100644 --- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/connection/ConnectionRecordMapper.xml +++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/connection/ConnectionRecordMapper.xml @@ -79,7 +79,10 @@ #{record.sharingProfileIdentifier,jdbcType=VARCHAR}, #{record.sharingProfileName,jdbcType=VARCHAR}, (SELECT user_id FROM guacamole_user - WHERE username = #{record.username,jdbcType=VARCHAR}), + JOIN guacamole_entity ON guacamole_user.entity_id = guacamole_entity.entity_id + WHERE + guacamole_entity.name = #{record.username,jdbcType=VARCHAR} + AND guacamole_entity.type = 'USER'), #{record.username,jdbcType=VARCHAR}, #{record.startDate,jdbcType=TIMESTAMP}, #{record.endDate,jdbcType=TIMESTAMP} @@ -165,13 +168,21 @@ JOIN guacamole_connection_permission ON guacamole_connection_history.connection_id = guacamole_connection_permission.connection_id - AND guacamole_connection_permission.user_id = #{user.objectID,jdbcType=INTEGER} + AND + + + + AND guacamole_connection_permission.permission = 'READ' JOIN guacamole_user_permission ON guacamole_connection_history.user_id = guacamole_user_permission.affected_user_id - AND guacamole_user_permission.user_id = #{user.objectID,jdbcType=INTEGER} + AND + + + + AND guacamole_user_permission.permission = 'READ' @@ -182,7 +193,10 @@ guacamole_connection_history.user_id IN ( SELECT user_id FROM guacamole_user - WHERE POSITION(#{term.term,jdbcType=VARCHAR} IN username) > 0 + JOIN guacamole_entity ON guacamole_user.entity_id = guacamole_entity.entity_id + WHERE + POSITION(#{term.term,jdbcType=VARCHAR} IN guacamole_entity.name) > 0 + AND guacamole_entity.type = 'USER' ) OR guacamole_connection_history.connection_id IN ( diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/connectiongroup/ConnectionGroupMapper.xml b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/connectiongroup/ConnectionGroupMapper.xml index e02a04640..9addd3c10 100644 --- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/connectiongroup/ConnectionGroupMapper.xml +++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/connectiongroup/ConnectionGroupMapper.xml @@ -69,7 +69,11 @@ SELECT connection_group_id FROM guacamole_connection_group_permission WHERE - user_id = #{user.objectID,jdbcType=INTEGER} + + + + + AND permission = 'READ' @@ -90,7 +94,11 @@ WHERE parent_id = #{parentIdentifier,jdbcType=VARCHAR} parent_id IS NULL - AND user_id = #{user.objectID,jdbcType=INTEGER} + AND + + + + AND permission = 'READ' @@ -161,7 +169,11 @@ open="(" separator="," close=")"> #{identifier,jdbcType=VARCHAR} - AND user_id = #{user.objectID,jdbcType=INTEGER} + AND + + + + AND permission = 'READ'; SELECT parent_id, guacamole_connection_group.connection_group_id @@ -172,7 +184,11 @@ open="(" separator="," close=")"> #{identifier,jdbcType=VARCHAR} - AND user_id = #{user.objectID,jdbcType=INTEGER} + AND + + + + AND permission = 'READ'; SELECT parent_id, guacamole_connection.connection_id @@ -183,7 +199,11 @@ open="(" separator="," close=")"> #{identifier,jdbcType=VARCHAR} - AND user_id = #{user.objectID,jdbcType=INTEGER} + AND + + + + AND permission = 'READ'; SELECT @@ -197,7 +217,11 @@ open="(" separator="," close=")"> #{identifier,jdbcType=VARCHAR} - AND user_id = #{user.objectID,jdbcType=INTEGER} + AND + + + + AND permission = 'READ'; diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/permission/ConnectionGroupPermissionMapper.xml b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/permission/ConnectionGroupPermissionMapper.xml index 972a71d20..adb961820 100644 --- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/permission/ConnectionGroupPermissionMapper.xml +++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/permission/ConnectionGroupPermissionMapper.xml @@ -25,24 +25,26 @@ - - + - + @@ -50,26 +52,32 @@ - + SELECT - guacamole_connection_permission.user_id, - username, + #{entity.entityID,jdbcType=INTEGER} AS entity_id, permission, connection_id FROM guacamole_connection_permission - JOIN guacamole_user ON guacamole_connection_permission.user_id = guacamole_user.user_id - WHERE guacamole_connection_permission.user_id = #{user.objectID,jdbcType=INTEGER} + WHERE + + + + + @@ -50,26 +52,32 @@ - + SELECT - guacamole_sharing_profile_permission.user_id, - username, + #{entity.entityID,jdbcType=INTEGER} AS entity_id, permission, sharing_profile_id FROM guacamole_sharing_profile_permission - JOIN guacamole_user ON guacamole_sharing_profile_permission.user_id = guacamole_user.user_id - WHERE guacamole_sharing_profile_permission.user_id = #{user.objectID,jdbcType=INTEGER} + WHERE + + + + + @@ -50,26 +52,32 @@ - + - SELECT - guacamole_system_permission.user_id, - username, + SELECT DISTINCT + #{entity.entityID} AS entity_id, permission FROM guacamole_system_permission - JOIN guacamole_user ON guacamole_system_permission.user_id = guacamole_user.user_id - WHERE guacamole_system_permission.user_id = #{user.objectID,jdbcType=INTEGER} + WHERE + + + + + @@ -63,10 +67,10 @@ DELETE FROM guacamole_system_permission - WHERE (user_id, permission) IN + WHERE (entity_id, permission) IN - (#{permission.userID,jdbcType=INTEGER}, + (#{permission.entityID,jdbcType=INTEGER}, #{permission.type,jdbcType=VARCHAR}) @@ -76,15 +80,15 @@ INSERT IGNORE INTO guacamole_system_permission ( - user_id, + entity_id, permission ) VALUES - (#{permission.userID,jdbcType=INTEGER}, + (#{permission.entityID,jdbcType=INTEGER}, #{permission.type,jdbcType=VARCHAR}) - \ No newline at end of file + diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/permission/UserGroupPermissionMapper.xml b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/permission/UserGroupPermissionMapper.xml new file mode 100644 index 000000000..d8af2bcd2 --- /dev/null +++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/permission/UserGroupPermissionMapper.xml @@ -0,0 +1,149 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + DELETE FROM guacamole_user_group_permission + USING guacamole_user_group_permission + JOIN guacamole_user_group affected_group ON guacamole_user_group_permission.affected_user_group_id = affected_group.user_group_id + JOIN guacamole_entity affected_entity ON affected_group.entity_id = affected_entity.entity_id + WHERE + (guacamole_user_group_permission.entity_id, permission, affected_entity.name) IN + + (#{permission.entityID,jdbcType=INTEGER}, + #{permission.type,jdbcType=VARCHAR}, + #{permission.objectIdentifier,jdbcType=VARCHAR}) + + AND affected_entity.type = 'USER_GROUP' + + + + + + + INSERT IGNORE INTO guacamole_user_group_permission ( + entity_id, + permission, + affected_user_group_id + ) + SELECT DISTINCT + permissions.entity_id, + permissions.permission, + affected_group.user_group_id + FROM + + SELECT #{permission.entityID,jdbcType=INTEGER} AS entity_id, + #{permission.type,jdbcType=VARCHAR} AS permission, + #{permission.objectIdentifier,jdbcType=VARCHAR} AS affected_name + + AS permissions + JOIN guacamole_entity affected_entity ON + affected_entity.name = permissions.affected_name + AND affected_entity.type = 'USER_GROUP' + JOIN guacamole_user_group affected_group ON affected_group.entity_id = affected_entity.entity_id + + + + diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/permission/UserPermissionMapper.xml b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/permission/UserPermissionMapper.xml index 3b837de21..4470aa353 100644 --- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/permission/UserPermissionMapper.xml +++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/permission/UserPermissionMapper.xml @@ -25,25 +25,29 @@ - - + - + - + @@ -51,29 +55,38 @@ - + @@ -91,15 +105,17 @@ DELETE FROM guacamole_user_permission USING guacamole_user_permission - JOIN guacamole_user affected ON guacamole_user_permission.affected_user_id = affected.user_id + JOIN guacamole_user affected_user ON guacamole_user_permission.affected_user_id = affected_user.user_id + JOIN guacamole_entity affected_entity ON affected_user.entity_id = affected_entity.entity_id WHERE - (guacamole_user_permission.user_id, permission, affected.username) IN + (guacamole_user_permission.entity_id, permission, affected_entity.name) IN - (#{permission.userID,jdbcType=INTEGER}, + (#{permission.entityID,jdbcType=INTEGER}, #{permission.type,jdbcType=VARCHAR}, #{permission.objectIdentifier,jdbcType=VARCHAR}) + AND affected_entity.type = 'USER' @@ -107,20 +123,27 @@ INSERT IGNORE INTO guacamole_user_permission ( - user_id, + entity_id, permission, affected_user_id ) - SELECT permissions.user_id, permissions.permission, guacamole_user.user_id FROM + SELECT DISTINCT + permissions.entity_id, + permissions.permission, + affected_user.user_id + FROM - SELECT #{permission.userID,jdbcType=INTEGER} AS user_id, + SELECT #{permission.entityID,jdbcType=INTEGER} AS entity_id, #{permission.type,jdbcType=VARCHAR} AS permission, - #{permission.objectIdentifier,jdbcType=VARCHAR} AS username + #{permission.objectIdentifier,jdbcType=VARCHAR} AS affected_name AS permissions - JOIN guacamole_user ON guacamole_user.username = permissions.username; + JOIN guacamole_entity affected_entity ON + affected_entity.name = permissions.affected_name + AND affected_entity.type = 'USER' + JOIN guacamole_user affected_user ON affected_user.entity_id = affected_entity.entity_id - \ No newline at end of file + diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/sharingprofile/SharingProfileMapper.xml b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/sharingprofile/SharingProfileMapper.xml index ef899132f..7ffdc3d01 100644 --- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/sharingprofile/SharingProfileMapper.xml +++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/sharingprofile/SharingProfileMapper.xml @@ -52,7 +52,11 @@ SELECT sharing_profile_id FROM guacamole_sharing_profile_permission WHERE - user_id = #{user.objectID,jdbcType=INTEGER} + + + + + AND permission = 'READ' @@ -99,7 +103,11 @@ open="(" separator="," close=")"> #{identifier,jdbcType=VARCHAR} - AND user_id = #{user.objectID,jdbcType=INTEGER} + AND + + + + AND permission = 'READ'; SELECT @@ -113,7 +121,11 @@ open="(" separator="," close=")"> #{identifier,jdbcType=VARCHAR} - AND user_id = #{user.objectID,jdbcType=INTEGER} + AND + + + + AND permission = 'READ'; diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/user/PasswordRecordMapper.xml b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/user/PasswordRecordMapper.xml index be9f0b600..f3772d7f9 100644 --- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/user/PasswordRecordMapper.xml +++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/user/PasswordRecordMapper.xml @@ -41,8 +41,9 @@ guacamole_user_password_history.password_date FROM guacamole_user_password_history JOIN guacamole_user ON guacamole_user_password_history.user_id = guacamole_user.user_id + JOIN guacamole_entity ON guacamole_user.entity_id = guacamole_entity.entity_id WHERE - guacamole_user.username = #{username,jdbcType=VARCHAR} + guacamole_entity.name = #{username,jdbcType=VARCHAR} ORDER BY guacamole_user_password_history.password_date DESC LIMIT #{maxHistorySize} diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/user/UserMapper.xml b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/user/UserMapper.xml index e183fe295..a27ff1b59 100644 --- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/user/UserMapper.xml +++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/user/UserMapper.xml @@ -28,7 +28,8 @@ - + + @@ -57,17 +58,24 @@ @@ -77,7 +85,8 @@ SELECT guacamole_user.user_id, - guacamole_user.username, + guacamole_entity.entity_id, + guacamole_entity.name, password_hash, password_salt, password_date, @@ -94,13 +103,15 @@ organizational_role, MAX(start_date) AS last_active FROM guacamole_user + JOIN guacamole_entity ON guacamole_user.entity_id = guacamole_entity.entity_id LEFT JOIN guacamole_user_history ON guacamole_user_history.user_id = guacamole_user.user_id - WHERE guacamole_user.username IN + WHERE guacamole_entity.name IN #{identifier,jdbcType=VARCHAR} - GROUP BY guacamole_user.user_id; + AND guacamole_entity.type = 'USER' + GROUP BY guacamole_user.user_id, guacamole_entity.entity_id; SELECT guacamole_user_attribute.user_id, @@ -108,11 +119,13 @@ guacamole_user_attribute.attribute_value FROM guacamole_user_attribute JOIN guacamole_user ON guacamole_user.user_id = guacamole_user_attribute.user_id - WHERE username IN + JOIN guacamole_entity ON guacamole_user.entity_id = guacamole_entity.entity_id + WHERE guacamole_entity.name IN #{identifier,jdbcType=VARCHAR} - ; + + AND guacamole_entity.type = 'USER'; @@ -122,7 +135,8 @@ SELECT guacamole_user.user_id, - guacamole_user.username, + guacamole_entity.entity_id, + guacamole_entity.name, password_hash, password_salt, password_date, @@ -139,16 +153,22 @@ organizational_role, MAX(start_date) AS last_active FROM guacamole_user + JOIN guacamole_entity ON guacamole_user.entity_id = guacamole_entity.entity_id JOIN guacamole_user_permission ON affected_user_id = guacamole_user.user_id LEFT JOIN guacamole_user_history ON guacamole_user_history.user_id = guacamole_user.user_id - WHERE guacamole_user.username IN + WHERE guacamole_entity.name IN #{identifier,jdbcType=VARCHAR} - AND guacamole_user_permission.user_id = #{user.objectID,jdbcType=INTEGER} + AND guacamole_entity.type = 'USER' + AND + + + + AND permission = 'READ' - GROUP BY guacamole_user.user_id; + GROUP BY guacamole_user.user_id, guacamole_entity.entity_id; SELECT guacamole_user_attribute.user_id, @@ -156,13 +176,19 @@ guacamole_user_attribute.attribute_value FROM guacamole_user_attribute JOIN guacamole_user ON guacamole_user.user_id = guacamole_user_attribute.user_id + JOIN guacamole_entity ON guacamole_user.entity_id = guacamole_entity.entity_id JOIN guacamole_user_permission ON affected_user_id = guacamole_user.user_id - WHERE username IN + WHERE guacamole_entity.name IN #{identifier,jdbcType=VARCHAR} - AND guacamole_user_permission.user_id = #{user.objectID,jdbcType=INTEGER} + AND guacamole_entity.type = 'USER' + AND + + + + AND permission = 'READ'; @@ -173,7 +199,8 @@ SELECT guacamole_user.user_id, - guacamole_user.username, + guacamole_entity.entity_id, + guacamole_entity.name, password_hash, password_salt, password_date, @@ -190,10 +217,12 @@ organizational_role, MAX(start_date) AS last_active FROM guacamole_user + JOIN guacamole_entity ON guacamole_user.entity_id = guacamole_entity.entity_id LEFT JOIN guacamole_user_history ON guacamole_user_history.user_id = guacamole_user.user_id WHERE - guacamole_user.username = #{username,jdbcType=VARCHAR} - GROUP BY guacamole_user.user_id; + guacamole_entity.name = #{username,jdbcType=VARCHAR} + AND guacamole_entity.type = 'USER' + GROUP BY guacamole_user.user_id, guacamole_entity.entity_id; SELECT guacamole_user_attribute.user_id, @@ -201,14 +230,19 @@ guacamole_user_attribute.attribute_value FROM guacamole_user_attribute JOIN guacamole_user ON guacamole_user.user_id = guacamole_user_attribute.user_id - WHERE username = #{username,jdbcType=VARCHAR}; + JOIN guacamole_entity ON guacamole_user.entity_id = guacamole_entity.entity_id + WHERE + guacamole_entity.name = #{username,jdbcType=VARCHAR} + AND guacamole_entity.type = 'USER' - DELETE FROM guacamole_user - WHERE username = #{identifier,jdbcType=VARCHAR} + DELETE FROM guacamole_entity + WHERE + name = #{identifier,jdbcType=VARCHAR} + AND type = 'USER' @@ -216,7 +250,7 @@ parameterType="org.apache.guacamole.auth.jdbc.user.UserModel"> INSERT INTO guacamole_user ( - username, + entity_id, password_hash, password_salt, password_date, @@ -233,7 +267,7 @@ organizational_role ) VALUES ( - #{object.identifier,jdbcType=VARCHAR}, + #{object.entityID,jdbcType=VARCHAR}, #{object.passwordHash,jdbcType=BINARY}, #{object.passwordSalt,jdbcType=BINARY}, #{object.passwordDate,jdbcType=TIMESTAMP}, diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/user/UserParentUserGroupMapper.xml b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/user/UserParentUserGroupMapper.xml new file mode 100644 index 000000000..1b0ec4e3b --- /dev/null +++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/user/UserParentUserGroupMapper.xml @@ -0,0 +1,96 @@ + + + + + + + + + + + + + + + + DELETE FROM guacamole_user_group_member + USING guacamole_user_group_member + JOIN guacamole_user_group ON guacamole_user_group.user_group_id = guacamole_user_group_member.user_group_id + JOIN guacamole_entity ON guacamole_entity.entity_id = guacamole_user_group.entity_id + WHERE + member_entity_id = #{parent.entityID,jdbcType=INTEGER} + AND guacamole_entity.type = 'USER_GROUP' + AND guacamole_entity.name IN + + #{identifier,jdbcType=VARCHAR} + + + + + + INSERT INTO guacamole_user_group_member ( + user_group_id, + member_entity_id + ) + SELECT DISTINCT + guacamole_user_group.user_group_id, + #{parent.entityID,jdbcType=INTEGER} + FROM guacamole_user_group + JOIN guacamole_entity ON guacamole_user_group.entity_id = guacamole_entity.entity_id + WHERE + guacamole_entity.name IN + + #{identifier,jdbcType=VARCHAR} + + AND guacamole_entity.type = 'USER_GROUP' + AND guacamole_user_group.user_group_id NOT IN ( + SELECT guacamole_user_group_member.user_group_id + FROM guacamole_user_group_member + WHERE guacamole_user_group_member.member_entity_id = #{parent.entityID,jdbcType=INTEGER} + ) + + + diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/user/UserRecordMapper.xml b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/user/UserRecordMapper.xml index bbae03b07..d9c02ef54 100644 --- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/user/UserRecordMapper.xml +++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/user/UserRecordMapper.xml @@ -44,8 +44,9 @@ guacamole_user_history.end_date FROM guacamole_user_history JOIN guacamole_user ON guacamole_user_history.user_id = guacamole_user.user_id + JOIN guacamole_entity ON guacamole_user.entity_id = guacamole_entity.entity_id WHERE - guacamole_user.username = #{username,jdbcType=VARCHAR} + guacamole_entity.name = #{username,jdbcType=VARCHAR} ORDER BY guacamole_user_history.start_date DESC, guacamole_user_history.end_date DESC @@ -66,7 +67,10 @@ VALUES ( #{record.remoteHost,jdbcType=VARCHAR}, (SELECT user_id FROM guacamole_user - WHERE username = #{record.username,jdbcType=VARCHAR}), + JOIN guacamole_entity ON guacamole_user.entity_id = guacamole_entity.entity_id + WHERE + guacamole_entity.name = #{record.username,jdbcType=VARCHAR} + AND guacamole_entity.type = 'USER'), #{record.username,jdbcType=VARCHAR}, #{record.startDate,jdbcType=TIMESTAMP}, #{record.endDate,jdbcType=TIMESTAMP} @@ -79,7 +83,10 @@ UPDATE guacamole_user_history SET remote_host = #{record.remoteHost,jdbcType=VARCHAR}, user_id = (SELECT user_id FROM guacamole_user - WHERE username = #{record.username,jdbcType=VARCHAR}), + JOIN guacamole_entity ON guacamole_user.entity_id = guacamole_entity.entity_id + WHERE + guacamole_entity.name = #{record.username,jdbcType=VARCHAR} + AND guacamole_entity.type = 'USER'), username = #{record.username,jdbcType=VARCHAR}, start_date = #{record.startDate,jdbcType=TIMESTAMP}, end_date = #{record.endDate,jdbcType=TIMESTAMP} @@ -105,7 +112,10 @@ guacamole_user_history.user_id IN ( SELECT user_id FROM guacamole_user - WHERE POSITION(#{term.term,jdbcType=VARCHAR} IN username) > 0 + JOIN guacamole_entity ON guacamole_user.entity_id = guacamole_entity.entity_id + WHERE + POSITION(#{term.term,jdbcType=VARCHAR} IN guacamole_entity.name) > 0 + AND guacamole_entity.type = 'USER'), ) @@ -146,7 +156,11 @@ JOIN guacamole_user_permission ON guacamole_user_history.user_id = guacamole_user_permission.affected_user_id - AND guacamole_user_permission.user_id = #{user.objectID,jdbcType=INTEGER} + AND + + + + AND guacamole_user_permission.permission = 'READ' @@ -157,7 +171,10 @@ guacamole_user_history.user_id IN ( SELECT user_id FROM guacamole_user - WHERE POSITION(#{term.term,jdbcType=VARCHAR} IN username) > 0 + JOIN guacamole_entity ON guacamole_user.entity_id = guacamole_entity.entity_id + WHERE + POSITION(#{term.term,jdbcType=VARCHAR} IN guacamole_entity.name) > 0 + AND guacamole_entity.type = 'USER' ) diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/usergroup/UserGroupMapper.xml b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/usergroup/UserGroupMapper.xml new file mode 100644 index 000000000..37092b4f6 --- /dev/null +++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/usergroup/UserGroupMapper.xml @@ -0,0 +1,229 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + DELETE FROM guacamole_entity + WHERE + name = #{identifier,jdbcType=VARCHAR} + AND type = 'USER_GROUP' + + + + + + INSERT INTO guacamole_user_group ( + entity_id, + disabled + ) + VALUES ( + #{object.entityID,jdbcType=VARCHAR}, + #{object.disabled,jdbcType=BOOLEAN} + ) + + + + + + UPDATE guacamole_user_group + SET disabled = #{object.disabled,jdbcType=BOOLEAN} + WHERE user_group_id = #{object.objectID,jdbcType=VARCHAR} + + + + + DELETE FROM guacamole_user_group_attribute + WHERE user_group_id = #{object.objectID,jdbcType=INTEGER} + + + + + INSERT INTO guacamole_user_group_attribute ( + user_group_id, + attribute_name, + attribute_value + ) + VALUES + + (#{object.objectID,jdbcType=INTEGER}, + #{attribute.name,jdbcType=VARCHAR}, + #{attribute.value,jdbcType=VARCHAR}) + + + + diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/usergroup/UserGroupMemberUserGroupMapper.xml b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/usergroup/UserGroupMemberUserGroupMapper.xml new file mode 100644 index 000000000..aedc956c5 --- /dev/null +++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/usergroup/UserGroupMemberUserGroupMapper.xml @@ -0,0 +1,93 @@ + + + + + + + + + + + + + + + + DELETE FROM guacamole_user_group_member + USING guacamole_user_group_member + JOIN guacamole_entity ON guacamole_entity.entity_id = member_entity_id + WHERE + user_group_id = #{parent.objectID,jdbcType=INTEGER} + AND guacamole_entity.type = 'USER_GROUP' + AND guacamole_entity.name IN + + #{identifier,jdbcType=VARCHAR} + + + + + + INSERT INTO guacamole_user_group_member ( + user_group_id, + member_entity_id + ) + SELECT DISTINCT + #{parent.objectID,jdbcType=INTEGER}, + guacamole_entity.entity_id + FROM guacamole_entity + WHERE + guacamole_entity.name IN + + #{identifier} + + AND guacamole_entity.type = 'USER_GROUP' + AND guacamole_entity.entity_id NOT IN ( + SELECT guacamole_user_group_member.member_entity_id + FROM guacamole_user_group_member + WHERE guacamole_user_group_member.user_group_id = #{parent.objectID,jdbcType=INTEGER} + ) + + + diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/usergroup/UserGroupMemberUserMapper.xml b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/usergroup/UserGroupMemberUserMapper.xml new file mode 100644 index 000000000..9e0820392 --- /dev/null +++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/usergroup/UserGroupMemberUserMapper.xml @@ -0,0 +1,93 @@ + + + + + + + + + + + + + + + + DELETE FROM guacamole_user_group_member + USING guacamole_user_group_member + JOIN guacamole_entity ON guacamole_entity.entity_id = member_entity_id + WHERE + user_group_id = #{parent.objectID,jdbcType=INTEGER} + AND guacamole_entity.type = 'USER' + AND guacamole_entity.name IN + + #{identifier,jdbcType=VARCHAR} + + + + + + INSERT INTO guacamole_user_group_member ( + user_group_id, + member_entity_id + ) + SELECT DISTINCT + #{parent.objectID,jdbcType=INTEGER}, + guacamole_entity.entity_id + FROM guacamole_entity + WHERE + guacamole_entity.name IN + + #{identifier} + + AND guacamole_entity.type = 'USER' + AND guacamole_entity.entity_id NOT IN ( + SELECT guacamole_user_group_member.member_entity_id + FROM guacamole_user_group_member + WHERE guacamole_user_group_member.user_group_id = #{parent.objectID,jdbcType=INTEGER} + ) + + + diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/usergroup/UserGroupParentUserGroupMapper.xml b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/usergroup/UserGroupParentUserGroupMapper.xml new file mode 100644 index 000000000..4ef3c72ba --- /dev/null +++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/usergroup/UserGroupParentUserGroupMapper.xml @@ -0,0 +1,96 @@ + + + + + + + + + + + + + + + + DELETE FROM guacamole_user_group_member + USING guacamole_user_group_member + JOIN guacamole_user_group ON guacamole_user_group.user_group_id = guacamole_user_group_member.user_group_id + JOIN guacamole_entity ON guacamole_entity.entity_id = guacamole_user_group.entity_id + WHERE + member_entity_id = #{parent.entityID,jdbcType=INTEGER} + AND guacamole_entity.type = 'USER_GROUP' + AND guacamole_entity.name IN + + #{identifier,jdbcType=VARCHAR} + + + + + + INSERT INTO guacamole_user_group_member ( + user_group_id, + member_entity_id + ) + SELECT DISTINCT + guacamole_user_group.user_group_id, + #{parent.entityID,jdbcType=INTEGER} + FROM guacamole_user_group + JOIN guacamole_entity ON guacamole_user_group.entity_id = guacamole_entity.entity_id + WHERE + guacamole_entity.name IN + + #{identifier,jdbcType=VARCHAR} + + AND guacamole_entity.type = 'USER_GROUP' + AND guacamole_user_group.user_group_id NOT IN ( + SELECT guacamole_user_group_member.user_group_id + FROM guacamole_user_group_member + WHERE guacamole_user_group_member.member_entity_id = #{parent.entityID,jdbcType=INTEGER} + ) + + +