1 class OauthController < ApplicationController
2 before_filter :login_required, :except => [:request_token, :access_token, :test_request]
3 before_filter :login_or_oauth_required, :only => [:test_request]
4 before_filter :verify_oauth_consumer_signature, :only => [:request_token]
5 before_filter :verify_oauth_request_token, :only => [:access_token]
6 # Uncomment the following if you are using restful_open_id_authentication
7 # skip_before_filter :verify_authenticity_token
10 @token = current_client_application.create_request_token
12 render :text => @token.to_query
14 render :nothing => true, :status => 401
19 @token = current_token && current_token.exchange!
21 render :text => @token.to_query
23 render :nothing => true, :status => 401
28 render :text => params.collect{|k,v|"#{k}=#{v}"}.join("&")
32 @token = RequestToken.find_by_token params[:oauth_token]
33 unless @token.invalidated?
35 if params[:authorize] == '1'
36 @token.authorize!(current_user)
37 redirect_url = params[:oauth_callback] || @token.client_application.callback_url
39 redirect_to "#{redirect_url}?oauth_token=#{@token.token}"
41 render :action => "authorize_success"
43 elsif params[:authorize] == "0"
45 render :action => "authorize_failure"
49 render :action => "authorize_failure"
54 @token = current_user.tokens.find_by_token params[:token]
57 flash[:notice] = "You've revoked the token for #{@token.client_application.name}"
59 redirect_to oauth_clients_url