reflex 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.document +5 -0
- data/.gitignore +24 -0
- data/LICENSE +20 -0
- data/README.rdoc +193 -0
- data/Rakefile +146 -0
- data/VERSION +1 -0
- data/cucumber.yml +7 -0
- data/features/connect_to_provider.feature +18 -0
- data/features/social_authentication.feature +50 -0
- data/features/step_definitions/reflex_steps.rb +93 -0
- data/features/step_definitions/web_steps.rb +192 -0
- data/features/support/env.rb +57 -0
- data/features/support/mocha.rb +16 -0
- data/features/support/mock_controller/oauth_authorize.html.erb +15 -0
- data/features/support/mocks.rb +21 -0
- data/features/support/paths.rb +39 -0
- data/features/support/rails_root/.gitignore +8 -0
- data/features/support/rails_root/Rakefile +10 -0
- data/features/support/rails_root/app/controllers/application_controller.rb +20 -0
- data/features/support/rails_root/app/controllers/user_sessions_controller.rb +24 -0
- data/features/support/rails_root/app/controllers/users_controller.rb +46 -0
- data/features/support/rails_root/app/helpers/application_helper.rb +3 -0
- data/features/support/rails_root/app/helpers/user_sessions_helper.rb +2 -0
- data/features/support/rails_root/app/helpers/users_helper.rb +2 -0
- data/features/support/rails_root/app/models/user.rb +7 -0
- data/features/support/rails_root/app/models/user_session.rb +2 -0
- data/features/support/rails_root/app/views/layouts/application.html.erb +23 -0
- data/features/support/rails_root/app/views/user_sessions/new.html.erb +23 -0
- data/features/support/rails_root/app/views/users/_form.html.erb +31 -0
- data/features/support/rails_root/app/views/users/_user.html.erb +1 -0
- data/features/support/rails_root/app/views/users/edit.html.erb +2 -0
- data/features/support/rails_root/app/views/users/index.html.erb +8 -0
- data/features/support/rails_root/app/views/users/new.html.erb +2 -0
- data/features/support/rails_root/app/views/users/show.html.erb +20 -0
- data/features/support/rails_root/config/boot.rb +110 -0
- data/features/support/rails_root/config/database.yml +9 -0
- data/features/support/rails_root/config/environment.rb +22 -0
- data/features/support/rails_root/config/environments/development.rb +0 -0
- data/features/support/rails_root/config/environments/test.rb +0 -0
- data/features/support/rails_root/config/initializers/backtrace_silencers.rb +7 -0
- data/features/support/rails_root/config/initializers/inflections.rb +10 -0
- data/features/support/rails_root/config/initializers/mime_types.rb +5 -0
- data/features/support/rails_root/config/initializers/new_rails_defaults.rb +21 -0
- data/features/support/rails_root/config/initializers/session_store.rb +15 -0
- data/features/support/rails_root/config/routes.rb +9 -0
- data/features/support/rails_root/db/migrate/001_create_users.rb +16 -0
- data/features/support/rails_root/db/migrate/002_create_reflex_connections.rb +17 -0
- data/features/support/rails_root/db/schema.rb +35 -0
- data/features/support/rails_root/vendor/plugins/reflex/rails/init.rb +1 -0
- data/features/traditional_registration_and_authentication.feature +39 -0
- data/init.rb +5 -0
- data/lib/reflex/authlogic/account.rb +55 -0
- data/lib/reflex/authlogic/acts_as_authentic.rb +19 -0
- data/lib/reflex/authlogic/authentication_process.rb +40 -0
- data/lib/reflex/authlogic/callback_filter.rb +26 -0
- data/lib/reflex/authlogic/connectable.rb +87 -0
- data/lib/reflex/authlogic/connection.rb +18 -0
- data/lib/reflex/authlogic/session.rb +84 -0
- data/lib/reflex/base.rb +37 -0
- data/lib/reflex/configuration.rb +38 -0
- data/lib/reflex/oauth_server.rb +47 -0
- data/lib/reflex/system.rb +25 -0
- data/lib/reflex.rb +14 -0
- data/rails/init.rb +22 -0
- data/rails_generators/reflex_connection_migration/reflex_connection_migration_generator.rb +12 -0
- data/rails_generators/reflex_connection_migration/templates/create_reflex_connections.rb +17 -0
- data/reflex.gemspec +164 -0
- data/spec/fakeweb/OAuthServer.getProviders +5 -0
- data/spec/fakeweb/OAuthServer.sessionGetProfile +5 -0
- data/spec/fakeweb/OAuthServer.tokenAccess +4 -0
- data/spec/fakeweb/OAuthServer.tokenRequest +5 -0
- data/spec/fakeweb/OAuthServer.tokenSetUserId +5 -0
- data/spec/fakeweb/OAuthServer.userGetProfile +5 -0
- data/spec/fakeweb/OAuthServer.userGetProviders +4 -0
- data/spec/fakeweb/OAuthServer.userRemoveProvider +5 -0
- data/spec/fakeweb/System.listMethods +5 -0
- data/spec/fakeweb/System.methodDescription +5 -0
- data/spec/fakeweb/System.methodSignature +5 -0
- data/spec/reflex/authlogic/connection_spec.rb +22 -0
- data/spec/reflex/base_spec.rb +29 -0
- data/spec/reflex/configuration_spec.rb +71 -0
- data/spec/reflex/oauth_server_spec.rb +219 -0
- data/spec/reflex/system_spec.rb +83 -0
- data/spec/reflex_spec.rb +5 -0
- data/spec/schema.rb +15 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +66 -0
- metadata +294 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
require 'reflex/authlogic/authentication_process'
|
|
2
|
+
|
|
3
|
+
module Reflex
|
|
4
|
+
module Authlogic
|
|
5
|
+
module Session
|
|
6
|
+
include Reflex::Authlogic::AuthenticationProcess
|
|
7
|
+
|
|
8
|
+
def self.included(base)
|
|
9
|
+
base.validate :validate_by_reflex!, :if => :authenticating_via_oauth_server?
|
|
10
|
+
|
|
11
|
+
base.send(:extend, ClassMethods)
|
|
12
|
+
base.send(:include, InstanceMethods)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
module ClassMethods
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
module InstanceMethods
|
|
19
|
+
# Clears out the block if we are authenticating via react,
|
|
20
|
+
# so that we can redirect without a DoubleRender error.
|
|
21
|
+
def save(&block)
|
|
22
|
+
block = nil if redirecting_to_oauth_server?
|
|
23
|
+
super(&block)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
private
|
|
27
|
+
|
|
28
|
+
def authenticate_oauth_session(allow_retry = true)
|
|
29
|
+
# Request the React Session
|
|
30
|
+
oauth_session = Reflex::OAuthServer.token_access(reflex_controller.params)
|
|
31
|
+
react_provider = oauth_session['connectedWithProvider']
|
|
32
|
+
react_user_id = oauth_session['applicationUserId']
|
|
33
|
+
|
|
34
|
+
if react_user_id
|
|
35
|
+
# User is known on React's side, so find it:
|
|
36
|
+
self.attempted_record = klass.send(:find_by_react_user_id, react_user_id)
|
|
37
|
+
|
|
38
|
+
unless attempted_record
|
|
39
|
+
# applicationUserId is not longer valid, so remove it's provider remotely:
|
|
40
|
+
Reflex::OAuthServer.user_remove_provider(react_user_id, react_provider)
|
|
41
|
+
|
|
42
|
+
# Retry authorization can be retried:
|
|
43
|
+
errors.add_to_base(:react_auth_retry)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
else
|
|
47
|
+
# User is not yet known on React's side, so create it:
|
|
48
|
+
react_profile = Reflex::OAuthServer.session_get_profile(react_oauth_session)
|
|
49
|
+
|
|
50
|
+
# Create a user record with a connection to this provider
|
|
51
|
+
self.attempted_record, connection = klass.create_for_react(react_provider, react_profile)
|
|
52
|
+
|
|
53
|
+
if !attempted_record.new_record?
|
|
54
|
+
# Set the user id on react's side:
|
|
55
|
+
Reflex::OAuthServer.token_set_user_id(connection.uuid, react_oauth_session)
|
|
56
|
+
else
|
|
57
|
+
# Something must have gone wrong
|
|
58
|
+
errors.add_to_base(:react_auth_failed)
|
|
59
|
+
|
|
60
|
+
return false
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
true
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def validate_by_reflex!
|
|
68
|
+
if redirecting_to_oauth_server?
|
|
69
|
+
redirect_to_oauth_server
|
|
70
|
+
|
|
71
|
+
elsif react_oauth_session
|
|
72
|
+
authenticate_oauth_session
|
|
73
|
+
|
|
74
|
+
else
|
|
75
|
+
# User did not grant access. Deal with it!
|
|
76
|
+
errors.add(:reflex, :invalid)
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
Authlogic::Session::Base.send(:include, Reflex::Authlogic::Session)
|
data/lib/reflex/base.rb
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
require 'xmlrpc/client'
|
|
2
|
+
|
|
3
|
+
# unfortunately react's oauth server has <nil />'s, which the ruby XMLRPC
|
|
4
|
+
# library does not enable by default, because it is an XML-RPC extension:
|
|
5
|
+
# http://ontosys.com/xml-rpc/extensions.php
|
|
6
|
+
old_verbose, $VERBOSE = $VERBOSE, nil
|
|
7
|
+
begin
|
|
8
|
+
XMLRPC::Config::ENABLE_NIL_PARSER = true
|
|
9
|
+
XMLRPC::Config::ENABLE_NIL_CREATE = true
|
|
10
|
+
ensure
|
|
11
|
+
$VERBOSE = old_verbose
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
module Reflex
|
|
15
|
+
class Base
|
|
16
|
+
def self.call(function, *arguments)
|
|
17
|
+
client = XMLRPC::Client.new(config.hostname, config.path, config.port)
|
|
18
|
+
client.call(function, *arguments)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def self.call!(function, *arguments)
|
|
22
|
+
call(function, config.key, config.secret, *arguments)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
private
|
|
26
|
+
|
|
27
|
+
def self.config
|
|
28
|
+
@@config ||= Configuration.instance
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def self.validate_valid_options!(options, *keys)
|
|
33
|
+
unless options.keys.all? { |key| keys.include?(key) }
|
|
34
|
+
raise "Invalid options: #{(options.keys - keys).join(', ')}"
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
require 'singleton'
|
|
2
|
+
require 'uri'
|
|
3
|
+
|
|
4
|
+
module Reflex
|
|
5
|
+
class Configuration
|
|
6
|
+
include ::Singleton
|
|
7
|
+
|
|
8
|
+
attr_accessor :key, :secret, :endpoint
|
|
9
|
+
|
|
10
|
+
def uri
|
|
11
|
+
@uri = URI.parse(endpoint) if @uri.nil? || @uri.to_s != endpoint
|
|
12
|
+
@uri
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def hostname
|
|
16
|
+
uri.host
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def path
|
|
20
|
+
uri.path
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def port
|
|
24
|
+
uri.port || 80
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def self.configure(options = {})
|
|
29
|
+
validate_valid_options!(options, :key, :secret, :endpoint)
|
|
30
|
+
|
|
31
|
+
authorization = Configuration.instance
|
|
32
|
+
options.each do |key, value|
|
|
33
|
+
authorization.send(:"#{key}=", value)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
authorization
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
module Reflex
|
|
2
|
+
class OAuthServer < Base
|
|
3
|
+
class << self
|
|
4
|
+
# Get all providers with API-keys configured
|
|
5
|
+
def get_providers
|
|
6
|
+
call!("OAuthServer.getProviders")
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
# Request a token. First step of the authentication process.
|
|
10
|
+
def token_request(provider)
|
|
11
|
+
call!("OAuthServer.tokenRequest", provider)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
# Grant access to token. Second step of the authentication process.
|
|
15
|
+
def token_access(params)
|
|
16
|
+
call!("OAuthServer.tokenAccess", params)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# Identify the user. Stores the relation between the third party id
|
|
20
|
+
# and the user_id. Third step of the authentication process.
|
|
21
|
+
def token_set_user_id(user_id, oauth_session)
|
|
22
|
+
call!("OAuthServer.tokenSetUserId", user_id, oauth_session)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# Return a list of providers that the user is connected to
|
|
26
|
+
def user_get_providers(user_id)
|
|
27
|
+
call!("OAuthServer.userGetProviders", user_id)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# Remove the connection between a user and a provider
|
|
31
|
+
def user_remove_provider(user_id, provider)
|
|
32
|
+
call!("OAuthServer.userRemoveProvider", user_id, provider)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# Returns a generic (same for all providers) list of profiledata
|
|
36
|
+
def user_get_profile(user_id, provider)
|
|
37
|
+
call!("OAuthServer.userGetProfile", user_id, provider)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# Returns a generic (same for all providers) list of profiledata
|
|
41
|
+
# given a OAuthSession
|
|
42
|
+
def session_get_profile(oauth_session)
|
|
43
|
+
call!("OAuthServer.sessionGetProfile", oauth_session)
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
module Reflex
|
|
2
|
+
class System < Base
|
|
3
|
+
class << self
|
|
4
|
+
# Returns an array of available methods
|
|
5
|
+
def list_methods
|
|
6
|
+
call("System.listMethods")
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
# Returns the signature of a given method
|
|
10
|
+
def method_signature(method)
|
|
11
|
+
call("System.methodSignature", method)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
# Returns the description of a given method
|
|
15
|
+
def method_description(method)
|
|
16
|
+
call("System.methodDescription", method)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# Returns help for a given method
|
|
20
|
+
def method_help(method)
|
|
21
|
+
call("System.methodHelp", method)
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
data/lib/reflex.rb
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
|
2
|
+
|
|
3
|
+
require 'reflex/base'
|
|
4
|
+
require 'reflex/configuration'
|
|
5
|
+
require 'reflex/oauth_server'
|
|
6
|
+
require 'reflex/system'
|
|
7
|
+
|
|
8
|
+
if defined?(Authlogic)
|
|
9
|
+
require 'uuidtools'
|
|
10
|
+
require 'reflex/authlogic/acts_as_authentic'
|
|
11
|
+
require 'reflex/authlogic/session'
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
$LOAD_PATH.shift
|
data/rails/init.rb
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..'))
|
|
2
|
+
|
|
3
|
+
require 'lib/reflex'
|
|
4
|
+
|
|
5
|
+
config_file = File.join(File.dirname(Rails.root), File.basename(Rails.root), 'config', 'reflex.yml')
|
|
6
|
+
|
|
7
|
+
if File.exists?(config_file)
|
|
8
|
+
settings = YAML.load(File.open(config_file))
|
|
9
|
+
configuration = settings[Rails.env].symbolize_keys
|
|
10
|
+
|
|
11
|
+
Reflex.configure(configuration)
|
|
12
|
+
else
|
|
13
|
+
Rails.logger.warn "** [Reflex] #{config_file} does not exist, skipping Reflex configuration"
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
if defined?(Authlogic)
|
|
17
|
+
require "lib/reflex/authlogic/callback_filter"
|
|
18
|
+
|
|
19
|
+
ActionController::Dispatcher.middleware.insert_before(ActionController::ParamsParser, Reflex::Authlogic::CallbackFilter)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
$LOAD_PATH.shift
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
class ReflexConnectionMigrationGenerator < Rails::Generator::Base
|
|
2
|
+
def manifest
|
|
3
|
+
record do |m|
|
|
4
|
+
m.migration_template 'create_reflex_connections.rb', 'db/migrate',
|
|
5
|
+
:migration_file_name => 'create_reflex_connections'
|
|
6
|
+
end
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def file_name
|
|
10
|
+
'create_reflex_connections'
|
|
11
|
+
end
|
|
12
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
class CreateReflexConnections < ActiveRecord::Migration
|
|
2
|
+
def self.up
|
|
3
|
+
create_table :reflex_connections do |t|
|
|
4
|
+
t.string :provider, :null => false
|
|
5
|
+
t.string :authorizable_type, :null => false
|
|
6
|
+
t.integer :authorizable_id, :null => false
|
|
7
|
+
t.string :uuid, :null => false
|
|
8
|
+
t.timestamps
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
add_index :reflex_connections, [:authorizable_type, :authorizable_id], :unique => false
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def self.down
|
|
15
|
+
drop_table :reflex_connections
|
|
16
|
+
end
|
|
17
|
+
end
|
data/reflex.gemspec
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
# Generated by jeweler
|
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
|
4
|
+
# -*- encoding: utf-8 -*-
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |s|
|
|
7
|
+
s.name = %q{reflex}
|
|
8
|
+
s.version = "0.0.2"
|
|
9
|
+
|
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
11
|
+
s.authors = ["Tom-Eric Gerritsen"]
|
|
12
|
+
s.date = %q{2010-05-01}
|
|
13
|
+
s.description = %q{Reflex is a gem that allows you to connect your application to the React Social API}
|
|
14
|
+
s.email = %q{tomeric@i76.nl}
|
|
15
|
+
s.extra_rdoc_files = [
|
|
16
|
+
"LICENSE",
|
|
17
|
+
"README.rdoc"
|
|
18
|
+
]
|
|
19
|
+
s.files = [
|
|
20
|
+
".document",
|
|
21
|
+
".gitignore",
|
|
22
|
+
"LICENSE",
|
|
23
|
+
"README.rdoc",
|
|
24
|
+
"Rakefile",
|
|
25
|
+
"VERSION",
|
|
26
|
+
"cucumber.yml",
|
|
27
|
+
"features/connect_to_provider.feature",
|
|
28
|
+
"features/social_authentication.feature",
|
|
29
|
+
"features/step_definitions/reflex_steps.rb",
|
|
30
|
+
"features/step_definitions/web_steps.rb",
|
|
31
|
+
"features/support/env.rb",
|
|
32
|
+
"features/support/mocha.rb",
|
|
33
|
+
"features/support/mock_controller/oauth_authorize.html.erb",
|
|
34
|
+
"features/support/mocks.rb",
|
|
35
|
+
"features/support/paths.rb",
|
|
36
|
+
"features/support/rails_root/.gitignore",
|
|
37
|
+
"features/support/rails_root/Rakefile",
|
|
38
|
+
"features/support/rails_root/app/controllers/application_controller.rb",
|
|
39
|
+
"features/support/rails_root/app/controllers/user_sessions_controller.rb",
|
|
40
|
+
"features/support/rails_root/app/controllers/users_controller.rb",
|
|
41
|
+
"features/support/rails_root/app/helpers/application_helper.rb",
|
|
42
|
+
"features/support/rails_root/app/helpers/user_sessions_helper.rb",
|
|
43
|
+
"features/support/rails_root/app/helpers/users_helper.rb",
|
|
44
|
+
"features/support/rails_root/app/models/user.rb",
|
|
45
|
+
"features/support/rails_root/app/models/user_session.rb",
|
|
46
|
+
"features/support/rails_root/app/views/layouts/application.html.erb",
|
|
47
|
+
"features/support/rails_root/app/views/user_sessions/new.html.erb",
|
|
48
|
+
"features/support/rails_root/app/views/users/_form.html.erb",
|
|
49
|
+
"features/support/rails_root/app/views/users/_user.html.erb",
|
|
50
|
+
"features/support/rails_root/app/views/users/edit.html.erb",
|
|
51
|
+
"features/support/rails_root/app/views/users/index.html.erb",
|
|
52
|
+
"features/support/rails_root/app/views/users/new.html.erb",
|
|
53
|
+
"features/support/rails_root/app/views/users/show.html.erb",
|
|
54
|
+
"features/support/rails_root/config/boot.rb",
|
|
55
|
+
"features/support/rails_root/config/database.yml",
|
|
56
|
+
"features/support/rails_root/config/environment.rb",
|
|
57
|
+
"features/support/rails_root/config/environments/development.rb",
|
|
58
|
+
"features/support/rails_root/config/environments/test.rb",
|
|
59
|
+
"features/support/rails_root/config/initializers/backtrace_silencers.rb",
|
|
60
|
+
"features/support/rails_root/config/initializers/inflections.rb",
|
|
61
|
+
"features/support/rails_root/config/initializers/mime_types.rb",
|
|
62
|
+
"features/support/rails_root/config/initializers/new_rails_defaults.rb",
|
|
63
|
+
"features/support/rails_root/config/initializers/session_store.rb",
|
|
64
|
+
"features/support/rails_root/config/routes.rb",
|
|
65
|
+
"features/support/rails_root/db/migrate/001_create_users.rb",
|
|
66
|
+
"features/support/rails_root/db/migrate/002_create_reflex_connections.rb",
|
|
67
|
+
"features/support/rails_root/db/schema.rb",
|
|
68
|
+
"features/support/rails_root/vendor/plugins/reflex/rails/init.rb",
|
|
69
|
+
"features/traditional_registration_and_authentication.feature",
|
|
70
|
+
"init.rb",
|
|
71
|
+
"lib/reflex.rb",
|
|
72
|
+
"lib/reflex/authlogic/account.rb",
|
|
73
|
+
"lib/reflex/authlogic/acts_as_authentic.rb",
|
|
74
|
+
"lib/reflex/authlogic/authentication_process.rb",
|
|
75
|
+
"lib/reflex/authlogic/callback_filter.rb",
|
|
76
|
+
"lib/reflex/authlogic/connectable.rb",
|
|
77
|
+
"lib/reflex/authlogic/connection.rb",
|
|
78
|
+
"lib/reflex/authlogic/session.rb",
|
|
79
|
+
"lib/reflex/base.rb",
|
|
80
|
+
"lib/reflex/configuration.rb",
|
|
81
|
+
"lib/reflex/oauth_server.rb",
|
|
82
|
+
"lib/reflex/system.rb",
|
|
83
|
+
"rails/init.rb",
|
|
84
|
+
"rails_generators/reflex_connection_migration/reflex_connection_migration_generator.rb",
|
|
85
|
+
"rails_generators/reflex_connection_migration/templates/create_reflex_connections.rb",
|
|
86
|
+
"reflex.gemspec",
|
|
87
|
+
"spec/fakeweb/OAuthServer.getProviders",
|
|
88
|
+
"spec/fakeweb/OAuthServer.sessionGetProfile",
|
|
89
|
+
"spec/fakeweb/OAuthServer.tokenAccess",
|
|
90
|
+
"spec/fakeweb/OAuthServer.tokenRequest",
|
|
91
|
+
"spec/fakeweb/OAuthServer.tokenSetUserId",
|
|
92
|
+
"spec/fakeweb/OAuthServer.userGetProfile",
|
|
93
|
+
"spec/fakeweb/OAuthServer.userGetProviders",
|
|
94
|
+
"spec/fakeweb/OAuthServer.userRemoveProvider",
|
|
95
|
+
"spec/fakeweb/System.listMethods",
|
|
96
|
+
"spec/fakeweb/System.methodDescription",
|
|
97
|
+
"spec/fakeweb/System.methodSignature",
|
|
98
|
+
"spec/reflex/authlogic/connection_spec.rb",
|
|
99
|
+
"spec/reflex/base_spec.rb",
|
|
100
|
+
"spec/reflex/configuration_spec.rb",
|
|
101
|
+
"spec/reflex/oauth_server_spec.rb",
|
|
102
|
+
"spec/reflex/system_spec.rb",
|
|
103
|
+
"spec/reflex_spec.rb",
|
|
104
|
+
"spec/schema.rb",
|
|
105
|
+
"spec/spec.opts",
|
|
106
|
+
"spec/spec_helper.rb"
|
|
107
|
+
]
|
|
108
|
+
s.homepage = %q{http://github.com/i76/reflex}
|
|
109
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
|
110
|
+
s.require_paths = ["lib"]
|
|
111
|
+
s.rubygems_version = %q{1.3.6}
|
|
112
|
+
s.summary = %q{Reflex connects your app to the React Social API}
|
|
113
|
+
s.test_files = [
|
|
114
|
+
"spec/reflex/authlogic/connection_spec.rb",
|
|
115
|
+
"spec/reflex/base_spec.rb",
|
|
116
|
+
"spec/reflex/configuration_spec.rb",
|
|
117
|
+
"spec/reflex/oauth_server_spec.rb",
|
|
118
|
+
"spec/reflex/system_spec.rb",
|
|
119
|
+
"spec/reflex_spec.rb",
|
|
120
|
+
"spec/schema.rb",
|
|
121
|
+
"spec/spec_helper.rb"
|
|
122
|
+
]
|
|
123
|
+
|
|
124
|
+
if s.respond_to? :specification_version then
|
|
125
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
|
126
|
+
s.specification_version = 3
|
|
127
|
+
|
|
128
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
|
129
|
+
s.add_runtime_dependency(%q<authlogic>, [">= 2.1.3"])
|
|
130
|
+
s.add_runtime_dependency(%q<uuidtools>, [">= 2.1.1"])
|
|
131
|
+
s.add_development_dependency(%q<cucumber>, [">= 0.6.2"])
|
|
132
|
+
s.add_development_dependency(%q<cucumber-rails>, [">= 0.2.4"])
|
|
133
|
+
s.add_development_dependency(%q<capybara>, [">= 0.3.0"])
|
|
134
|
+
s.add_development_dependency(%q<database_cleaner>, [">= 0.4.3"])
|
|
135
|
+
s.add_development_dependency(%q<mocha>, [">= 0.9.8"])
|
|
136
|
+
s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
|
|
137
|
+
s.add_development_dependency(%q<fakeweb>, [">= 1.2.8"])
|
|
138
|
+
s.add_development_dependency(%q<mime-types>, [">= 1.16"])
|
|
139
|
+
else
|
|
140
|
+
s.add_dependency(%q<authlogic>, [">= 2.1.3"])
|
|
141
|
+
s.add_dependency(%q<uuidtools>, [">= 2.1.1"])
|
|
142
|
+
s.add_dependency(%q<cucumber>, [">= 0.6.2"])
|
|
143
|
+
s.add_dependency(%q<cucumber-rails>, [">= 0.2.4"])
|
|
144
|
+
s.add_dependency(%q<capybara>, [">= 0.3.0"])
|
|
145
|
+
s.add_dependency(%q<database_cleaner>, [">= 0.4.3"])
|
|
146
|
+
s.add_dependency(%q<mocha>, [">= 0.9.8"])
|
|
147
|
+
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
|
148
|
+
s.add_dependency(%q<fakeweb>, [">= 1.2.8"])
|
|
149
|
+
s.add_dependency(%q<mime-types>, [">= 1.16"])
|
|
150
|
+
end
|
|
151
|
+
else
|
|
152
|
+
s.add_dependency(%q<authlogic>, [">= 2.1.3"])
|
|
153
|
+
s.add_dependency(%q<uuidtools>, [">= 2.1.1"])
|
|
154
|
+
s.add_dependency(%q<cucumber>, [">= 0.6.2"])
|
|
155
|
+
s.add_dependency(%q<cucumber-rails>, [">= 0.2.4"])
|
|
156
|
+
s.add_dependency(%q<capybara>, [">= 0.3.0"])
|
|
157
|
+
s.add_dependency(%q<database_cleaner>, [">= 0.4.3"])
|
|
158
|
+
s.add_dependency(%q<mocha>, [">= 0.9.8"])
|
|
159
|
+
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
|
160
|
+
s.add_dependency(%q<fakeweb>, [">= 1.2.8"])
|
|
161
|
+
s.add_dependency(%q<mime-types>, [">= 1.16"])
|
|
162
|
+
end
|
|
163
|
+
end
|
|
164
|
+
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
HTTP/1.1 200 OK
|
|
2
|
+
Content-Type: text/xml
|
|
3
|
+
|
|
4
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
5
|
+
<methodResponse><params><param><value><array><data><value><string>Facebook</string></value><value><string>Hyves</string></value><value><string>Twitter</string></value></data></array></value></param></params></methodResponse>
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
HTTP/1.1 200 OK
|
|
2
|
+
Content-Type: text/xml
|
|
3
|
+
|
|
4
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
5
|
+
<methodResponse><params><param><value><struct><member><name>real_name</name><value><string>Barney Stinson</string></value></member><member><name>user_name</name><value><string>barney</string></value></member><member><name>profile_picture</name><value><string>http://awesome.com/barney.jpg</string></value></member></struct></value></param></params></methodResponse>
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
HTTP/1.1 200 OK
|
|
2
|
+
Content-Type: text/xml
|
|
3
|
+
|
|
4
|
+
<methodResponse><params><param><value><struct><member><name>applicationUserId</name><value><string>1</string></value></member><member><name>connectedWithProvider</name><value><string>Twitter</string></value></member><member><name>reactOAuthSession</name><value><string>FILTERED</string></value></member></struct></value></param></params></methodResponse>
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
HTTP/1.1 200 OK
|
|
2
|
+
Content-Type: text/xml
|
|
3
|
+
|
|
4
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
5
|
+
<methodResponse><params><param><value><struct><member><name>redirectUrl</name><value><string>https://twitter.com/oauth/authorize?oauth_token=FILTERED&callback=http%3A%2F%2Flocalhost%3A3000%2Fuser_sessions%3FReactOAuthSession%3DFILTERED</string></value></member><member><name>reactOAuthSession</name><value><string>FILTERED</string></value></member></struct></value></param></params></methodResponse>
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
HTTP/1.1 200 OK
|
|
2
|
+
Content-Type: text/xml
|
|
3
|
+
|
|
4
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
5
|
+
<methodResponse><params><param><value><struct><member><name>applicationUserId</name><value><string>1</string></value></member><member><name>connectedWithProvider</name><value><string>Twitter</string></value></member></struct></value></param></params></methodResponse>
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
HTTP/1.1 200 OK
|
|
2
|
+
Content-Type: text/xml
|
|
3
|
+
|
|
4
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
5
|
+
<methodResponse><params><param><value><struct><member><name>real_name</name><value><string>Barney Stinson</string></value></member><member><name>user_name</name><value><string>barney</string></value></member><member><name>profile_picture</name><value><string>http://awesome.com/barney.jpg</string></value></member></struct></value></param></params></methodResponse>
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
HTTP/1.1 200 OK
|
|
2
|
+
Content-Type: text/xml
|
|
3
|
+
|
|
4
|
+
<methodResponse><params><param><value><struct><member><name>connectedWithProviders</name><value><array><data><value><string>Facebook</string></value></data><data><value><string>Twitter</string></value></data></array></value></member></struct></value></param></params></methodResponse>
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
HTTP/1.1 200 OK
|
|
2
|
+
Content-Type: text/xml
|
|
3
|
+
|
|
4
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
5
|
+
<methodResponse><params><param><value><array><data><value><string>System.listMethods</string></value><value><string>System.methodSignature</string></value><value><string>System.methodDescription</string></value><value><string>System.methodHelp</string></value><value><string>BitLy.shorten</string></value><value><string>BitLy.expand</string></value><value><string>BitLy.info</string></value><value><string>BitLy.stats</string></value><value><string>BitLy.errors</string></value><value><string>Facebook.streamPublish</string></value><value><string>Facebook.photosCreateAlbum</string></value><value><string>Facebook.photosGetAlbums</string></value><value><string>Facebook.photosUpload</string></value><value><string>Facebook.usersGetInfo</string></value><value><string>Hyves.wwwsCreate</string></value><value><string>Hyves.albumsGetByUser</string></value><value><string>Hyves.albumsCreate</string></value><value><string>Hyves.albumsAddMedia</string></value><value><string>Hyves.doMediaUpload</string></value><value><string>Hyves.mediaGetUploadToken</string></value><value><string>Hyves.mediaUpload</string></value><value><string>Hyves.mediaUploadStatus</string></value><value><string>Hyves.usersGet</string></value><value><string>Netlog.peopleGet</string></value><value><string>Netlog.activityCreate</string></value><value><string>Netlog.friendsGet</string></value><value><string>OAuthServer.getProviders</string></value><value><string>OAuthServer.tokenRequest</string></value><value><string>OAuthServer.tokenAccess</string></value><value><string>OAuthServer.tokenSetUserId</string></value><value><string>OAuthServer.userGetProviders</string></value><value><string>OAuthServer.userRemoveProvider</string></value><value><string>OAuthServer.sessionGetProfile</string></value><value><string>OAuthServer.userGetProfile</string></value><value><string>Twitter.statusUpdate</string></value><value><string>Twitter.usersShow</string></value></data></array></value></param></params></methodResponse>
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
HTTP/1.1 200 OK
|
|
2
|
+
Content-Type: text/xml
|
|
3
|
+
|
|
4
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
5
|
+
<methodResponse><params><param><value><struct><member><name>method</name><value><struct><member><name>description</name><value><string>Our extended version of System.methodSignature, with named parameters and descriptions.</string></value></member></struct></value></member><member><name>parameters</name><value><struct><member><name>method</name><value><struct><member><name>type</name><value><string>string</string></value></member><member><name>description</name><value><string>Method to get the description for</string></value></member></struct></value></member></struct></value></member></struct></value></param></params></methodResponse>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'spec_helper'))
|
|
2
|
+
|
|
3
|
+
describe Reflex::Authlogic::Connection do
|
|
4
|
+
before(:each) do
|
|
5
|
+
@authorizable = Authorizable.create
|
|
6
|
+
@connection = Reflex::Authlogic::Connection.new(:provider => 'Twitter', :authorizable => @authorizable)
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
it "should generate a UUID before validation on create" do
|
|
10
|
+
@connection.uuid.should be_nil
|
|
11
|
+
@connection.valid?
|
|
12
|
+
@connection.uuid.should_not be_nil
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it "should not update a UUID on update validations" do
|
|
16
|
+
@connection.save
|
|
17
|
+
|
|
18
|
+
lambda {
|
|
19
|
+
@connection.save
|
|
20
|
+
}.should_not change(@connection, :uuid)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..') + '/spec_helper')
|
|
2
|
+
|
|
3
|
+
describe Reflex::Base do
|
|
4
|
+
include ReflexSpecHelper
|
|
5
|
+
|
|
6
|
+
before(:each) do
|
|
7
|
+
@configuration = Reflex.configure(:endpoint => 'http://social.react.com/XmlRpc_v2/', :secret => 'secret', :key => 'key')
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
describe "call" do
|
|
11
|
+
it "should delegate to a XMLRPC client" do
|
|
12
|
+
mock_client = mock()
|
|
13
|
+
XMLRPC::Client.expects(:new).with('social.react.com', '/XmlRpc_v2/', 80).returns(mock_client)
|
|
14
|
+
mock_client.expects(:call).with('System.methodDescription', 'System.listMethods')
|
|
15
|
+
|
|
16
|
+
Reflex::Base.call('System.methodDescription', 'System.listMethods')
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
describe "call!" do
|
|
21
|
+
it "should add authentication parameters and delete to a XMLRPC client" do
|
|
22
|
+
mock_client = mock()
|
|
23
|
+
XMLRPC::Client.expects(:new).with('social.react.com', '/XmlRpc_v2/', 80).returns(mock_client)
|
|
24
|
+
mock_client.expects(:call).with('OAuthServer.getProviders', 'key', 'secret')
|
|
25
|
+
|
|
26
|
+
Reflex::Base.call!('OAuthServer.getProviders')
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|