Files

OAuth::Controllers::ProviderController

Public Class Methods

included(controller) click to toggle source
    # File lib/oauth/controllers/provider_controller.rb, line 5
 5:       def self.included(controller)
 6:         controller.class_eval do
 7:           before_filter :login_required, :only => [:authorize,:revoke]
 8:           before_filter :login_or_oauth_required, :only => [:test_request]
 9:           before_filter :oauth_required, :only => [:invalidate,:capabilities]
10:           before_filter :verify_oauth_consumer_signature, :only => [:request_token]
11:           before_filter :verify_oauth_request_token, :only => [:access_token]
12:           skip_before_filter :verify_authenticity_token, :only=>[:request_token, :access_token, :invalidate, :test_request]
13:         end
14:       end

Public Instance Methods

access_token() click to toggle source
    # File lib/oauth/controllers/provider_controller.rb, line 25
25:       def access_token
26:         @token = current_token && current_token.exchange!
27:         if @token
28:           render :text => @token.to_query
29:         else
30:           render :nothing => true, :status => 401
31:         end
32:       end
authorize() click to toggle source
    # File lib/oauth/controllers/provider_controller.rb, line 38
38:       def authorize
39:         @token = ::RequestToken.find_by_token params[:oauth_token]
40:         unless @token
41:           render :action=>"authorize_failure"
42:           return
43:         end
44:         
45:         unless @token.invalidated?    
46:           if request.post? 
47:             if user_authorizes_token?
48:               @token.authorize!(current_user)
49:               if @token.oauth10?
50:                 @redirect_url = params[:oauth_callback] || @token.client_application.callback_url
51:               else
52:                 @redirect_url = @token.oob? ? @token.client_application.callback_url : @token.callback_url
53:               end
54:               
55:               if @redirect_url
56:                 if @token.oauth10?
57:                   redirect_to "#{@redirect_url}?oauth_token=#{@token.token}"
58:                 else
59:                   redirect_to "#{@redirect_url}?oauth_token=#{@token.token}&oauth_verifier=#{@token.verifier}"
60:                 end
61:               else
62:                 render :action => "authorize_success"
63:               end
64:             else
65:               @token.invalidate!
66:               render :action => "authorize_failure"
67:             end
68:           end
69:         else
70:           render :action => "authorize_failure"
71:         end
72:       end
capabilities() click to toggle source

Capabilities of current_token

     # File lib/oauth/controllers/provider_controller.rb, line 90
 90:       def capabilities
 91:         if current_token.respond_to?(:capabilities)
 92:           @capabilities=current_token.capabilities
 93:         else
 94:           @capabilities={:invalidate=>url_for(:action=>:invalidate)}
 95:         end
 96:         
 97:         respond_to do |format|
 98:           format.json {render :json=>@capabilities}
 99:           format.xml {render :xml=>@capabilities}
100:         end
101:       end
invalidate() click to toggle source

Invalidate current token

    # File lib/oauth/controllers/provider_controller.rb, line 84
84:       def invalidate
85:         current_token.invalidate!
86:         head :status=>410
87:       end
request_token() click to toggle source
    # File lib/oauth/controllers/provider_controller.rb, line 16
16:       def request_token
17:         @token = current_client_application.create_request_token
18:         if @token
19:           render :text => @token.to_query
20:         else
21:           render :nothing => true, :status => 401
22:         end
23:       end
revoke() click to toggle source
    # File lib/oauth/controllers/provider_controller.rb, line 74
74:       def revoke
75:         @token = current_user.tokens.find_by_token params[:token]
76:         if @token
77:           @token.invalidate!
78:           flash[:notice] = "You've revoked the token for #{@token.client_application.name}"
79:         end
80:         redirect_to oauth_clients_url
81:       end
test_request() click to toggle source
    # File lib/oauth/controllers/provider_controller.rb, line 34
34:       def test_request
35:         render :text => params.collect{|k,v|"#{k}=#{v}"}.join("&")
36:       end

Protected Instance Methods

user_authorizes_token?() click to toggle source

Override this to match your authorization page form

     # File lib/oauth/controllers/provider_controller.rb, line 106
106:       def user_authorizes_token?
107:         params[:authorize] == '1'
108:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.