twitter oauth dance complete

This commit is contained in:
maxwell 2010-10-23 16:09:58 -07:00 committed by danielvincent
parent 31b3d739c0
commit c4ff07b09a
11 changed files with 164 additions and 1 deletions

View file

@ -9,6 +9,10 @@ gem "chef"
gem 'devise', '1.1.3' gem 'devise', '1.1.3'
gem 'devise-mongo_mapper', :git => 'git://github.com/collectiveidea/devise-mongo_mapper' gem 'devise-mongo_mapper', :git => 'git://github.com/collectiveidea/devise-mongo_mapper'
gem 'devise_invitable', '~> 0.3.4' gem 'devise_invitable', '~> 0.3.4'
#Authentication
gem 'omniauth'
#Mongo #Mongo
gem 'mongo_mapper', :branch => 'rails3', :git => 'git://github.com/jnunemaker/mongomapper.git' gem 'mongo_mapper', :branch => 'rails3', :git => 'git://github.com/jnunemaker/mongomapper.git'
gem 'bson_ext', '1.1' gem 'bson_ext', '1.1'

View file

@ -170,6 +170,9 @@ GEM
factory_girl_rails (1.0) factory_girl_rails (1.0)
factory_girl (~> 1.3) factory_girl (~> 1.3)
rails (>= 3.0.0.beta4) rails (>= 3.0.0.beta4)
faraday (0.4.6)
addressable (>= 2.1.1)
rack (>= 1.0.1)
ffi (0.6.3) ffi (0.6.3)
rake (>= 0.8.7) rake (>= 0.8.7)
gherkin (2.2.9) gherkin (2.2.9)
@ -182,11 +185,20 @@ GEM
i18n (0.4.1) i18n (0.4.1)
json (1.4.6) json (1.4.6)
json_pure (1.4.6) json_pure (1.4.6)
<<<<<<< HEAD
launchy (0.3.7) launchy (0.3.7)
configuration (>= 0.0.5) configuration (>= 0.0.5)
rake (>= 0.8.1) rake (>= 0.8.1)
<<<<<<< HEAD
linecache19 (0.5.11) linecache19 (0.5.11)
ruby_core_source (>= 0.1.4) ruby_core_source (>= 0.1.4)
=======
linecache (0.43)
=======
linecache19 (0.5.11)
ruby_core_source (>= 0.1.4)
>>>>>>> twitter oauth dance complete
>>>>>>> twitter oauth dance complete
mail (2.2.7) mail (2.2.7)
activesupport (>= 2.3.6) activesupport (>= 2.3.6)
mime-types mime-types
@ -207,6 +219,8 @@ GEM
moneta (0.6.0) moneta (0.6.0)
mongo (1.1) mongo (1.1)
bson (>= 1.0.5) bson (>= 1.0.5)
multi_json (0.0.4)
net-ldap (0.1.1)
net-scp (1.0.4) net-scp (1.0.4)
net-ssh (>= 1.99.1) net-ssh (>= 1.99.1)
net-sftp (2.0.5) net-sftp (2.0.5)
@ -215,6 +229,7 @@ GEM
net-ssh-gateway (1.0.1) net-ssh-gateway (1.0.1)
net-ssh (>= 1.99.1) net-ssh (>= 1.99.1)
nokogiri (1.4.3.1) nokogiri (1.4.3.1)
<<<<<<< HEAD
ohai (0.5.8) ohai (0.5.8)
extlib extlib
json (>= 1.4.4, <= 1.4.6) json (>= 1.4.4, <= 1.4.6)
@ -222,15 +237,54 @@ GEM
mixlib-config mixlib-config
mixlib-log mixlib-log
systemu systemu
=======
oa-basic (0.1.5)
multi_json (~> 0.0.2)
nokogiri (~> 1.4.2)
oa-core (= 0.1.5)
rest-client (~> 1.6.0)
oa-core (0.1.5)
rack (~> 1.1)
oa-enterprise (0.1.5)
net-ldap (~> 0.1.1)
nokogiri (~> 1.4.2)
oa-core (= 0.1.5)
pyu-ruby-sasl (~> 0.0.3.1)
rubyntlm (~> 0.1.1)
oa-oauth (0.1.5)
multi_json (~> 0.0.2)
nokogiri (~> 1.4.2)
oa-core (= 0.1.5)
oauth (~> 0.4.0)
oauth2 (~> 0.0.10)
oa-openid (0.1.5)
oa-core (= 0.1.5)
rack-openid (~> 1.1.1)
ruby-openid-apps-discovery
oauth (0.4.3)
oauth2 (0.0.13)
faraday (~> 0.4.1)
multi_json (>= 0.0.4)
omniauth (0.1.5)
oa-basic (= 0.1.5)
oa-core (= 0.1.5)
oa-enterprise (= 0.1.5)
oa-oauth (= 0.1.5)
oa-openid (= 0.1.5)
>>>>>>> twitter oauth dance complete
plucky (0.3.6) plucky (0.3.6)
mongo (~> 1.1) mongo (~> 1.1)
polyglot (0.3.1) polyglot (0.3.1)
pubsubhubbub (0.1.1) pubsubhubbub (0.1.1)
em-http-request (>= 0.1.5) em-http-request (>= 0.1.5)
eventmachine (>= 0.12.9) eventmachine (>= 0.12.9)
pyu-ruby-sasl (0.0.3.2)
rack (1.2.1) rack (1.2.1)
rack-mount (0.6.13) rack-mount (0.6.13)
rack (>= 1.0.0) rack (>= 1.0.0)
rack-openid (1.1.2)
rack (>= 0.4)
ruby-openid (>= 2.0.3)
rack-test (0.5.6) rack-test (0.5.6)
rack (>= 1.0) rack (>= 1.0)
rails (3.0.1) rails (3.0.1)
@ -269,8 +323,17 @@ GEM
columnize (>= 0.3.1) columnize (>= 0.3.1)
linecache19 (>= 0.5.11) linecache19 (>= 0.5.11)
ruby-debug-base19 (>= 0.11.19) ruby-debug-base19 (>= 0.11.19)
<<<<<<< HEAD
ruby_core_source (0.1.4) ruby_core_source (0.1.4)
archive-tar-minitar (>= 0.5.2) archive-tar-minitar (>= 0.5.2)
=======
ruby-openid (2.1.8)
ruby-openid-apps-discovery (1.2.0)
ruby-openid (>= 2.1.7)
ruby_core_source (0.1.4)
archive-tar-minitar (>= 0.5.2)
rubyntlm (0.1.1)
>>>>>>> twitter oauth dance complete
rubyzip (0.9.4) rubyzip (0.9.4)
selenium-webdriver (0.0.29) selenium-webdriver (0.0.29)
childprocess (>= 0.0.7) childprocess (>= 0.0.7)
@ -325,6 +388,7 @@ DEPENDENCIES
mini_magick mini_magick
mocha mocha
mongo_mapper! mongo_mapper!
omniauth
pubsubhubbub pubsubhubbub
rails (>= 3.0.0) rails (>= 3.0.0)
redfinger! redfinger!

