-
-
Save guiocavalcanti/3854022 to your computer and use it in GitHub Desktop.
Revisions
-
guiocavalcanti revised this gist
Oct 8, 2012 . 1 changed file with 0 additions and 3 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 @@ -10,9 +10,6 @@ def permit end resource :walls do get '/' do permit.able_to?(:read, "something") end -
guiocavalcanti revised this gist
Oct 8, 2012 . 1 changed file with 3 additions and 12 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 @@ -4,26 +4,17 @@ class Wally < Grape::API format :json helpers do def permit @permit ||= Permit::Mechanism.new end end resource :walls do params do requires :token, type: String, desc: "Your api token." end get '/' do permit.able_to?(:read, "something") end end end -
fltiago created this gist
Oct 8, 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,29 @@ require "debugger" class Wally < Grape::API format :json helpers do def current_user @current_user ||= Author.find_by(token: params[:token]) end def authorize!(action) error!('401 Unauthorized', 401) unless current_user and permit.able_to?(:read, action) end def permit @permit ||= Permit::Mechanism.new(:subject_id => current_user.subject_permit, :service_name => "wally") end end resource :walls do params do requires :token, type: String, desc: "Your api token." end get ':resource_id' do authorize!(params[:resource_id]) ... end end end