SECURITY: don't grant same privileges to user_api and api access

User API is no longer gets bypasses that standard API gets.
Only bypasses are CSRF and XHR requirements.
This commit is contained in:
Sam
2016-12-16 12:05:20 +11:00
parent 40fc83843b
commit e23af6eea4
6 changed files with 24 additions and 6 deletions
+2 -2
View File
@@ -25,7 +25,7 @@ class ApplicationController < ActionController::Base
# and then raising a CSRF exception
def handle_unverified_request
# NOTE: API key is secret, having it invalidates the need for a CSRF token
unless is_api?
unless is_api? || is_user_api?
super
clear_current_user
render text: "['BAD CSRF']", status: 403
@@ -501,7 +501,7 @@ class ApplicationController < ActionController::Base
def check_xhr
# bypass xhr check on PUT / POST / DELETE provided api key is there, otherwise calling api is annoying
return if !request.get? && is_api?
return if !request.get? && (is_api? || is_user_api?)
raise RenderEmpty.new unless ((request.format && request.format.json?) || request.xhr?)
end