diff --git a/app/controllers/katello/api/registry/registry_proxies_controller.rb b/app/controllers/katello/api/registry/registry_proxies_controller.rb index 90dbaa8b83f..da42eb53750 100644 --- a/app/controllers/katello/api/registry/registry_proxies_controller.rb +++ b/app/controllers/katello/api/registry/registry_proxies_controller.rb @@ -5,12 +5,13 @@ class Api::Registry::RegistryProxiesController < Api::V2::ApiController before_action :disable_strong_params before_action :confirm_settings skip_before_action :authorize + before_action :token_request_type_check, only: [:token] before_action :optional_authorize, only: [:token, :catalog] before_action :registry_authorize, except: [:token, :v1_search, :catalog, :static_index] before_action :authorize_repository_read, only: [:pull_manifest, :tags_list, :check_blob, :pull_blob] before_action :container_push_prop_validation, only: [:start_upload_blob, :upload_blob, :finish_upload_blob, :push_manifest] before_action :create_container_repo_if_needed, only: [:start_upload_blob, :upload_blob, :finish_upload_blob, :push_manifest] - skip_before_action :check_media_type, only: [:start_upload_blob, :upload_blob, :finish_upload_blob, + skip_before_action :check_media_type, only: [:start_upload_blob, :token, :upload_blob, :finish_upload_blob, :push_manifest] wrap_parameters false @@ -56,6 +57,12 @@ def authenticate_cert_request end end + def token_request_type_check + if request.post? + head :not_found and return + end + end + def redirect_authorization_headers response.headers['Docker-Distribution-API-Version'] = 'registry/2.0' response.headers['Www-Authenticate'] = "Bearer realm=\"#{request_url}/v2/token\"," \