module Api
class CapabilitiesController < ApiController
- before_action :api_deny_access_handler
-
authorize_resource :class => false
around_action :api_call_handle_error, :api_call_timeout
module Api
class ChangesController < ApiController
- before_action :api_deny_access_handler
-
authorize_resource :class => false
before_action :check_api_readable
module Api
class ChangesetCommentsController < ApiController
before_action :authorize
- before_action :api_deny_access_handler
authorize_resource
require "xml/libxml"
before_action :authorize, :only => [:create, :update, :upload, :close, :subscribe, :unsubscribe]
- before_action :api_deny_access_handler, :only => [:create, :update, :upload, :close, :subscribe, :unsubscribe, :expand_bbox]
authorize_resource
module Api
class MapController < ApiController
- before_action :api_deny_access_handler
-
authorize_resource :class => false
before_action :check_api_readable
require "xml/libxml"
before_action :authorize, :only => [:create, :update, :delete]
- before_action :api_deny_access_handler
authorize_resource
before_action :check_api_readable
before_action :setup_user_auth, :only => [:create, :comment, :show]
before_action :authorize, :only => [:close, :reopen, :destroy]
- before_action :api_deny_access_handler
authorize_resource
require "xml/libxml"
before_action :setup_user_auth, :only => [:history, :version]
- before_action :api_deny_access_handler
before_action :authorize, :only => [:redact]
authorize_resource
module Api
class PermissionsController < ApiController
- before_action :api_deny_access_handler
-
authorize_resource :class => false
before_action :check_api_readable
require "xml/libxml"
before_action :authorize, :only => [:create, :update, :delete]
- before_action :api_deny_access_handler
authorize_resource
module Api
class TracepointsController < ApiController
- before_action :api_deny_access_handler
-
authorize_resource
before_action :check_api_readable
before_action :authorize_web
before_action :set_locale
before_action :authorize
- before_action :api_deny_access_handler
authorize_resource
before_action :disable_terms_redirect, :only => [:api_details]
before_action :authorize, :only => [:api_details, :api_gpx_files]
- before_action :api_deny_access_handler
authorize_resource
require "xml/libxml"
before_action :authorize, :only => [:create, :update, :delete]
- before_action :api_deny_access_handler
authorize_resource
class ApiController < ApplicationController
skip_before_action :verify_authenticity_token
+
+ def deny_access(_exception)
+ if current_token
+ set_locale
+ report_error t("oauth.permissions.missing"), :forbidden
+ elsif current_user
+ head :forbidden
+ else
+ realm = "Web Password"
+ errormessage = "Couldn't authenticate you"
+ response.headers["WWW-Authenticate"] = "Basic realm=\"#{realm}\""
+ render :plain => errormessage, :status => :unauthorized
+ end
+ end
end
end
end
- def deny_access(exception)
- if @api_deny_access_handling
- api_deny_access(exception)
- else
- web_deny_access(exception)
- end
- end
-
- def web_deny_access(_exception)
+ def deny_access(_exception)
if current_token
set_locale
report_error t("oauth.permissions.missing"), :forbidden
end
end
- def api_deny_access(_exception)
- if current_token
- set_locale
- report_error t("oauth.permissions.missing"), :forbidden
- elsif current_user
- head :forbidden
- else
- realm = "Web Password"
- errormessage = "Couldn't authenticate you"
- response.headers["WWW-Authenticate"] = "Basic realm=\"#{realm}\""
- render :plain => errormessage, :status => :unauthorized
- end
- end
-
- attr_accessor :api_access_handling
-
- def api_deny_access_handler
- @api_deny_access_handling = true
- end
-
private
# extract authorisation credentials from headers, returns user = nil if none