View file

@ -0,0 +1,30 @@
# Copyright (c) 2010, Diaspora Inc. This file is
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
class OmniauthServicesController < ApplicationController
before_filter :authenticate_user!
def index
@services = current_user.services
end
def create
auth = request.env['omniauth.auth']
puts auth['extra']['access_token'].inspect
current_user.services.create(:provider => auth['provider'], :uid => auth['uid'])
flash[:notice] = "Authentication successful."
redirect_to omniauth_services_url
end
def destroy
@service = current_user.services.find(params[:id])
@service.destroy
flash[:notice] = "Successfully destroyed authentication."
redirect_to omniauth_services_url
end
end

View file

@ -0,0 +1,13 @@
# Copyright (c) 2010, Diaspora Inc. This file is
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
class OmniauthService
include MongoMapper::Document
belongs_to :user
key :provider, String
key :uid, String
end

View file

@ -61,6 +61,8 @@ class User
many :raw_visible_posts, :in => :visible_post_ids, :class_name => 'Post' many :raw_visible_posts, :in => :visible_post_ids, :class_name => 'Post'
many :aspects, :class_name => 'Aspect', :dependent => :destroy many :aspects, :class_name => 'Aspect', :dependent => :destroy
many :services, :class_name => "OmniauthService"
#after_create :seed_aspects #after_create :seed_aspects
before_destroy :unfriend_everyone, :remove_person before_destroy :unfriend_everyone, :remove_person

