<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1 +1,7 @@
-I am a sample OAuth provider built against a vanilla Rails 2.0.x app that does not use acts_as_authenticated.  It merely shows how your application could be OAuth-enabled and does not validate tokens or do anything particularly fancy with them.
+I am a sample OAuth provider built against a vanilla Rails 2.0.x app that does
+not use acts_as_authenticated. It merely shows how your application could be
+OAuth-enabled and does not validate tokens or do anything particularly fancy
+with them.
+
+Note: this is effectively pseudo-code, so don't expect it to work out of the
+box.</diff>
      <filename>README</filename>
    </modified>
    <modified>
      <diff>@@ -21,14 +21,19 @@ protected
     @oauth_consumer
   end
 
+  def oauth_request_proxy
+    @oauth_request_proxy
+  end
+
   def oauth_token
     @oauth_token
   end
 
   # verifies a request token request
   def verify_oauth_consumer_signature
-    valid = OAuth::Signature.verify(request) do |token, consumer_key|
-      @oauth_consumer = OauthConsumer.find_by_key(consumer_key)
+    valid = OAuth::Signature.verify(request) do |request_proxy|
+      @request_proxy = request_proxy
+      @oauth_consumer = OauthConsumer.find_by_key(request_proxy.oauth_consumer_key)
 
       # return the token secret and the consumer secret
       [nil, oauth_consumer.secret]
@@ -52,8 +57,9 @@ private
 
   # Implement this for your own application using app-specific models
   def verify_oauth_signature
-    valid = OAuth::Signature.verify(request) do |token|
-      @oauth_token = OauthToken.find_by_token(token, :include =&gt; :consumer)
+    valid = OAuth::Signature.verify(request) do |request_proxy|
+      @request_proxy = request_proxy
+      @oauth_token = OauthToken.find_by_token(request_proxy.oauth_token, :include =&gt; :consumer)
       @oauth_consumer = @oauth_token.consumer
 
       # return the token secret and the consumer secret</diff>
      <filename>app/controllers/application.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,32 +1,49 @@
 class OauthController &lt; ApplicationController
   before_filter :verify_oauth_consumer_signature, :only =&gt; :request_token
   before_filter :verify_oauth_request_token,      :only =&gt; :access_token
-  
+
   def access_token
     # TODO this does a straight token exchange
     # in a real application, you'd want to ensure that the request token has been authorized
-    
+
     consumer = oauth_token.consumer
-    
+
+    # check the verifier
+    raise Exception if oauth_token.verifier != oauth_request_proxy.oauth_verifier
+
     # destroy the existing request token
     oauth_token.destroy
-    
+
     # create a new access token
     # this is where an existing access token for an app would be loaded in order to share it between devices
     token = consumer.access_tokens.create!
-      
+
     render :text =&gt; &quot;oauth_token=#{token.token}&amp;oauth_token_secret=#{token.secret}&quot;
   end
-  
+
   def authorize
     # TODO implement me
+
+    token = OauthRequestToken.find_by_token(params[:oauth_token])
+
+    return unless request.post?
+
+    # generate a random 16-character string
+    chars = (&quot;0&quot;..&quot;9&quot;).to_a + (&quot;a&quot;..&quot;z&quot;).to_a
+    s = &quot;&quot;
+    16.times { s &lt;&lt; chars[rand(36)] }
+
+    token.update_attributes(:validated =&gt; true, :verifier =&gt; s)
+
+    # Note: this doesn't work for callbacks that already contain ?'s
+    redirect_to token.callback_url + &quot;?oauth_verifier=#{s}&quot;
   end
-  
+
   def request_token
     consumer = OauthConsumer.find(:first)
-    
-    token = consumer.request_tokens.create!
-    
-    render :text =&gt; &quot;oauth_token=#{token.token}&amp;oauth_token_secret=#{token.secret}&quot;
+
+    token = consumer.request_tokens.create!(:callback_url =&gt; oauth_request_proxy.oauth_callback)
+
+    render :text =&gt; &quot;oauth_token=#{token.token}&amp;oauth_token_secret=#{token.secret}&amp;oauth_callback_confirmed=true&quot;
   end
 end</diff>
      <filename>app/controllers/oauth_controller.rb</filename>
    </modified>
    <modified>
      <diff>@@ -6,6 +6,9 @@ class CreateOauthTokens &lt; ActiveRecord::Migration
       t.string  :token
       t.string  :secret
       t.string  :type
+      t.boolean :validated, :null =&gt; false, :default =&gt; false
+      t.string  :callback_url
+      t.string  :verifier
       t.timestamps
     end
   end</diff>
      <filename>db/migrate/001_create_oauth_tokens.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>6d3d7d1edccb780db672bd1d16a33aad7cfb2b2b</id>
    </parent>
  </parents>
  <author>
    <name>Seth Fitzsimmons</name>
    <email>seth@mojodna.net</email>
  </author>
  <url>http://github.com/mojodna/sample-oauth-provider/commit/c66208aeafec4034f953d5fac68f0c1b618d79c1</url>
  <id>c66208aeafec4034f953d5fac68f0c1b618d79c1</id>
  <committed-date>2009-05-26T22:10:03-07:00</committed-date>
  <authored-date>2009-05-26T22:08:53-07:00</authored-date>
  <message>support for OAuth 1.0a</message>
  <tree>7d8400ee7afa47545d7ea74000d2dab45fe38e82</tree>
  <committer>
    <name>Seth Fitzsimmons</name>
    <email>seth@mojodna.net</email>
  </committer>
</commit>
