From 38c6a803fb039c12565b3a51a2cbfbaf80958507 Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Thu, 9 Jun 2016 15:33:43 +0200 Subject: [PATCH] Remove support of unused property sonar.authorizer in ruby code --- .../lib/authorization/all_pass_authorizer.rb | 33 ----------------- .../lib/authorization/logged_in_authorizer.rb | 35 ------------------- .../{authorization => }/default_authorizer.rb | 2 +- .../webapp/WEB-INF/lib/need_authorization.rb | 14 ++------ 4 files changed, 4 insertions(+), 80 deletions(-) delete mode 100644 server/sonar-web/src/main/webapp/WEB-INF/lib/authorization/all_pass_authorizer.rb delete mode 100644 server/sonar-web/src/main/webapp/WEB-INF/lib/authorization/logged_in_authorizer.rb rename server/sonar-web/src/main/webapp/WEB-INF/lib/{authorization => }/default_authorizer.rb (99%) diff --git a/server/sonar-web/src/main/webapp/WEB-INF/lib/authorization/all_pass_authorizer.rb b/server/sonar-web/src/main/webapp/WEB-INF/lib/authorization/all_pass_authorizer.rb deleted file mode 100644 index fe7c9b8e516..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/lib/authorization/all_pass_authorizer.rb +++ /dev/null @@ -1,33 +0,0 @@ -# -# SonarQube, open source software quality management tool. -# Copyright (C) 2008-2014 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 3 of the License, or (at your option) any later version. -# -# SonarQube is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with this program; if not, write to the Free Software Foundation, -# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# - -class SonarAuthorizer - def has_role?(user, role) - true - end - - def has_role_for_resources?(user, role, resource_ids) - resource_ids.map{|rid| true} - end - - def on_logout(user) - - end -end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/lib/authorization/logged_in_authorizer.rb b/server/sonar-web/src/main/webapp/WEB-INF/lib/authorization/logged_in_authorizer.rb deleted file mode 100644 index ce7d0b7b831..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/lib/authorization/logged_in_authorizer.rb +++ /dev/null @@ -1,35 +0,0 @@ -# -# SonarQube, open source software quality management tool. -# Copyright (C) 2008-2014 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 3 of the License, or (at your option) any later version. -# -# SonarQube is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with this program; if not, write to the Free Software Foundation, -# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# - -class SonarAuthorizer - - def has_role?(user, role) - !user.id.nil? - end - - def has_role_for_resources?(user, role, resource_ids) - authorized=has_role?(user, role) - resource_ids.map{|rid| authorized} - end - - def on_logout(user) - - end -end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/lib/authorization/default_authorizer.rb b/server/sonar-web/src/main/webapp/WEB-INF/lib/default_authorizer.rb similarity index 99% rename from server/sonar-web/src/main/webapp/WEB-INF/lib/authorization/default_authorizer.rb rename to server/sonar-web/src/main/webapp/WEB-INF/lib/default_authorizer.rb index 2b1de852d15..6a2330139dd 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/lib/authorization/default_authorizer.rb +++ b/server/sonar-web/src/main/webapp/WEB-INF/lib/default_authorizer.rb @@ -19,7 +19,7 @@ # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # -class SonarAuthorizer +class DefaultAuthorizer def has_role?(user, role) global_roles(user).include?(role) diff --git a/server/sonar-web/src/main/webapp/WEB-INF/lib/need_authorization.rb b/server/sonar-web/src/main/webapp/WEB-INF/lib/need_authorization.rb index 118a48e4029..08d1a327b71 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/lib/need_authorization.rb +++ b/server/sonar-web/src/main/webapp/WEB-INF/lib/need_authorization.rb @@ -18,21 +18,13 @@ # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # -# -# This class loads your own authorization service from the configuration -# in the sonar.properties file. -# The property is sonar.authorizer=[Your service file name]. -# Before that you should put your service file into the lib/authorization directory. -# The service class must be named SonarAuthorizer. -# class AuthorizerFactory @@authorizer = nil def self.authorizer if (@@authorizer.nil?) - filename = Java::OrgSonarServerUi::JRubyFacade.new.getConfigurationValue('sonar.authorizer') || 'default_authorizer' - require File.dirname(__FILE__) + "/authorization/#{filename}" - @@authorizer ||= SonarAuthorizer.new + require File.dirname(__FILE__) + "/default_authorizer" + @@authorizer ||= DefaultAuthorizer.new end @@authorizer end @@ -40,7 +32,7 @@ class AuthorizerFactory end # NeedAuthorization is a set of modules that enhance your models and controller classes in authorization function. -# All the methods in this module will finally delegate to the loaded SonarAuthorizer. +# All the methods in this module will finally delegate to the loaded DefaultAuthorizer. module NeedAuthorization # ForUser module is used for the User class, to decide if the user has certain "global" permissions. -- 2.39.5