diff --git a/app/controllers/authorizations_controller.rb b/app/controllers/authorizations_controller.rb index a3f42a1ae0282f8ebabcc3c5654a69a716767eea..d580c7c82e801372f5c244d55f9741bf934eeda1 100644 --- a/app/controllers/authorizations_controller.rb +++ b/app/controllers/authorizations_controller.rb @@ -18,16 +18,14 @@ class AuthorizationsController < ApplicationController end def token - if(params[:type] == 'client_associate' && params[:redirect_uri] && params[:name]) - client = OAuth2::Provider.client_class.create!(:name => params[:name]) + if(params[:type] == 'client_associate' && params[:manifest_url]) + client = OAuth2::Provider.client_class.create_from_manifest!(params[:manifest_url]) render :json => {:client_id => client.oauth_identifier, - :client_secret => client.oauth_secret, - :expires_in => 0, - :flows_supported => "", - :user_endpoint_url => "bob"} - - #redirect_to("#{params[:redirect_uri]}?#{query_string}") + :client_secret => client.oauth_secret, + :expires_in => 0, + :flows_supported => "", + } else render :text => "bad request", :status => 403 @@ -35,3 +33,10 @@ class AuthorizationsController < ApplicationController end end +OAuth2::Provider.client_class.instance_eval do + def self.create_from_manifest! manifest_url + puts manifest_url + manifest = JSON.parse(RestClient.get(manifest_url).body) + create!(manifest) + end +end diff --git a/app/views/authorizations/new.html.haml b/app/views/authorizations/new.html.haml index d593420085717a545f4d60e7913f9eeaa0e3b192..4c47a7baf268012457ff223668b65cffefc96907 100644 --- a/app/views/authorizations/new.html.haml +++ b/app/views/authorizations/new.html.haml @@ -1,7 +1,24 @@ -= form_for :authorization, - :url => oauth_authorize_path(params.slice(:redirect_uri, :client_id, :client_secret)) do |form| - %h2 - = "Authorize #{@client.name}?" - = form.submit "Fuck Yeah!", :value => "Yes" - = form.submit "Hell No.", :value => "No" +%br +%br + +.prepend-4 + .floating.span-15 + .span-3.append-1 + = image_tag(@client.icon_url, :id => 'client-application-image') + + .span-10 + = form_for :authorization, + :url => oauth_authorize_path(params.slice(:redirect_uri, :client_id, :client_secret)) do |form| + + %h1 + = "Authorize #{@client.name}?" + + .description + = @client.description + + %br + + %p + = form.submit "Fuck Yeah!", :value => "Yes" + = form.submit "Hell No.", :value => "No" diff --git a/db/migrate/20110602224152_diaspora_o_auth_client_fields.rb b/db/migrate/20110602224152_diaspora_o_auth_client_fields.rb new file mode 100644 index 0000000000000000000000000000000000000000..184c1bd0c7e2e53a292416485efd339285433677 --- /dev/null +++ b/db/migrate/20110602224152_diaspora_o_auth_client_fields.rb @@ -0,0 +1,13 @@ +class DiasporaOAuthClientFields < ActiveRecord::Migration + def self.up + add_column :oauth_clients, :description, :text + add_column :oauth_clients, :homepage_url, :string + add_column :oauth_clients, :icon_url, :string + end + + def self.down + remove_column :oauth_clients, :icon_url + remove_column :oauth_clients, :homepage_url + remove_column :oauth_clients, :description + end +end diff --git a/db/schema.rb b/db/schema.rb index 78a15252d214ca6621e6ad229abcbe5ba97151b5..9f7bfa013a86393869b671ee97747efabce129cc 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -225,6 +225,9 @@ ActiveRecord::Schema.define(:version => 20110603212633) do t.string "name" t.string "oauth_identifier", :limit => 32, :null => false t.string "oauth_secret", :limit => 32, :null => false + t.text "description" + t.string "homepage_url" + t.string "icon_url" end create_table "people", :force => true do |t| diff --git a/features/oauth.feature b/features/oauth.feature index cdc97fbe721f184a17a20f83c30355abf337cdec..5f585dbcf46ddfb5034c066487ef68c46a5eb084 100644 --- a/features/oauth.feature +++ b/features/oauth.feature @@ -10,6 +10,7 @@ Feature: oauth When I visit "/" on Chubbies And I try to authorize Chubbies Then I should see "Authorize Chubbies?" + And I should see "Chubbies tests Diaspora's OAuth capabilities." When I press "Yes" Then I should be on "/account" on Chubbies @@ -20,6 +21,7 @@ Feature: oauth When I visit "/" on Chubbies And I try to authorize Chubbies Then I should see "Authorize Chubbies?" + And I should see "Chubbies tests Diaspora's OAuth capabilities." When I press "No" Then I should be on "/callback" on Chubbies @@ -30,6 +32,7 @@ Feature: oauth When I visit "/" on Chubbies And I try to authorize Chubbies Then I should see "Authorize Chubbies?" + And I should see "Chubbies tests Diaspora's OAuth capabilities." When I press "Yes" Then I should be on "/account" on Chubbies diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass index 74c5c52985c5c8bc4d57548b322cd0800b646d47..262b1f4291941f44673670c0a986d30476a09960 100644 --- a/public/stylesheets/sass/application.sass +++ b/public/stylesheets/sass/application.sass @@ -2926,3 +2926,6 @@ h1.tag #facebox input[type='text'], input.text :width 98% + +#client-application-image + :max-width 100% diff --git a/spec/support/chubbies/app.rb b/spec/support/chubbies/app.rb index b8607f31a6ad2f7f7c6f3b284595b5667d839f82..af54e1141b34003b55ec975dc21192fda7359d3f 100644 --- a/spec/support/chubbies/app.rb +++ b/spec/support/chubbies/app.rb @@ -80,8 +80,7 @@ get '/account' do if !@@client_id && !@@client_secret response = HTTParty.post(token_url, :body => { :type => :client_associate, - :name => :Chubbies, - :redirect_uri => redirect_uri + :manifest_url => "http://" + request.host_with_port + "/manifest" }) json = JSON.parse(response.body) @@ -90,7 +89,6 @@ get '/account' do @@client_secret = json["client_secret"] redirect '/account' - else if access_token @resource_response = get_with_access_token("/api/v0/me") @@ -101,6 +99,15 @@ get '/account' do end end +get '/manifest' do + { + :name => "Chubbies", + :description => "Chubbies tests Diaspora's OAuth capabilities.", + :homepage_url => "http://" + request.host_with_port, + :icon_url => "http://" + request.host_with_port + "/chubbies.jpeg" + }.to_json +end + get '/reset' do @@client_id = nil @@client_secret = nil diff --git a/spec/support/chubbies/public/chubbies.jpeg b/spec/support/chubbies/public/chubbies.jpeg new file mode 100644 index 0000000000000000000000000000000000000000..2a569180e114ee741c81e1b8b60e2998c8c5fab5 Binary files /dev/null and b/spec/support/chubbies/public/chubbies.jpeg differ