authlogic_facebook_koala 0.3.0 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. data/README.md +4 -0
  2. data/authlogic_facebook_koala.gemspec +25 -22
  3. metadata +31 -165
  4. data/LICENSE +0 -20
  5. data/README.rdoc +0 -76
  6. data/Rakefile +0 -39
  7. data/VERSION +0 -1
  8. data/init.rb +0 -1
  9. data/lib/authlogic_facebook_koala.rb +0 -17
  10. data/lib/authlogic_facebook_koala/acts_as_authentic.rb +0 -20
  11. data/lib/authlogic_facebook_koala/adapter.rb +0 -35
  12. data/lib/authlogic_facebook_koala/config.rb +0 -80
  13. data/lib/authlogic_facebook_koala/helper.rb +0 -4
  14. data/lib/authlogic_facebook_koala/session.rb +0 -68
  15. data/rails/init.rb +0 -1
  16. data/test/rails_root/app/controllers/application_controller.rb +0 -10
  17. data/test/rails_root/app/helpers/application_helper.rb +0 -3
  18. data/test/rails_root/app/models/user.rb +0 -7
  19. data/test/rails_root/app/models/user_session.rb +0 -7
  20. data/test/rails_root/config/boot.rb +0 -110
  21. data/test/rails_root/config/database.yml +0 -10
  22. data/test/rails_root/config/environment.rb +0 -31
  23. data/test/rails_root/config/environments/development.rb +0 -0
  24. data/test/rails_root/config/environments/test.rb +0 -0
  25. data/test/rails_root/config/facebook.yml +0 -7
  26. data/test/rails_root/config/initializers/authlogic_facebook_koala.rb +0 -5
  27. data/test/rails_root/config/initializers/new_rails_defaults.rb +0 -21
  28. data/test/rails_root/config/initializers/session_store.rb +0 -15
  29. data/test/rails_root/config/locales/en.yml +0 -5
  30. data/test/rails_root/config/routes.rb +0 -43
  31. data/test/rails_root/db/migrate/20101217000008_create_users.rb +0 -37
  32. data/test/rails_root/db/seeds.rb +0 -7
  33. data/test/rails_root/script/console +0 -3
  34. data/test/rails_root/script/dbconsole +0 -3
  35. data/test/rails_root/script/generate +0 -3
  36. data/test/test_helper.rb +0 -43
  37. data/test/units/adapter_test.rb +0 -182
  38. data/test/units/config_test.rb +0 -145
  39. data/test/units/session_test.rb +0 -221
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.3.0
data/init.rb DELETED
@@ -1 +0,0 @@
1
- require File.dirname(__FILE__) + "/rails/init.rb"
@@ -1,17 +0,0 @@
1
- require 'yaml'
2
- require 'ostruct'
3
- require 'singleton'
4
-
5
- require 'authlogic_facebook_koala/config'
6
- require 'authlogic_facebook_koala/adapter'
7
- require 'authlogic_facebook_koala/acts_as_authentic'
8
- require 'authlogic_facebook_koala/session'
9
- require 'authlogic_facebook_koala/helper'
10
-
11
- if ActiveRecord::Base.respond_to?(:add_acts_as_authentic_module)
12
- ActiveRecord::Base.send :include, AuthlogicFacebookKoala::ActsAsAuthentic
13
-
14
- Authlogic::Session::Base.send :extend, AuthlogicFacebookKoala::Config
15
- Authlogic::Session::Base.send :include, AuthlogicFacebookKoala::Session
16
- Authlogic::Session::Base.send :include, AuthlogicFacebookKoala::Adapter
17
- end
@@ -1,20 +0,0 @@
1
- module AuthlogicFacebookKoala
2
- module ActsAsAuthentic
3
- def self.included(klass)
4
- klass.class_eval do
5
- extend Config
6
- add_acts_as_authentic_module(Methods, :prepend)
7
- end
8
- end
9
-
10
- module Config
11
- end
12
-
13
- module Methods
14
- def self.included(klass)
15
- klass.class_eval do
16
- end
17
- end
18
- end
19
- end
20
- end
@@ -1,35 +0,0 @@
1
- module AuthlogicFacebookKoala
2
-
3
- module Adapter
4
-
5
- def facebook_session
6
- @facebook_session ||= begin
7
- if controller.cookies.has_key?("fbs_#{facebook_app_id}")
8
- oauth = Koala::Facebook::OAuth.new(facebook_app_id, facebook_secret_key)
9
- if oauth.respond_to?(:get_user_info_from_cookie)
10
- user_info = oauth.get_user_info_from_cookie(controller.cookies)
11
- else
12
- user_info = oauth.get_user_from_cookie(controller.cookies)
13
- end
14
- OpenStruct.new( user_info )
15
- end
16
- end
17
- end
18
-
19
- def facebook_session?
20
- !facebook_session.nil?
21
- end
22
-
23
- def facebook_user
24
- @facebook_user ||= begin
25
- facebook_graph = Koala::Facebook::GraphAPI.new(facebook_session.access_token)
26
- user = facebook_graph.get_object('me')
27
- user[:uid] = user.delete('id')
28
- OpenStruct.new( user )
29
- end if facebook_session?
30
- end
31
-
32
- end
33
-
34
- end
35
-
@@ -1,80 +0,0 @@
1
- module AuthlogicFacebookKoala
2
-
3
- module Config
4
-
5
- def self.extended(klass)
6
- (class << klass; self end).send(:define_method, :default_config) do
7
- @default_config ||= begin
8
- config_file = File.join(Rails.root, 'config', facebook_config_file)
9
- OpenStruct.new(File.exist?(config_file) ? YAML.load_file(config_file)[Rails.env] : {})
10
- end
11
- end
12
- end
13
-
14
- # Specify your config file if using one. If not then you need to specify
15
- # facebook_app_id, facebook_secret_key & facebook_api_key
16
- #
17
- # * <tt>Default:</tt> facebook.yml
18
- # * <tt>Accepts:</tt> String
19
- def facebook_config_file(value=nil)
20
- rw_config(:facebook_config_file, value, 'facebook.yml')
21
- end
22
- alias_method :facebook_config_file=, :facebook_config_file
23
-
24
- # Specify your app_id.
25
- #
26
- # * <tt>Default:</tt> app_id in config/facebook.yml
27
- # * <tt>Accepts:</tt> String
28
- def facebook_app_id(value=nil)
29
- rw_config(:facebook_app_id, value, default_config.app_id)
30
- end
31
- alias_method :facebook_app_id=, :facebook_app_id
32
-
33
- # Specify your secret_key.
34
- #
35
- # * <tt>Default:</tt> secret_key in config/facebook.yml
36
- # * <tt>Accepts:</tt> String
37
- def facebook_secret_key(value=nil)
38
- rw_config(:facebook_secret_key, value, default_config.secret_key)
39
- end
40
- alias_method :facebook_secret_key=, :facebook_secret_key
41
-
42
- # Specify your api_key.
43
- #
44
- # * <tt>Default:</tt> api_key in config/facebook.yml
45
- # * <tt>Accepts:</tt> String
46
- def facebook_api_key(value=nil)
47
- rw_config(:facebook_api_key, value, default_config.api_key)
48
- end
49
- alias_method :facebook_api_key=, :facebook_api_key
50
-
51
- # What user field should be used for the facebook UID?
52
- #
53
- # * <tt>Default:</tt> :facebook_uid
54
- # * <tt>Accepts:</tt> Symbol
55
- def facebook_uid_field(value=nil)
56
- rw_config(:facebook_uid_field, value, :facebook_uid)
57
- end
58
- alias_method :facebook_uid_field=, :facebook_uid_field
59
-
60
- # What method should be used to find the facebook account?
61
- #
62
- # * <tt>Default:</tt> :find_by_#{facebook_uid_field}
63
- # * <tt>Accepts:</tt> Symbol or String
64
- def facebook_finder(value=nil)
65
- rw_config(:facebook_finder, value, nil)
66
- end
67
- alias_method :facebook_finder=, :facebook_finder
68
-
69
- # Should a new user be automatically created if there is no user with
70
- # given facebook uid?
71
- #
72
- # * <tt>Default:</tt> false
73
- # * <tt>Accepts:</tt> Boolean
74
- def facebook_auto_register(value=nil)
75
- rw_config(:facebook_auto_register, value, false)
76
- end
77
- alias_method :facebook_auto_register=, :facebook_auto_register
78
- end
79
-
80
- end
@@ -1,4 +0,0 @@
1
- module AuthlogicFacebookKoala
2
- module Helper
3
- end
4
- end
@@ -1,68 +0,0 @@
1
- module AuthlogicFacebookKoala
2
- module Session
3
-
4
- def self.included(klass)
5
-
6
- klass.class_eval do
7
- attr_accessor :skip_facebook_authentication
8
- validate :validate_by_facebook, :if => :authenticating_with_facebook?
9
- end
10
-
11
- end
12
-
13
- def logged_in_with_facebook?
14
- @logged_in_with_facebook
15
- end
16
-
17
- protected
18
- # Override this if you want only some requests to use facebook
19
- def authenticating_with_facebook?
20
- !skip_facebook_authentication && !authenticating_with_unauthorized_record? && facebook_session?
21
- end
22
-
23
- private
24
-
25
- def validate_by_facebook
26
- facebook_uid = facebook_session.uid
27
- self.attempted_record = klass.send(facebook_finder, facebook_uid)
28
-
29
- if self.attempted_record || !facebook_auto_register?
30
- return @logged_in_with_facebook = !!self.attempted_record
31
- else
32
- self.attempted_record = klass.new
33
- self.attempted_record.send(:"#{facebook_uid_field}=", facebook_uid)
34
- if self.attempted_record.respond_to?(:before_connect)
35
- self.attempted_record.send(:before_connect, facebook_session)
36
- end
37
-
38
- @logged_in_with_facebook = true
39
- return self.attempted_record.save(false)
40
- end
41
- end
42
-
43
- def facebook_app_id
44
- self.class.facebook_app_id
45
- end
46
-
47
- def facebook_api_key
48
- self.class.facebook_api_key
49
- end
50
-
51
- def facebook_secret_key
52
- self.class.facebook_secret_key
53
- end
54
-
55
- def facebook_auto_register?
56
- self.class.facebook_auto_register
57
- end
58
-
59
- def facebook_uid_field
60
- self.class.facebook_uid_field
61
- end
62
-
63
- def facebook_finder
64
- self.class.facebook_finder || "find_by_#{facebook_uid_field}"
65
- end
66
-
67
- end
68
- end
@@ -1 +0,0 @@
1
- require 'authlogic_facebook_koala'
@@ -1,10 +0,0 @@
1
- # Filters added to this controller apply to all controllers in the application.
2
- # Likewise, all the methods added will be available for all controllers.
3
-
4
- class ApplicationController < ActionController::Base
5
- helper :all # include all helpers, all the time
6
- protect_from_forgery # See ActionController::RequestForgeryProtection for details
7
-
8
- # Scrub sensitive parameters from your log
9
- # filter_parameter_logging :password
10
- end
@@ -1,3 +0,0 @@
1
- # Methods added to this helper will be available to all templates in the application.
2
- module ApplicationHelper
3
- end
@@ -1,7 +0,0 @@
1
- class User < ActiveRecord::Base
2
- acts_as_authentic
3
-
4
- def before_connect(facebook_session)
5
- true
6
- end
7
- end
@@ -1,7 +0,0 @@
1
- class UserSession < Authlogic::Session::Base
2
-
3
- facebook_app_id '233423200151'
4
- facebook_api_key 'f4fdb590052b81c3d73c5d2aa5908308'
5
- facebook_secret_key '8371c9fc95a7d0a3d9cdb6bbacfea306'
6
-
7
- end
@@ -1,110 +0,0 @@
1
- # Don't change this file!
2
- # Configure your app in config/environment.rb and config/environments/*.rb
3
-
4
- RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
5
-
6
- module Rails
7
- class << self
8
- def boot!
9
- unless booted?
10
- preinitialize
11
- pick_boot.run
12
- end
13
- end
14
-
15
- def booted?
16
- defined? Rails::Initializer
17
- end
18
-
19
- def pick_boot
20
- (vendor_rails? ? VendorBoot : GemBoot).new
21
- end
22
-
23
- def vendor_rails?
24
- File.exist?("#{RAILS_ROOT}/vendor/rails")
25
- end
26
-
27
- def preinitialize
28
- load(preinitializer_path) if File.exist?(preinitializer_path)
29
- end
30
-
31
- def preinitializer_path
32
- "#{RAILS_ROOT}/config/preinitializer.rb"
33
- end
34
- end
35
-
36
- class Boot
37
- def run
38
- load_initializer
39
- Rails::Initializer.run(:set_load_path)
40
- end
41
- end
42
-
43
- class VendorBoot < Boot
44
- def load_initializer
45
- require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
46
- Rails::Initializer.run(:install_gem_spec_stubs)
47
- Rails::GemDependency.add_frozen_gem_path
48
- end
49
- end
50
-
51
- class GemBoot < Boot
52
- def load_initializer
53
- self.class.load_rubygems
54
- load_rails_gem
55
- require 'initializer'
56
- end
57
-
58
- def load_rails_gem
59
- if version = self.class.gem_version
60
- gem 'rails', version
61
- else
62
- gem 'rails'
63
- end
64
- rescue Gem::LoadError => load_error
65
- $stderr.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.)
66
- exit 1
67
- end
68
-
69
- class << self
70
- def rubygems_version
71
- Gem::RubyGemsVersion rescue nil
72
- end
73
-
74
- def gem_version
75
- if defined? RAILS_GEM_VERSION
76
- RAILS_GEM_VERSION
77
- elsif ENV.include?('RAILS_GEM_VERSION')
78
- ENV['RAILS_GEM_VERSION']
79
- else
80
- parse_gem_version(read_environment_rb)
81
- end
82
- end
83
-
84
- def load_rubygems
85
- min_version = '1.3.2'
86
- require 'rubygems'
87
- unless rubygems_version >= min_version
88
- $stderr.puts %Q(Rails requires RubyGems >= #{min_version} (you have #{rubygems_version}). Please `gem update --system` and try again.)
89
- exit 1
90
- end
91
-
92
- rescue LoadError
93
- $stderr.puts %Q(Rails requires RubyGems >= #{min_version}. Please install RubyGems and try again: http://rubygems.rubyforge.org)
94
- exit 1
95
- end
96
-
97
- def parse_gem_version(text)
98
- $1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/
99
- end
100
-
101
- private
102
- def read_environment_rb
103
- File.read("#{RAILS_ROOT}/config/environment.rb")
104
- end
105
- end
106
- end
107
- end
108
-
109
- # All that for this:
110
- Rails.boot!
@@ -1,10 +0,0 @@
1
- development:
2
- :adapter: sqlite3
3
- :database: ":memory:"
4
- pool: 5
5
- timeout: 5000
6
- test:
7
- :adapter: sqlite3
8
- :database: ":memory:"
9
- pool: 5
10
- timeout: 5000
@@ -1,31 +0,0 @@
1
- RAILS_GEM_VERSION = '2.3.5' unless defined? RAILS_GEM_VERSION
2
-
3
- # Bootstrap the Rails environment, frameworks, and default configuration
4
- require File.join(File.dirname(__FILE__), 'boot')
5
-
6
- Rails::Initializer.run do |config|
7
- # config.load_paths += %W( #{RAILS_ROOT}/extras )
8
- # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
9
- # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
10
- # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}')]
11
- # config.i18n.default_locale = :de
12
- # config.active_record.schema_format = :sql
13
-
14
- config.gem "authlogic"
15
- config.gem 'flexmock'
16
- config.gem "koala"
17
- config.gem "shoulda"
18
- config.gem "test-unit", :lib => "test/unit"
19
-
20
- config.frameworks -= [ :active_resource, :action_mailer ]
21
- config.log_level = :debug
22
- config.cache_classes = false
23
- config.whiny_nils = true
24
- config.action_controller.consider_all_requests_local = true
25
- config.action_controller.perform_caching = false
26
- config.action_view.cache_template_loading = true
27
- config.action_controller.allow_forgery_protection = false
28
- config.action_mailer.delivery_method = :test
29
- config.time_zone = 'UTC'
30
-
31
- end
@@ -1,7 +0,0 @@
1
- test:
2
- app_id: appidfromfile
3
- api_key: apikeyfromfile
4
- secret_key: secretkeyfromfile
5
- canvas_page_name: facebook_koala
6
- callback_url: http://example.com/
7
-
@@ -1,5 +0,0 @@
1
- afk_path = File.join(File.dirname(__FILE__), *%w(.. .. .. ..))
2
- afk_lib_path = File.join(afk_path, "lib")
3
-
4
- $LOAD_PATH.unshift(afk_lib_path)
5
- load File.join(afk_path, "init.rb")