authlogic-connect 0.0.2 → 0.0.3.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/README.markdown +10 -14
- data/Rakefile +2 -2
- data/lib/authlogic-connect.rb +2 -1
- data/lib/authlogic_connect/common/user.rb +10 -3
- data/lib/authlogic_connect/oauth/process.rb +1 -1
- data/lib/authlogic_connect/oauth/tokens/facebook_token.rb +7 -15
- data/lib/authlogic_connect/oauth/tokens/get_satisfaction_token.rb +5 -10
- data/lib/authlogic_connect/oauth/tokens/google_token.rb +6 -11
- data/lib/authlogic_connect/oauth/tokens/linked_in_token.rb +10 -0
- data/lib/authlogic_connect/oauth/tokens/myspace_token.rb +7 -10
- data/lib/authlogic_connect/oauth/tokens/oauth_token.rb +8 -17
- data/lib/authlogic_connect/oauth/tokens/twitter_token.rb +3 -8
- data/lib/authlogic_connect/oauth/tokens/vimeo_token.rb +3 -8
- data/lib/authlogic_connect/oauth/tokens/yahoo_token.rb +6 -14
- data/lib/authlogic_connect/token.rb +12 -0
- metadata +3 -4
- data/lib/authlogic_connect/oauth/tokens/delicious_token.rb +0 -12
- data/lib/authlogic_connect/oauth/tokens/photobucket_token.rb +0 -13
- data/lib/authlogic_connect/oauth/tokens/smug_mug_token.rb +0 -14
data/README.markdown
CHANGED
@@ -62,23 +62,11 @@ Otherwise, add this migration
|
|
62
62
|
|
63
63
|
class AddAuthlogicConnectMigration < ActiveRecord::Migration
|
64
64
|
def self.up
|
65
|
-
|
66
|
-
add_column :users, :oauth_secret, :string
|
67
|
-
add_index :users, :oauth_token
|
68
|
-
|
69
|
-
change_column :users, :login, :string, :default => nil, :null => true
|
70
|
-
change_column :users, :crypted_password, :string, :default => nil, :null => true
|
71
|
-
change_column :users, :password_salt, :string, :default => nil, :null => true
|
65
|
+
# TODO
|
72
66
|
end
|
73
67
|
|
74
68
|
def self.down
|
75
|
-
|
76
|
-
remove_column :users, :oauth_secret
|
77
|
-
|
78
|
-
[:login, :crypted_password, :password_salt].each do |field|
|
79
|
-
User.all(:conditions => "#{field} is NULL").each { |user| user.update_attribute(field, "") if user.send(field).nil? }
|
80
|
-
change_column :users, field, :string, :default => "", :null => false
|
81
|
-
end
|
69
|
+
# TODO
|
82
70
|
end
|
83
71
|
end
|
84
72
|
|
@@ -176,6 +164,14 @@ That's it! The rest is taken care of for you.
|
|
176
164
|
|
177
165
|
This has no tests! I had to build this in a weekend and am not fluent with Shoulda, which I'd like to use. One of these days when I can breathe.
|
178
166
|
|
167
|
+
## Goals
|
168
|
+
|
169
|
+
1. It should require the end user ONE CLICK to create an account with your site.
|
170
|
+
2. It should not depend on Javascript
|
171
|
+
3. It should be enhanced by Javascript
|
172
|
+
4. You should never have to touch the User/Session model/controller/migration if you are a just looking to get up and running quickly.
|
173
|
+
5. You should be able to plugin ruby libraries that wrap an api, such as TwitterAuth via `@user.twitter`, and LinkedIn via `@user.linked_in`. Just because it's that easy.
|
174
|
+
|
179
175
|
## TODO
|
180
176
|
|
181
177
|
- Change `register_with_oauth` and related to `register_method` and `login_method`: oauth, openid, traditional
|
data/Rakefile
CHANGED
@@ -6,7 +6,7 @@ require 'rake/gempackagetask'
|
|
6
6
|
spec = Gem::Specification.new do |s|
|
7
7
|
s.name = "authlogic-connect"
|
8
8
|
s.author = "Lance Pollard"
|
9
|
-
s.version = "0.0.2"
|
9
|
+
s.version = "0.0.3.2"
|
10
10
|
s.summary = "Authlogic Connect: Let your app use all of Oauth and OpenID"
|
11
11
|
s.homepage = "http://github.com/viatropos/authlogic-connect"
|
12
12
|
s.email = "lancejpollard@gmail.com"
|
@@ -38,7 +38,7 @@ end
|
|
38
38
|
|
39
39
|
desc "Publish gem to rubygems"
|
40
40
|
task :publish => [:package] do
|
41
|
-
|
41
|
+
%x[gem push pkg/#{spec.name}-#{spec.version}.gem]
|
42
42
|
end
|
43
43
|
|
44
44
|
desc "Print a list of the files to be put into the gem"
|
data/lib/authlogic-connect.rb
CHANGED
@@ -3,6 +3,7 @@ require 'authlogic'
|
|
3
3
|
require 'oauth'
|
4
4
|
require 'oauth2'
|
5
5
|
|
6
|
+
|
6
7
|
# Throw callback rack app into the middleware stack
|
7
8
|
# TODO: Somehow do this for Rails 3?
|
8
9
|
# For now it is in the sample Rails 3 app
|
@@ -78,7 +79,7 @@ module AuthlogicConnect
|
|
78
79
|
end
|
79
80
|
|
80
81
|
def token(key)
|
81
|
-
|
82
|
+
raise "can't find key '#{key.to_s}' in AuthlogicConnect.config" unless AuthlogicConnect.include?(key) and !key.to_s.empty?
|
82
83
|
"#{key.to_s.camelcase}Token".constantize
|
83
84
|
end
|
84
85
|
|
@@ -10,6 +10,14 @@ module AuthlogicConnect::Common
|
|
10
10
|
|
11
11
|
module InstanceMethods
|
12
12
|
|
13
|
+
def authenticated_with
|
14
|
+
@authenticated_with ||= self.tokens.collect{|t| t.service_name.to_s}
|
15
|
+
end
|
16
|
+
|
17
|
+
def authenticated_with?(service)
|
18
|
+
self.tokens.detect{|t| t.service_name.to_s == service.to_s}
|
19
|
+
end
|
20
|
+
|
13
21
|
# core save method coordinating how to save the user
|
14
22
|
def save(perform_validation = true, &block)
|
15
23
|
status = true
|
@@ -19,11 +27,10 @@ module AuthlogicConnect::Common
|
|
19
27
|
status = save_with_oauth(perform_validation, &block)
|
20
28
|
end
|
21
29
|
if status
|
22
|
-
result = super
|
30
|
+
result = super(:validate => true)
|
23
31
|
yield(result) if block_given?
|
24
|
-
result
|
25
32
|
end
|
26
|
-
|
33
|
+
result
|
27
34
|
end
|
28
35
|
|
29
36
|
def validate_password_with_oauth?
|
@@ -2,18 +2,10 @@
|
|
2
2
|
# http://developers.facebook.com/setup/
|
3
3
|
class FacebookToken < OauthToken
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
}
|
13
|
-
end
|
14
|
-
|
15
|
-
def oauth_version
|
16
|
-
2.0
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
5
|
+
version 2.0
|
6
|
+
|
7
|
+
settings "https://graph.facebook.com",
|
8
|
+
:authorize_url => "https://graph.facebook.com/oauth/authorize",
|
9
|
+
:scope => "email, offline_access"
|
10
|
+
|
11
|
+
end
|
@@ -1,14 +1,9 @@
|
|
1
1
|
# http://getsatisfaction.com/developers/oauth
|
2
2
|
class GetSatisfactionToken < OauthToken
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
:authorize_url => "/api/authorize",
|
10
|
-
:access_token_path => "/api/access_token"
|
11
|
-
}
|
12
|
-
end
|
13
|
-
end
|
4
|
+
settings "http://getsatisfaction.com",
|
5
|
+
:request_token_path => "/api/request_token",
|
6
|
+
:authorize_url => "/api/authorize",
|
7
|
+
:access_token_path => "/api/access_token"
|
8
|
+
|
14
9
|
end
|
@@ -24,15 +24,10 @@
|
|
24
24
|
# YouTube http://gdata.youtube.com
|
25
25
|
class GoogleToken < OauthToken
|
26
26
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
:access_token_path => "/accounts/OAuthGetAccessToken",
|
34
|
-
:scope => "https://www.google.com/m8/feeds/"
|
35
|
-
}
|
36
|
-
end
|
37
|
-
end
|
27
|
+
settings "https://www.google.com",
|
28
|
+
:request_token_path => "/accounts/OAuthGetRequestToken",
|
29
|
+
:authorize_path => "/accounts/OAuthAuthorizeToken",
|
30
|
+
:access_token_path => "/accounts/OAuthGetAccessToken",
|
31
|
+
:scope => "https://www.google.com/m8/feeds/"
|
32
|
+
|
38
33
|
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# http://developer.linkedin.com/docs/DOC-1008
|
2
|
+
# http://github.com/pengwynn/linkedin/tree/master/lib/linked_in/
|
3
|
+
class LinkedInToken < OauthToken
|
4
|
+
|
5
|
+
settings "https://api.linkedin.com",
|
6
|
+
:request_token_path => "/uas/oauth/requestToken",
|
7
|
+
:access_token_path => "/uas/oauth/accessToken",
|
8
|
+
:authorize_path => "/uas/oauth/authorize"
|
9
|
+
|
10
|
+
end
|
@@ -1,14 +1,11 @@
|
|
1
1
|
# http://wiki.developer.myspace.com/index.php?title=Category:MySpaceID
|
2
|
+
# http://developerwiki.myspace.com/index.php?title=OAuth_REST_API_Usage_-_Authentication_Process
|
3
|
+
# http://developerwiki.myspace.com/index.php?title=How_to_Set_Up_a_New_Application_for_OpenID
|
2
4
|
class MyspaceToken < OauthToken
|
3
5
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
:authorize_path => "/accounts/OAuthAuthorizeToken",
|
10
|
-
:access_token_path => "/accounts/OAuthGetAccessToken"
|
11
|
-
}
|
12
|
-
end
|
13
|
-
end
|
6
|
+
settings "http://api.myspace.com",
|
7
|
+
:request_token_path => "/request_token",
|
8
|
+
:authorize_path => "/authorize",
|
9
|
+
:access_token_path => "/access_token"
|
10
|
+
|
14
11
|
end
|
@@ -1,6 +1,5 @@
|
|
1
1
|
class OauthToken < Token
|
2
|
-
|
3
|
-
# preexisting library eg. Twitter gem.
|
2
|
+
|
4
3
|
def client
|
5
4
|
unless @client
|
6
5
|
if oauth_version == 1.0
|
@@ -13,14 +12,6 @@ class OauthToken < Token
|
|
13
12
|
@client
|
14
13
|
end
|
15
14
|
|
16
|
-
def consumer
|
17
|
-
self.class.consumer
|
18
|
-
end
|
19
|
-
|
20
|
-
def simple_client
|
21
|
-
@simple_client ||= SimpleClient.new(OAuth::AccessToken.new(self.class.consumer, token, secret))
|
22
|
-
end
|
23
|
-
|
24
15
|
def oauth_version
|
25
16
|
self.class.oauth_version
|
26
17
|
end
|
@@ -31,20 +22,20 @@ class OauthToken < Token
|
|
31
22
|
|
32
23
|
class << self
|
33
24
|
|
34
|
-
def
|
35
|
-
|
25
|
+
def version(value)
|
26
|
+
@oauth_version = value
|
36
27
|
end
|
37
28
|
|
38
|
-
def
|
39
|
-
@
|
29
|
+
def oauth_version
|
30
|
+
@oauth_version ||= 1.0
|
40
31
|
end
|
41
32
|
|
42
33
|
def consumer
|
43
34
|
unless @consumer
|
44
35
|
if oauth_version == 1.0
|
45
|
-
@consumer = OAuth::Consumer.new(credentials[:key], credentials[:secret],
|
36
|
+
@consumer = OAuth::Consumer.new(credentials[:key], credentials[:secret], config.merge(credentials[:options] || {}))
|
46
37
|
else
|
47
|
-
@consumer = OAuth2::Client.new(credentials[:key], credentials[:secret],
|
38
|
+
@consumer = OAuth2::Client.new(credentials[:key], credentials[:secret], config)
|
48
39
|
end
|
49
40
|
end
|
50
41
|
|
@@ -56,7 +47,7 @@ class OauthToken < Token
|
|
56
47
|
end
|
57
48
|
|
58
49
|
def get_request_token(callback_url)
|
59
|
-
consumer.get_request_token({:oauth_callback => callback_url},
|
50
|
+
consumer.get_request_token({:oauth_callback => callback_url}, config)
|
60
51
|
end
|
61
52
|
|
62
53
|
def get_access_token(oauth_verifier)
|
@@ -1,11 +1,6 @@
|
|
1
1
|
class TwitterToken < OauthToken
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
:site => "http://twitter.com",
|
7
|
-
:authorize_url => "http://twitter.com/oauth/authenticate"
|
8
|
-
}
|
9
|
-
end
|
10
|
-
end
|
3
|
+
settings "http://twitter.com",
|
4
|
+
:authorize_url => "http://twitter.com/oauth/authenticate"
|
5
|
+
|
11
6
|
end
|
@@ -2,12 +2,7 @@
|
|
2
2
|
# http://www.vimeo.com/api/applications/new
|
3
3
|
class VimeoToken < OauthToken
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
:site => "http://vimeo.com",
|
9
|
-
:authorize_url => "http://vimeo.com/oauth/authorize"
|
10
|
-
}
|
11
|
-
end
|
12
|
-
end
|
5
|
+
settings "http://vimeo.com",
|
6
|
+
:authorize_url => "http://vimeo.com/oauth/authorize"
|
7
|
+
|
13
8
|
end
|
@@ -2,19 +2,11 @@
|
|
2
2
|
# http://developer.yahoo.com/oauth/guide/oauth-accesstoken.html
|
3
3
|
class YahooToken < OauthToken
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
:authorize_path => '/oauth/v2/request_auth'
|
12
|
-
}
|
13
|
-
end
|
14
|
-
|
15
|
-
def oauth_version
|
16
|
-
2.0
|
17
|
-
end
|
18
|
-
end
|
5
|
+
version 2
|
6
|
+
|
7
|
+
settings "https://api.login.yahoo.com",
|
8
|
+
:request_token_path => '/oauth/v2/get_request_token',
|
9
|
+
:access_token_path => '/oauth/v2/get_token',
|
10
|
+
:authorize_path => '/oauth/v2/request_auth'
|
19
11
|
|
20
12
|
end
|
@@ -14,6 +14,10 @@ class Token < ActiveRecord::Base
|
|
14
14
|
self.class.service_name
|
15
15
|
end
|
16
16
|
|
17
|
+
def settings
|
18
|
+
self.class.settings
|
19
|
+
end
|
20
|
+
|
17
21
|
def get(path)
|
18
22
|
|
19
23
|
end
|
@@ -31,6 +35,14 @@ class Token < ActiveRecord::Base
|
|
31
35
|
raise "implement consumer in subclass"
|
32
36
|
end
|
33
37
|
|
38
|
+
def settings(site, hash = {})
|
39
|
+
@settings = hash.merge(:site => site)
|
40
|
+
end
|
41
|
+
|
42
|
+
def config
|
43
|
+
@settings ||= {}
|
44
|
+
end
|
45
|
+
|
34
46
|
protected
|
35
47
|
|
36
48
|
def credentials
|
metadata
CHANGED
@@ -5,8 +5,9 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
+
- 3
|
8
9
|
- 2
|
9
|
-
version: 0.0.2
|
10
|
+
version: 0.0.3.2
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Lance Pollard
|
@@ -115,15 +116,13 @@ files:
|
|
115
116
|
- lib/authlogic_connect/oauth/helper.rb
|
116
117
|
- lib/authlogic_connect/oauth/process.rb
|
117
118
|
- lib/authlogic_connect/oauth/session.rb
|
118
|
-
- lib/authlogic_connect/oauth/tokens/delicious_token.rb
|
119
119
|
- lib/authlogic_connect/oauth/tokens/facebook_token.rb
|
120
120
|
- lib/authlogic_connect/oauth/tokens/get_satisfaction_token.rb
|
121
121
|
- lib/authlogic_connect/oauth/tokens/google_token.rb
|
122
|
+
- lib/authlogic_connect/oauth/tokens/linked_in_token.rb
|
122
123
|
- lib/authlogic_connect/oauth/tokens/myspace_token.rb
|
123
124
|
- lib/authlogic_connect/oauth/tokens/oauth_token.rb
|
124
125
|
- lib/authlogic_connect/oauth/tokens/opensocial_token.rb
|
125
|
-
- lib/authlogic_connect/oauth/tokens/photobucket_token.rb
|
126
|
-
- lib/authlogic_connect/oauth/tokens/smug_mug_token.rb
|
127
126
|
- lib/authlogic_connect/oauth/tokens/twitter_token.rb
|
128
127
|
- lib/authlogic_connect/oauth/tokens/vimeo_token.rb
|
129
128
|
- lib/authlogic_connect/oauth/tokens/yahoo_token.rb
|
@@ -1,13 +0,0 @@
|
|
1
|
-
# http://photobucket.com/developer/
|
2
|
-
# https://login.photobucket.com/developer/register
|
3
|
-
class PhotobucketToken < OauthToken
|
4
|
-
|
5
|
-
class << self
|
6
|
-
def settings
|
7
|
-
@settings ||= {
|
8
|
-
:site => "http://twitter.com",
|
9
|
-
:authorize_url => "http://twitter.com/oauth/authenticate"
|
10
|
-
}
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
# http://wiki.smugmug.net/display/API/OAuth
|
2
|
-
class SmugMugToken < OauthToken
|
3
|
-
|
4
|
-
class << self
|
5
|
-
def settings
|
6
|
-
@settings ||= {
|
7
|
-
:site => "http://api.smugmug.com",
|
8
|
-
:request_token_path => "/services/oauth/getRequestToken.mg",
|
9
|
-
:authorize_url => "/services/oauth/authorize.mg",
|
10
|
-
:access_token_path => "/services/oauth/getAccessToken.mg"
|
11
|
-
}
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|