Module: OAuth::Controllers::ProviderController
- Defined in:
- lib/oauth/controllers/provider_controller.rb
Class Method Summary collapse
Instance Method Summary collapse
- #access_token ⇒ Object
- #authorize ⇒ Object
- #request_token ⇒ Object
- #revoke ⇒ Object
- #test_request ⇒ Object
Class Method Details
.included(controller) ⇒ Object
5 6 7 8 9 10 11 12 13 |
# File 'lib/oauth/controllers/provider_controller.rb', line 5 def self.included(controller) controller.class_eval do before_filter :login_required, :except => [:request_token, :access_token, :test_request] before_filter :login_or_oauth_required, :only => [:test_request] before_filter :verify_oauth_consumer_signature, :only => [:request_token] before_filter :verify_oauth_request_token, :only => [:access_token] skip_before_filter :verify_authenticity_token end end |
Instance Method Details
#access_token ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/oauth/controllers/provider_controller.rb', line 24 def access_token @token = current_token && current_token.exchange! if @token render :text => @token.to_query else render :nothing => true, :status => 401 end end |
#authorize ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/oauth/controllers/provider_controller.rb', line 37 def @token = ::RequestToken.find_by_token params[:oauth_token] unless @token.invalidated? if request.post? if params[:authorize] == '1' @token.(current_user) if @token.oauth10? @redirect_url = params[:oauth_callback] || @token.client_application.callback_url else @redirect_url = @token.oob? ? @token.client_application.callback_url : @token.callback_url end if @redirect_url if @token.oauth10? redirect_to "#{@redirect_url}?oauth_token=#{@token.token}" else redirect_to "#{@redirect_url}?oauth_token=#{@token.token}&oauth_verifier=#{@token.verifier}" end else render :action => "authorize_success" end elsif params[:authorize] == "0" @token.invalidate! render :action => "authorize_failure" end end else render :action => "authorize_failure" end end |
#request_token ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/oauth/controllers/provider_controller.rb', line 15 def request_token @token = current_client_application.create_request_token if @token render :text => @token.to_query else render :nothing => true, :status => 401 end end |
#revoke ⇒ Object
68 69 70 71 72 73 74 75 |
# File 'lib/oauth/controllers/provider_controller.rb', line 68 def revoke @token = current_user.tokens.find_by_token params[:token] if @token @token.invalidate! flash[:notice] = "You've revoked the token for #{@token.client_application.name}" end redirect_to oauth_clients_url end |
#test_request ⇒ Object
33 34 35 |
# File 'lib/oauth/controllers/provider_controller.rb', line 33 def test_request render :text => params.collect{|k,v|"#{k}=#{v}"}.join("&") end |