aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sonar-core/src/main/resources/org/sonar/core/persistence/rows-h2.sql2
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/controllers/batch_bootstrap_controller.rb4
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/db/migrate/414_add_scan_and_dry_run_permissions.rb43
3 files changed, 7 insertions, 42 deletions
diff --git a/sonar-core/src/main/resources/org/sonar/core/persistence/rows-h2.sql b/sonar-core/src/main/resources/org/sonar/core/persistence/rows-h2.sql
index c0e5e0cb2a7..dbac000ea11 100644
--- a/sonar-core/src/main/resources/org/sonar/core/persistence/rows-h2.sql
+++ b/sonar-core/src/main/resources/org/sonar/core/persistence/rows-h2.sql
@@ -8,7 +8,7 @@ INSERT INTO GROUP_ROLES(ID, GROUP_ID, RESOURCE_ID, ROLE) VALUES (1, 1, null, 'ad
INSERT INTO GROUP_ROLES(ID, GROUP_ID, RESOURCE_ID, ROLE) VALUES (2, 1, null, 'profileadmin');
INSERT INTO GROUP_ROLES(ID, GROUP_ID, RESOURCE_ID, ROLE) VALUES (3, 1, null, 'shareDashboard');
INSERT INTO GROUP_ROLES(ID, GROUP_ID, RESOURCE_ID, ROLE) VALUES (4, null, null, 'scan');
-INSERT INTO GROUP_ROLES(ID, GROUP_ID, RESOURCE_ID, ROLE) VALUES (5, null, null, 'dryrun');
+INSERT INTO GROUP_ROLES(ID, GROUP_ID, RESOURCE_ID, ROLE) VALUES (5, null, null, 'dryRunScan');
ALTER TABLE GROUP_ROLES ALTER COLUMN ID RESTART WITH 6;
INSERT INTO GROUPS_USERS(USER_ID, GROUP_ID) VALUES (1, 1);
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/batch_bootstrap_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/batch_bootstrap_controller.rb
index 4c6de01d129..77b709dec77 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/batch_bootstrap_controller.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/batch_bootstrap_controller.rb
@@ -26,7 +26,7 @@ class BatchBootstrapController < Api::ApiController
# GET /batch_bootstrap/db?project=<key or id>
def db
- has_dryrun_role = has_role?(:dryrun)
+ has_dryrun_role = has_role?(:dryRunScan)
return render_unauthorized("You're not authorized to execute a dry run analysis. Please contact your SonarQube administrator.") if !has_dryrun_role
project = load_project()
return render_unauthorized("You're not authorized to access to project '" + project.name + "', please contact your SonarQube administrator") if project && !has_role?(:user, project)
@@ -38,7 +38,7 @@ class BatchBootstrapController < Api::ApiController
# GET /batch_bootstrap/properties?[project=<key or id>][&dryRun=true|false]
def properties
dryRun = params[:dryRun].present? && params[:dryRun] == "true"
- has_dryrun_role = has_role?(:dryrun)
+ has_dryrun_role = has_role?(:dryRunScan)
has_scan_role = has_role?(:scan)
return render_unauthorized("You're not authorized to execute any SonarQube analysis. Please contact your SonarQube administrator.") if (!has_dryrun_role && !has_scan_role)
diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/414_add_scan_and_dry_run_permissions.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/414_add_scan_and_dry_run_permissions.rb
index 27772af1601..cd00678468f 100644
--- a/sonar-server/src/main/webapp/WEB-INF/db/migrate/414_add_scan_and_dry_run_permissions.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/db/migrate/414_add_scan_and_dry_run_permissions.rb
@@ -30,50 +30,15 @@ class AddScanAndDryRunPermissions < ActiveRecord::Migration
class UserRole < ActiveRecord::Base
end
-
+
def self.up
# -- Role scan --
- group_roles=GroupRole.find(:all, :conditions => {:role => 'admin', :resource_id => nil})
- groups = group_roles.map { |ur| ur.group_id }
# Anyone
- unless groups.include?(nil)
- groups << nil
- end
- groups.each do |group_id|
- GroupRole.create(:group_id => group_id, :role => 'scan', :resource_id => nil)
- end
+ GroupRole.create(:group_id => nil, :role => 'scan', :resource_id => nil)
- user_roles=UserRole.find(:all, :conditions => {:role => 'admin', :resource_id => nil})
- users = user_roles.map { |ur| ur.user_id }
- users.each do |user_id|
- UserRole.create(:user_id => user_id, :role=> 'scan', :resource_id => nil)
- end
-
- # -- Role dryrun --
- group_roles=GroupRole.find(:all, :conditions => {:role => 'admin', :resource_id => nil})
- groups = group_roles.map { |ur| ur.group_id }
+ # -- Role dryRunScan --
# Anyone
- unless groups.include?(nil)
- groups << nil
- end
- # sonar-users
- userGroupName = Property.by_key('sonar.defaultGroup')
- userGroupName = 'sonar-users' if userGroupName.nil?
- userGroup = Group.find(:all, :conditions => {:name => userGroupName}).first
- unless userGroup.nil? || groups.include?(userGroup.id)
- groups << userGroup.id
- end
-
- groups.each do |group_id|
- GroupRole.create(:group_id => group_id, :role => 'dryrun', :resource_id => nil)
- end
-
- user_roles=UserRole.find(:all, :conditions => {:role => 'admin', :resource_id => nil})
- users = user_roles.map { |ur| ur.user_id }
- users.each do |user_id|
- UserRole.create(:user_id => user_id, :role=> 'dryrun', :resource_id => nil)
- end
-
+ GroupRole.create(:group_id => nil, :role => 'dryRunScan', :resource_id => nil)
end
end