easy_auth-oauth 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: bef3a7129c4beab51adf4acabc57daccc5de46ed
4
+ data.tar.gz: 237cd95ec4bf89f0ded4b476ae93eca28b105da8
5
+ SHA512:
6
+ metadata.gz: 2481a9d72060516a986b6220e0a4c5ea473a4b32bd6f7a66f4fdadbdc75eb66b7edca02029130653b7df0eb80dd3850f0370d89d247887f6c68fba5044761230
7
+ data.tar.gz: 91fbc925f577f1152da16c8b1a448f3403dd579fd05a5feafd205bd1916d62644436fc188e85d8453e23a548c3c27ff5e85e68ca58777901c534e7c4a09a5f66
data/README.md CHANGED
@@ -14,13 +14,8 @@ In your Gemfile add the following:
14
14
  gem 'easy_auth-oauth'
15
15
  ```
16
16
 
17
- After running Bundler you'll need to install the migrations
18
-
19
- ```ruby
20
- rake easy_auth-oauth:install:migrations
21
- ```
22
-
23
- Then run your migrations.
17
+ Then follow the general installation instructions for
18
+ [EasyAuth](https://github.com/dockyard/easy_auth#installation)
24
19
 
25
20
  ## Authors ##
26
21
 
@@ -1,32 +1,32 @@
1
+ require 'easy_auth-oauth_core'
1
2
  require 'oauth'
2
3
 
3
4
  module EasyAuth::Models::Identities::Oauth::Base
4
- def self.included(base)
5
- base.class_eval do
6
- serialize :token, Hash
7
- extend ClassMethods
8
- end
5
+ extend ActiveSupport::Concern
6
+ include EasyAuth::Models::Identities::OauthCore
7
+
8
+ included do
9
+ serialize :token, Hash
9
10
  end
10
11
 
11
12
  module ClassMethods
12
13
  def authenticate(controller)
13
- oauth_token = controller.params[:oauth_token]
14
- oauth_verifier = controller.params[:oauth_verifier]
15
- access_token_secret = controller.session.delete('access_token_secret')
16
- request_token = OAuth::RequestToken.new(client, oauth_token, access_token_secret)
17
- token = request_token.get_access_token(:oauth_verifier => oauth_verifier)
18
- username = retrieve_username(token)
19
- identity = self.find_or_initialize_by_username username.to_s
20
- identity.token = {:token => token.token, :secret => token.secret}
21
- account = controller.current_account
22
-
23
- if identity.new_record?
24
- account = EasyAuth.account_model.create(EasyAuth.account_model.identity_username_attribute => identity.username) if account.nil?
25
- identity.account = account
14
+ super(controller) do
15
+ oauth_token = controller.params[:oauth_token]
16
+ oauth_verifier = controller.params[:oauth_verifier]
17
+ access_token_secret = controller.session.delete('access_token_secret')
18
+ request_token = OAuth::RequestToken.new(client, oauth_token, access_token_secret)
19
+ token = request_token.get_access_token(:oauth_verifier => oauth_verifier)
20
+ account_attributes = get_account_attributes(token)
21
+ identity = self.find_or_initialize_by(uid: retrieve_uid(account_attributes))
22
+ identity.token = {:token => token.token, :secret => token.secret}
23
+
24
+ [identity, account_attributes]
26
25
  end
26
+ end
27
27
 
28
- identity.save!
29
- identity
28
+ def can_authenticate?(controller)
29
+ controller.params[:oauth_token].present? && controller.params[:oauth_verifier].present?
30
30
  end
31
31
 
32
32
  def new_session(controller)
@@ -37,22 +37,16 @@ module EasyAuth::Models::Identities::Oauth::Base
37
37
  ::OAuth::AccessToken.new client, identity.token[:token], identity.token[:secret]
38
38
  end
39
39
 
40
- private
41
-
42
- def token_options(callback_url)
43
- { :redirect_uri => callback_url }
44
- end
45
-
46
40
  def client_options
47
41
  { :site => site_url, :authorize_path => authorize_path }
48
42
  end
49
43
 
50
- def provider
51
- raise NotImplementedError
44
+ def get_account_attributes(token)
45
+ token.params
52
46
  end
53
47
 
54
- def retrieve_username(token)
55
- raise NotImplementedError
48
+ def version
49
+ :oauth
56
50
  end
57
51
 
58
52
  def client
@@ -72,29 +66,5 @@ module EasyAuth::Models::Identities::Oauth::Base
72
66
  def site_url
73
67
  raise NotImplementedError
74
68
  end
75
-
76
- def scope
77
- settings.scope
78
- end
79
-
80
- def client_id
81
- settings.client_id
82
- end
83
-
84
- def secret
85
- settings.secret
86
- end
87
-
88
- def settings
89
- EasyAuth.oauth[provider]
90
- end
91
-
92
- def provider
93
- self.to_s.split('::').last.underscore.to_sym
94
- end
95
- end
96
-
97
- def get_access_token
98
- self.class.get_access_token self
99
69
  end
100
70
  end
@@ -43,8 +43,8 @@ module EasyAuth
43
43
 
44
44
  self.oauth = {}
45
45
 
46
- def self.oauth_client(provider, client_id, secret, scope = '')
47
- oauth[provider] = OpenStruct.new :client_id => client_id, :secret => secret, :scope => scope || ''
46
+ def self.oauth_client(provider, client_id, secret)
47
+ oauth[provider] = OpenStruct.new :client_id => client_id, :secret => secret
48
48
  end
49
49
  end
50
50
 
@@ -2,15 +2,15 @@ module EasyAuth::Oauth::Controllers::Sessions
2
2
 
3
3
  private
4
4
 
5
- def after_successful_sign_in_with_oauth(identity)
6
- send("after_successful_sign_in_with_oauth_for_#{params[:provider]}", identity)
5
+ def after_successful_sign_in_with_oauth
6
+ send("after_successful_sign_in_with_oauth_for_#{params[:provider]}")
7
7
  end
8
8
 
9
- def after_successful_sign_in_url_with_oauth(identity)
10
- send("after_successful_sign_in_url_with_oauth_for_#{params[:provider]}", identity)
9
+ def after_successful_sign_in_url_with_oauth
10
+ send("after_successful_sign_in_url_with_oauth_for_#{params[:provider]}")
11
11
  end
12
12
 
13
- def after_failed_sign_in_with_oauth(identity)
14
- send("after_failed_sign_in_with_oauth_for_#{params[:provider]}", identity)
13
+ def after_failed_sign_in_with_oauth
14
+ send("after_failed_sign_in_with_oauth_for_#{params[:provider]}")
15
15
  end
16
16
  end
@@ -1,5 +1,5 @@
1
1
  module EasyAuth
2
2
  module Oauth
3
- VERSION = '0.1.0'
3
+ VERSION = '0.2.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: easy_auth-oauth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
5
- prerelease:
4
+ version: 0.2.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Brian Cardarella
@@ -10,28 +9,39 @@ authors:
10
9
  autorequire:
11
10
  bindir: bin
12
11
  cert_chain: []
13
- date: 2012-11-05 00:00:00.000000000 Z
12
+ date: 2014-03-11 00:00:00.000000000 Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: easy_auth
17
16
  requirement: !ruby/object:Gem::Requirement
18
- none: false
19
17
  requirements:
20
18
  - - ~>
21
19
  - !ruby/object:Gem::Version
22
- version: 0.2.0
20
+ version: 0.3.0
23
21
  type: :runtime
24
22
  prerelease: false
25
23
  version_requirements: !ruby/object:Gem::Requirement
26
- none: false
27
24
  requirements:
28
25
  - - ~>
29
26
  - !ruby/object:Gem::Version
30
- version: 0.2.0
27
+ version: 0.3.0
28
+ - !ruby/object:Gem::Dependency
29
+ name: easy_auth-oauth_core
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - '>='
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - '>='
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
31
42
  - !ruby/object:Gem::Dependency
32
43
  name: oauth
33
44
  requirement: !ruby/object:Gem::Requirement
34
- none: false
35
45
  requirements:
36
46
  - - ~>
37
47
  - !ruby/object:Gem::Version
@@ -39,7 +49,6 @@ dependencies:
39
49
  type: :runtime
40
50
  prerelease: false
41
51
  version_requirements: !ruby/object:Gem::Requirement
42
- none: false
43
52
  requirements:
44
53
  - - ~>
45
54
  - !ruby/object:Gem::Version
@@ -47,71 +56,62 @@ dependencies:
47
56
  - !ruby/object:Gem::Dependency
48
57
  name: rspec
49
58
  requirement: !ruby/object:Gem::Requirement
50
- none: false
51
59
  requirements:
52
- - - ! '>='
60
+ - - '>='
53
61
  - !ruby/object:Gem::Version
54
62
  version: '0'
55
63
  type: :development
56
64
  prerelease: false
57
65
  version_requirements: !ruby/object:Gem::Requirement
58
- none: false
59
66
  requirements:
60
- - - ! '>='
67
+ - - '>='
61
68
  - !ruby/object:Gem::Version
62
69
  version: '0'
63
70
  - !ruby/object:Gem::Dependency
64
71
  name: sqlite3
65
72
  requirement: !ruby/object:Gem::Requirement
66
- none: false
67
73
  requirements:
68
- - - ! '>='
74
+ - - '>='
69
75
  - !ruby/object:Gem::Version
70
76
  version: '0'
71
77
  type: :development
72
78
  prerelease: false
73
79
  version_requirements: !ruby/object:Gem::Requirement
74
- none: false
75
80
  requirements:
76
- - - ! '>='
81
+ - - '>='
77
82
  - !ruby/object:Gem::Version
78
83
  version: '0'
79
84
  - !ruby/object:Gem::Dependency
80
85
  name: database_cleaner
81
86
  requirement: !ruby/object:Gem::Requirement
82
- none: false
83
87
  requirements:
84
- - - ! '>='
88
+ - - '>='
85
89
  - !ruby/object:Gem::Version
86
90
  version: '0'
87
91
  type: :development
88
92
  prerelease: false
89
93
  version_requirements: !ruby/object:Gem::Requirement
90
- none: false
91
94
  requirements:
92
- - - ! '>='
95
+ - - '>='
93
96
  - !ruby/object:Gem::Version
94
97
  version: '0'
95
98
  - !ruby/object:Gem::Dependency
96
99
  name: valid_attribute
97
100
  requirement: !ruby/object:Gem::Requirement
98
- none: false
99
101
  requirements:
100
- - - ! '>='
102
+ - - '>='
101
103
  - !ruby/object:Gem::Version
102
104
  version: '0'
103
105
  type: :development
104
106
  prerelease: false
105
107
  version_requirements: !ruby/object:Gem::Requirement
106
- none: false
107
108
  requirements:
108
- - - ! '>='
109
+ - - '>='
109
110
  - !ruby/object:Gem::Version
110
111
  version: '0'
111
112
  - !ruby/object:Gem::Dependency
112
113
  name: factory_girl
113
114
  requirement: !ruby/object:Gem::Requirement
114
- none: false
115
115
  requirements:
116
116
  - - ~>
117
117
  - !ruby/object:Gem::Version
@@ -119,7 +119,6 @@ dependencies:
119
119
  type: :development
120
120
  prerelease: false
121
121
  version_requirements: !ruby/object:Gem::Requirement
122
- none: false
123
122
  requirements:
124
123
  - - ~>
125
124
  - !ruby/object:Gem::Version
@@ -127,17 +126,15 @@ dependencies:
127
126
  - !ruby/object:Gem::Dependency
128
127
  name: bourne
129
128
  requirement: !ruby/object:Gem::Requirement
130
- none: false
131
129
  requirements:
132
- - - ! '>='
130
+ - - '>='
133
131
  - !ruby/object:Gem::Version
134
132
  version: '0'
135
133
  type: :development
136
134
  prerelease: false
137
135
  version_requirements: !ruby/object:Gem::Requirement
138
- none: false
139
136
  requirements:
140
- - - ! '>='
137
+ - - '>='
141
138
  - !ruby/object:Gem::Version
142
139
  version: '0'
143
140
  description: EasyAuth-Oauth
@@ -165,32 +162,25 @@ files:
165
162
  - README.md
166
163
  homepage: https://github.com/dockyard/easy_auth-oauth
167
164
  licenses: []
165
+ metadata: {}
168
166
  post_install_message:
169
167
  rdoc_options: []
170
168
  require_paths:
171
169
  - lib
172
170
  required_ruby_version: !ruby/object:Gem::Requirement
173
- none: false
174
171
  requirements:
175
- - - ! '>='
172
+ - - '>='
176
173
  - !ruby/object:Gem::Version
177
174
  version: '0'
178
- segments:
179
- - 0
180
- hash: 4126111251491885690
181
175
  required_rubygems_version: !ruby/object:Gem::Requirement
182
- none: false
183
176
  requirements:
184
- - - ! '>='
177
+ - - '>='
185
178
  - !ruby/object:Gem::Version
186
179
  version: '0'
187
- segments:
188
- - 0
189
- hash: 4126111251491885690
190
180
  requirements: []
191
181
  rubyforge_project:
192
- rubygems_version: 1.8.23
182
+ rubygems_version: 2.0.3
193
183
  signing_key:
194
- specification_version: 3
184
+ specification_version: 4
195
185
  summary: EasyAuth-Oauth
196
186
  test_files: []