Skip to content
Browse files

initial working code commit, connects to facebook

  • Loading branch information...
1 parent bb5cf91 commit 303df962633286a2f71ac99697b4426abac204fe bhbryant committed May 18, 2010
View
0 .document 100644 → 100755
File mode changed.
View
0 .gitignore 100644 → 100755
File mode changed.
View
0 LICENSE 100644 → 100755
File mode changed.
View
0 README.rdoc 100644 → 100755
File mode changed.
View
11 Rakefile 100644 → 100755
@@ -1,16 +1,23 @@
require 'rubygems'
require 'rake'
+require File.join(File.dirname(__FILE__), 'lib', 'devise_oauth2_authenticatable', 'version')
begin
require 'jeweler'
Jeweler::Tasks.new do |gem|
gem.name = "devise_oauth2_authenticatable"
- gem.summary = %Q{TODO: one-line summary of your gem}
- gem.description = %Q{TODO: longer description of your gem}
+ gem.version = ::Devise::Oauth2Authenticatable::VERSION
+ gem.summary = %{Devise << OAuth2}
+ gem.description = %{Implements OAuth2 for devises, specifically integrating with facebook Graph}
gem.email = "benjamin@bryantmarkowsky.com"
gem.homepage = "http://github.com/bhbryant/devise_oauth2_authenticatable"
gem.authors = ["bhbryant"]
gem.add_development_dependency "rspec", ">= 1.2.9"
+
+ gem.add_dependency'devise', '>= 1.0.0'
+ gem.add_dependency "oauth2"
+ gem.add_dependency "json"
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
end
Jeweler::GemcutterTasks.new
View
59 lib/devise_oauth2_authenticatable.rb 100644 → 100755
@@ -0,0 +1,59 @@
+# encoding: utf-8
+require 'devise'
+require 'oauth2'
+
+
+require 'devise_oauth2_authenticatable/model'
+require 'devise_oauth2_authenticatable/strategy'
+require 'devise_oauth2_authenticatable/schema'
+require 'devise_oauth2_authenticatable/routes'
+#require 'devise_oauth2_authenticatable/controller_filters'
+require 'devise_oauth2_authenticatable/view_helpers'
+
+
+module Devise
+ # Specifies the name of the database column name used for storing
+ # the oauth UID. Useful if this info should be saved in a
+ # generic column if different authentication solutions are used.
+ mattr_accessor :oauth2_uid_field
+ @@oauth2_uid_field = :oauth2_uid
+
+ # Specifies the name of the database column name used for storing
+ # the user Facebook session key. Useful if this info should be saved in a
+ # generic column if different authentication solutions are used.
+ mattr_accessor :oauth2_token_field
+ @@oauth2_token_field = :oauth2_token
+
+ # Specifies if account should be created if no account exists for
+ # a specified Facebook UID or not.
+ mattr_accessor :oauth2_auto_create_account
+ @@oauth2_auto_create_account = true
+
+ def self.oauth2_client
+ @@oauth2_client ||= OAuth2::Client.new(OAUTH2_CONFIG['client_id'], OAUTH2_CONFIG['client_secret'], :site => OAUTH2_CONFIG['authorization_server'])
+ end
+
+
+ def self.session_sign_in_url(request, mapping)
+ url = URI.parse(request.url)
+ url.path = "#{mapping.parsed_path}/#{mapping.path_names[:sign_in]}"
+ url.query = nil
+ url.to_s
+ end
+
+ def self.requested_scope
+ @@requested_scope ||= OAUTH2_CONFIG['requested_scope']
+ end
+
+end
+
+# Load core I18n locales: en
+#
+I18n.load_path.unshift File.join(File.dirname(__FILE__), *%w[devise_oauth2_authenticatable locales en.yml])
+
+# Add +:facebook_connectable+ strategies to defaults.
+#
+Devise.add_module(:oauth2_authenticatable,
+ :strategy => true,
+ :controller => :sessions,
+ :model => 'devise_oauth2_authenticatable/model')
View
0 spec/devise_oauth2_authenticatable_spec.rb 100644 → 100755
File mode changed.
View
0 spec/spec.opts 100644 → 100755
File mode changed.
View
0 spec/spec_helper.rb 100644 → 100755
File mode changed.

0 comments on commit 303df96

Please sign in to comment.
Something went wrong with that request. Please try again.