1 class OauthController < ApplicationController
4 before_filter :authorize_web, :only => [:oauthorize, :revoke]
5 before_filter :set_locale, :only => [:oauthorize, :revoke]
6 before_filter :require_user, :only => [:oauthorize]
7 before_filter :verify_oauth_consumer_signature, :only => [:request_token]
8 before_filter :verify_oauth_request_token, :only => [:access_token]
9 # Uncomment the following if you are using restful_open_id_authentication
10 # skip_before_filter :verify_authenticity_token
13 @token = current_client_application.create_request_token
15 logger.info "in REQUEST TOKEN"
17 logger.info "request token params: #{params.inspect}"
18 # request tokens indicate what permissions the client *wants*, not
19 # necessarily the same as those which the user allows.
20 current_client_application.permissions.each do |pref|
21 logger.info "PARAMS found #{pref}"
22 @token.write_attribute(pref, true)
26 render :text => @token.to_query
28 render :nothing => true, :status => 401
33 @token = current_token && current_token.exchange!
35 render :text => @token.to_query
37 render :nothing => true, :status => 401
42 @token = RequestToken.find_by_token params[:oauth_token]
43 unless @token.invalidated?
46 @token.client_application.permissions.each do |pref|
48 logger.info "OAUTHORIZE PARAMS found #{pref}"
49 @token.write_attribute(pref, true)
52 @token.write_attribute(pref, false)
57 @token.authorize!(@user)
58 redirect_url = params[:oauth_callback] || @token.client_application.callback_url
60 redirect_to "#{redirect_url}?oauth_token=#{@token.token}"
62 render :action => "authorize_success"
66 render :action => "authorize_failure"
70 render :action => "authorize_failure"
75 @token = @user.oauth_tokens.find_by_token params[:token]
78 flash[:notice] = "You've revoked the token for #{@token.client_application.name}"
80 logger.info "about to redirect"
81 redirect_to :controller => 'oauth_clients', :action => 'index'