Created
April 20, 2012 19:40
-
-
Save zerobearing2/2431247 to your computer and use it in GitHub Desktop.
Revisions
-
zerobearing2 revised this gist
Apr 20, 2012 . 1 changed file with 10 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,13 @@ # Overload rails 3.2.x default HTTP Baisc 401 response # to JSON instead of plain text/html. # # Examples # # require 'json_401' # class ApiController < ActionController::Metal # ... # end # module ActionController::HttpAuthentication::Basic def authentication_request(controller, realm) -
zerobearing2 renamed this gist
Apr 20, 2012 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
zerobearing2 created this gist
Apr 20, 2012 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,10 @@ module ActionController::HttpAuthentication::Basic def authentication_request(controller, realm) controller.headers["WWW-Authenticate"] = %(Basic realm="#{realm.gsub(/"/, "")}") controller.response.headers["Content-Type"] = "application/json" controller.response_body = {error: "Access denied."}.to_json controller.status = 401 end end