diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2016-10-14 14:09:12 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@sonarsource.com> | 2016-10-16 19:10:47 +0200 |
commit | 63ce1a3671fb71e25f77915c6db201eccd766d5e (patch) | |
tree | 29210d9eed750a1c0fedcec432f97d3414a53d99 /sonar-db | |
parent | 0021e9357ab965230305a8e2fb0a1494ea45ef13 (diff) | |
download | sonarqube-63ce1a3671fb71e25f77915c6db201eccd766d5e.tar.gz sonarqube-63ce1a3671fb71e25f77915c6db201eccd766d5e.zip |
SONAR-8134 refactor SQL to check organization permission
Diffstat (limited to 'sonar-db')
-rw-r--r-- | sonar-db/src/main/resources/org/sonar/db/permission/AuthorizationMapper.xml | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/sonar-db/src/main/resources/org/sonar/db/permission/AuthorizationMapper.xml b/sonar-db/src/main/resources/org/sonar/db/permission/AuthorizationMapper.xml index 0dbb5162cbf..d819a2b2294 100644 --- a/sonar-db/src/main/resources/org/sonar/db/permission/AuthorizationMapper.xml +++ b/sonar-db/src/main/resources/org/sonar/db/permission/AuthorizationMapper.xml @@ -6,11 +6,23 @@ <select id="selectOrganizationPermissions" parameterType="map" resultType="string"> select gr.role from group_roles gr + inner join groups_users gu on gr.group_id=gu.group_id where gr.organization_uuid=#{organizationUuid,jdbcType=VARCHAR} and gr.resource_id is null and - (gr.group_id is null or gr.group_id in (select gu.group_id from groups_users gu where gu.user_id=#{userId,jdbcType=BIGINT})) + gu.user_id=#{userId,jdbcType=BIGINT} + union + + select gr.role + from group_roles gr + where + gr.organization_uuid=#{organizationUuid,jdbcType=VARCHAR} and + gr.group_id is null and + gr.resource_id is null + + union + select ur.role from user_roles ur where @@ -30,10 +42,20 @@ <select id="selectRootComponentPermissions" parameterType="map" resultType="string"> select gr.role from group_roles gr + inner join groups_users gu on gr.group_id=gu.group_id where gr.resource_id=#{rootComponentId,jdbcType=BIGINT} and - (gr.group_id is null or gr.group_id in (select gu.group_id from groups_users gu where gu.user_id=#{userId,jdbcType=BIGINT})) + gu.user_id=#{userId,jdbcType=BIGINT} + union + select gr.role + from group_roles gr + where + gr.resource_id=#{rootComponentId,jdbcType=BIGINT} and + gr.group_id is null + + union + select ur.role from user_roles ur where |