diff options
Diffstat (limited to 'app/controllers/application_controller.rb')
-rw-r--r-- | app/controllers/application_controller.rb | 48 |
1 files changed, 8 insertions, 40 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 353f9098b95..9749af08dca 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -29,11 +29,9 @@ class ApplicationController < ActionController::Base before_action :limit_session_time, if: -> { !current_user } before_action :authenticate_user!, except: [:route_not_found] before_action :enforce_terms!, if: :should_enforce_terms? - before_action :validate_user_service_ticket! before_action :check_password_expiration, if: :html_request? before_action :ldap_security_check before_action :default_headers - before_action :default_cache_headers before_action :add_gon_variables, if: :html_request? before_action :configure_permitted_parameters, if: :devise_controller? before_action :require_email, unless: :devise_controller? @@ -61,12 +59,10 @@ class ApplicationController < ActionController::Base helper_method :can? helper_method :import_sources_enabled?, :github_import_enabled?, :gitea_import_enabled?, :github_import_configured?, - :gitlab_import_enabled?, :gitlab_import_configured?, :bitbucket_import_enabled?, :bitbucket_import_configured?, :bitbucket_server_import_enabled?, :fogbugz_import_enabled?, :git_import_enabled?, :gitlab_project_import_enabled?, - :manifest_import_enabled?, :phabricator_import_enabled?, - :masked_page_url + :manifest_import_enabled?, :masked_page_url def self.endpoint_id_for_action(action_name) "#{name}##{action_name}" @@ -90,7 +86,7 @@ class ApplicationController < ActionController::Base render_403 end - rescue_from Gitlab::Auth::IpBlacklisted do + rescue_from Gitlab::Auth::IpBlocked do Gitlab::AuthLogger.error( message: 'Rack_Attack', env: :blocklist, @@ -112,6 +108,11 @@ class ApplicationController < ActionController::Base render plain: e.message, status: :too_many_requests end + rescue_from Gitlab::Git::ResourceExhaustedError do |e| + response.headers.merge!(e.headers) + render plain: e.message, status: :too_many_requests + end + content_security_policy do |p| next if p.directives.blank? next unless Gitlab::CurrentSettings.snowplow_enabled? && !Gitlab::CurrentSettings.snowplow_collector_hostname.blank? @@ -260,10 +261,7 @@ class ApplicationController < ActionController::Base respond_to do |format| format.html do - render template, - layout: "errors", - status: status, - locals: { message: message } + render template, layout: "errors", status: status, locals: { message: message } end format.any { head status } end @@ -319,10 +317,6 @@ class ApplicationController < ActionController::Base headers['X-Content-Type-Options'] = 'nosniff' end - def default_cache_headers - headers['Pragma'] = 'no-cache' # HTTP 1.0 compatibility - end - def stream_csv_headers(csv_filename) no_cache_headers stream_headers @@ -331,20 +325,6 @@ class ApplicationController < ActionController::Base headers['Content-Disposition'] = "attachment; filename=\"#{csv_filename}\"" end - def validate_user_service_ticket! - return unless signed_in? && session[:service_tickets] - - valid = session[:service_tickets].all? do |provider, ticket| - Gitlab::Auth::OAuth::Session.valid?(provider, ticket) - end - - unless valid - session[:service_tickets] = nil - sign_out current_user - redirect_to new_user_session_path - end - end - def check_password_expiration return if session[:impersonator_id] || !current_user&.allow_password_authentication? @@ -452,14 +432,6 @@ class ApplicationController < ActionController::Base Gitlab::Auth::OAuth::Provider.enabled?(:github) end - def gitlab_import_enabled? - request.host != 'gitlab.com' && Gitlab::CurrentSettings.import_sources.include?('gitlab') - end - - def gitlab_import_configured? - Gitlab::Auth::OAuth::Provider.enabled?(:gitlab) - end - def bitbucket_import_enabled? Gitlab::CurrentSettings.import_sources.include?('bitbucket') end @@ -484,10 +456,6 @@ class ApplicationController < ActionController::Base Gitlab::CurrentSettings.import_sources.include?('manifest') end - def phabricator_import_enabled? - Gitlab::PhabricatorImport.available? - end - # U2F (universal 2nd factor) devices need a unique identifier for the application # to perform authentication. # https://developers.yubico.com/U2F/App_ID.html |