GUACAMOLE-715: Include all provided effective user groups that exist within the database in results of effective groups query, regardless of whether the user is declared as a member of those groups within the database.

While this query is generally functioning as described above for all
supported databases, it is not functioning properly for the
non-recursive variant of the MySQL/MariaDB query. This change corrects
that behavior.
This commit is contained in:
Michael Jumper
2019-04-21 12:01:31 -07:00
parent 3c9302f040
commit 61b6664eac

View File

@@ -73,27 +73,31 @@
JOIN guacamole_user_group_member ON guacamole_user_group.user_group_id = guacamole_user_group_member.user_group_id JOIN guacamole_user_group_member ON guacamole_user_group.user_group_id = guacamole_user_group_member.user_group_id
WHERE WHERE
guacamole_user_group.disabled = false guacamole_user_group.disabled = false
AND ( AND guacamole_user_group_member.member_entity_id = #{entity.entityID}
guacamole_user_group_member.member_entity_id = #{entity.entityID} <if test="!effectiveGroups.isEmpty()">
<if test="!effectiveGroups.isEmpty()"> UNION SELECT
OR guacamole_user_group_member.member_entity_id IN ( guacamole_entity.name
SELECT entity_id FROM guacamole_entity FROM guacamole_user_group
WHERE type = 'USER_GROUP' AND name IN JOIN guacamole_entity ON guacamole_user_group.entity_id = guacamole_entity.entity_id
<foreach collection="effectiveGroups" item="effectiveGroup" JOIN guacamole_user_group_member ON guacamole_user_group.user_group_id = guacamole_user_group_member.user_group_id
open="(" separator="," close=")"> JOIN guacamole_entity member_entity ON guacamole_user_group_member.member_entity_id = member_entity.entity_id
#{effectiveGroup,jdbcType=VARCHAR} WHERE
</foreach> guacamole_user_group.disabled = false
) AND member_entity.type = 'USER_GROUP' AND member_entity.name IN
OR guacamole_user_group.entity_id IN ( <foreach collection="effectiveGroups" item="effectiveGroup"
SELECT entity_id FROM guacamole_entity open="(" separator="," close=")">
WHERE type = 'USER_GROUP' AND name IN #{effectiveGroup,jdbcType=VARCHAR}
<foreach collection="effectiveGroups" item="effectiveGroup" </foreach>
open="(" separator="," close=")"> UNION SELECT
#{effectiveGroup,jdbcType=VARCHAR} guacamole_entity.name
</foreach> FROM guacamole_user_group
) JOIN guacamole_entity ON guacamole_user_group.entity_id = guacamole_entity.entity_id
</if> WHERE type = 'USER_GROUP' AND name IN
) <foreach collection="effectiveGroups" item="effectiveGroup"
open="(" separator="," close=")">
#{effectiveGroup,jdbcType=VARCHAR}
</foreach>
</if>
</if> </if>
<if test="recursive"> <if test="recursive">