View file

@ -0,0 +1,17 @@
-# Copyright (c) 2010, Diaspora Inc. This file is
-# licensed under the Affero General Public License version 3 or later. See
-# the COPYRIGHT file.
%h2
Services
%ul#stream
- for service in @services
%h3
= service.provider
%b
=service.uid
= link_to "disconnect", service, :confirm => "disconnect #{service.provider}?", :method => :delete
= link_to "Connect to twitter", "/auth/twitter"

View file

@ -0,0 +1,15 @@
# Copyright (c) 2010, Diaspora Inc. This file is
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
def load_config_yaml filename
YAML.load(File.read(filename))
end
oauth_keys_file = "#{Rails.root}/config/oauth_keys.yml"
if File.exist? oauth_keys_file
SERVICES = load_config_yaml(oauth_keys_file)
SERVICES ||= load_config_yaml("#{oauth_keys_file}.example")
end

View file

@ -0,0 +1,9 @@
# Copyright (c) 2010, Diaspora Inc. This file is
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
Rails.application.config.middleware.use OmniAuth::Builder do
provider :twitter, SERVICES['twitter']['consumer_key'], SERVICES['twitter']['consumer_secret']
#provider :facebook, 'APP_ID', 'APP_SECRET'
end

3
config/oauth_keys.yml Normal file
View file

@ -0,0 +1,3 @@
twitter:
consumer_key: no69jTnL5SCOnWgk5XWqbQ
consumer_secret: 2DZyu8DA43AIeFsRVdz8OtAHLvCtPjdRKdNO3UZGqWM

View file

@ -0,0 +1,3 @@
twitter:
consumer_key: ""
consumer_secret: ""

View file

@ -9,6 +9,9 @@ Diaspora::Application.routes.draw do
resources :requests, :except => [:edit, :update] resources :requests, :except => [:edit, :update]
resources :photos, :except => [:index] resources :photos, :except => [:index]
resources :albums resources :albums
resources :omniauth_services
match '/auth/:provider/callback' => 'omniauth_services#create'
devise_for :users, :controllers => {:registrations => "registrations", devise_for :users, :controllers => {:registrations => "registrations",
:password => "devise/passwords", :password => "devise/passwords",
@ -18,7 +21,7 @@ Diaspora::Application.routes.draw do
match 'users/export', :to => 'users#export' match 'users/export', :to => 'users#export'
match 'users/import', :to => 'users#import' match 'users/import', :to => 'users#import'
match 'users/export_photos', :to => 'users#export_photos' match 'users/export_photos', :to => 'users#export_photos'
resources :users, :except => [:create, :new, :show] resources :users, :except => [:create, :new, :show]
match 'aspects/move_friend', :to => 'aspects#move_friend', :as => 'move_friend' match 'aspects/move_friend', :to => 'aspects#move_friend', :as => 'move_friend'
match 'aspects/add_to_aspect',:to => 'aspects#add_to_aspect', :as => 'add_to_aspect' match 'aspects/add_to_aspect',:to => 'aspects#add_to_aspect', :as => 'add_to_aspect'