diff options
author | Julien Lancelot <julien.lancelot@sonarsource.com> | 2016-06-22 17:04:00 +0200 |
---|---|---|
committer | Julien Lancelot <julien.lancelot@sonarsource.com> | 2016-06-29 08:41:53 +0200 |
commit | a2c1cc8cd4a407aba13d733330fb5308a1f5168e (patch) | |
tree | 2b78735a56bc4f31167a0837f3717d92859a2840 /server/sonar-web/src/main/webapp/WEB-INF/app | |
parent | b91b2032f4b4814812fd6d0a40bce8a0e85d0870 (diff) | |
download | sonarqube-a2c1cc8cd4a407aba13d733330fb5308a1f5168e.tar.gz sonarqube-a2c1cc8cd4a407aba13d733330fb5308a1f5168e.zip |
SONAR-7796 Rewrite /api/authentication/validate in Java
Diffstat (limited to 'server/sonar-web/src/main/webapp/WEB-INF/app')
-rw-r--r-- | server/sonar-web/src/main/webapp/WEB-INF/app/controllers/api/authentication_controller.rb | 70 |
1 files changed, 0 insertions, 70 deletions
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/api/authentication_controller.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/api/authentication_controller.rb deleted file mode 100644 index a55e5363ac9..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/api/authentication_controller.rb +++ /dev/null @@ -1,70 +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 Api::AuthenticationController < Api::ApiController - skip_before_filter :check_authentication, :set_user_session - - # prevent HTTP proxies from caching authentication status - before_filter :set_cache_buster - - # - # GET /api/authentication/validate - # curl http://localhost:9000/api/authentication/validate -v -u admin:admin - # - # Since v.3.3 - def validate - hash={:valid => valid?} - - # make sure no authentication information is left by - # this validation - reset_session - - respond_to do |format| - format.json { render :json => jsonp(hash) } - format.xml { render :xml => hash.to_xml(:skip_types => true, :root => 'authentication') } - format.text { render :text => text_not_supported } - end - end - - private - - def valid? - begin - logged_in? || (!force_authentication? && anonymous?) - rescue Errors::AccessDenied - false - end - end - - def force_authentication? - property = Property.by_key(org.sonar.api.CoreProperties.CORE_FORCE_AUTHENTICATION_PROPERTY) - property ? property.value == 'true' : false - end - - def anonymous? - current_user.nil? - end - - def set_cache_buster - response.headers["Cache-Control"] = "no-cache, no-store, max-age=0, must-revalidate" - response.headers["Pragma"] = "no-cache" - response.headers["Expires"] = "Fri, 01 Jan 1990 00:00:00 GMT" - end - -end |