Empact-authlogic_rpx 1.1.4 → 1.1.5
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/Empact-authlogic_rpx.gemspec +2 -2
- data/README.rdoc +10 -2
- data/VERSION +1 -1
- data/lib/authlogic_rpx/acts_as_authentic.rb +112 -82
- data/lib/authlogic_rpx/helper.rb +1 -1
- data/lib/authlogic_rpx/rpx_identifier.rb +0 -1
- metadata +3 -3
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{Empact-authlogic_rpx}
|
8
|
-
s.version = "1.1.
|
8
|
+
s.version = "1.1.5"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Paul Gallagher / tardate"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-05-22}
|
13
13
|
s.description = %q{Authlogic extension/plugin that provides RPX (rpxnow.com) authentication support}
|
14
14
|
s.email = %q{gallagher.paul@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
data/README.rdoc
CHANGED
@@ -10,10 +10,11 @@ This fork enables full-featured auto-registration without sacrificing database c
|
|
10
10
|
Authlogic_RPX is an Authlogic extension library that provides support for authentication using the RPX multi-authentication service offered by JanRain. To use RPX, you must first register your application at {RPX}[http://rpxnow.com/]. A free "Basic" account is available, in addition to paid enhanced versions. All work with Authlogic_RPX.
|
11
11
|
|
12
12
|
Key features and capabilities:
|
13
|
+
* You can offer your users all the authentication methods supported by RPX (OpenID, Facebook, twitter, Google, Yahoo!, LinkedIn etc)
|
13
14
|
* Auto-registration by default following RPX authentication (can be disabled if required)
|
14
|
-
* Can allow users to enable RPX authentication for their existing password-enabled accounts
|
15
15
|
* View helpers to assist with inserting login fragments in pages
|
16
16
|
* Can co-exist with standard password authentication
|
17
|
+
* Allow users to enable RPX authentication for any existing password-enabled accounts
|
17
18
|
* Supports identity mapping and merging (allowing users to have multiple logins associated with one member record on your site)
|
18
19
|
|
19
20
|
|
@@ -582,6 +583,13 @@ For example, to insert a login link in a navigation bar is as simple as this:
|
|
582
583
|
<% end %>
|
583
584
|
</div>
|
584
585
|
|
586
|
+
<b>NOTE:</b> One of the most common problems people encounter in testing out authlogic_rpx is to <b>no set the correct :app_name</b>.
|
587
|
+
The example above shows how this parameter is set for the rails-authlogic-rpx-sample, but you need to replace this value with the
|
588
|
+
name you registered at rpxnow.com .
|
589
|
+
|
590
|
+
<b>NOTE2:</b> Make sure the application name is entered here all in lowercase. If you do not, it can cause SSL certificate errors to
|
591
|
+
be displayed when logging in with certain browsers (notably Android 2.1 webkit).
|
592
|
+
|
585
593
|
=== 8. Allow users to "Add RPX" to existing accounts (optional)
|
586
594
|
|
587
595
|
If you got this far and have a working application, you are ready to go, especially if you only plan to support RPX authentication.
|
@@ -732,4 +740,4 @@ The idea of adding RPX support to authlogic is not new. Some early ideas were fo
|
|
732
740
|
* <b>http://github.com/gampleman/authlogic_rpx/</b> similar, but including an implementation of the RPX api
|
733
741
|
|
734
742
|
authlogic_rpx was created by Paul Gallagher (tardate.com) and released under the MIT license.
|
735
|
-
Big thanks for contributions from {John}[http://gitub.com/jjb]
|
743
|
+
Big thanks for contributions from {Joris}[http://github.com/trooster], {John}[http://gitub.com/jjb], {Damir}[http://gitub.com/sidonath], {Ben}[http://github.com/Empact]
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.1.
|
1
|
+
1.1.5
|
@@ -32,7 +32,6 @@ module AuthlogicRpx
|
|
32
32
|
end
|
33
33
|
alias_method :account_merge_enabled=,:account_merge_enabled
|
34
34
|
|
35
|
-
|
36
35
|
# account_mapping_mode is used to explicitly set/override the mapping behaviour.
|
37
36
|
#
|
38
37
|
# * <tt>Default:</tt> :auto
|
@@ -78,73 +77,64 @@ module AuthlogicRpx
|
|
78
77
|
|
79
78
|
module Methods
|
80
79
|
|
81
|
-
#
|
80
|
+
# Mix-in the required methods based on mapping mode
|
81
|
+
#
|
82
82
|
def self.included(klass)
|
83
83
|
klass.class_eval do
|
84
84
|
|
85
85
|
case
|
86
86
|
when using_no_mapping?
|
87
|
-
|
88
|
-
alias_method :add_rpx_identifier, :add_rpx_identifier__nomap
|
89
|
-
alias_method :identified_by?, :identified_by__nomap?
|
90
|
-
alias_method :merge_user_id, :merge_user_id__nomap
|
91
|
-
|
92
|
-
# Uses default find_by_rpx_identifier class method
|
93
|
-
|
94
|
-
# Add an rpx_identifier collection method
|
95
|
-
def rpx_identifiers
|
96
|
-
[{ :identifier => rpx_identifier, :provider_name => "Unknown" }]
|
97
|
-
end
|
87
|
+
include AuthlogicRpx::MethodSet_NoMapping
|
98
88
|
|
99
89
|
when using_internal_mapping?
|
100
|
-
|
101
|
-
|
102
|
-
alias_method :identified_by?, :identified_by__internal?
|
103
|
-
alias_method :merge_user_id, :merge_user_id__internal
|
104
|
-
has_many :rpx_identifiers, :class_name => 'RPXIdentifier', :validate => false, :dependent => :destroy
|
90
|
+
include AuthlogicRpx::MethodSet_InternalMapping
|
91
|
+
has_many :rpx_identifiers, :class_name => 'RPXIdentifier', :dependent => :destroy
|
105
92
|
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
93
|
+
# Add custom find_by_rpx_identifier class method
|
94
|
+
#
|
95
|
+
def self.find_by_rpx_identifier(id)
|
96
|
+
identifier = RPXIdentifier.find_by_identifier(id)
|
97
|
+
if identifier.nil?
|
98
|
+
if self.column_names.include? 'rpx_identifier'
|
99
|
+
# check for authentication using <=1.0.4, migrate identifier to rpx_identifiers table
|
100
|
+
user = self.find( :first, :conditions => [ "rpx_identifier = ?", id ] )
|
101
|
+
unless user.nil?
|
102
|
+
user.add_rpx_identifier( id, 'Unknown' )
|
103
|
+
end
|
104
|
+
return user
|
105
|
+
else
|
106
|
+
return nil
|
107
|
+
end
|
108
|
+
else
|
109
|
+
identifier.send( self.class_name.downcase )
|
110
|
+
end
|
111
|
+
end
|
124
112
|
|
125
113
|
else
|
126
114
|
raise AuthlogicRpx::ActsAsAuthentic::ConfigurationError.new( "invalid or unsupported account_mapping_mode" )
|
127
115
|
end
|
128
116
|
|
129
|
-
|
130
|
-
|
131
|
-
|
117
|
+
# Set up some fundamental conditional validations
|
118
|
+
validates_length_of_password_field_options validates_length_of_password_field_options.merge(:if => :validate_password_not_rpx?)
|
119
|
+
validates_confirmation_of_password_field_options validates_confirmation_of_password_field_options.merge(:if => :validate_password_not_rpx?)
|
120
|
+
validates_length_of_password_confirmation_field_options validates_length_of_password_confirmation_field_options.merge(:if => :validate_password_not_rpx?)
|
132
121
|
|
133
122
|
before_validation :adding_rpx_identifier
|
134
123
|
end
|
135
124
|
|
125
|
+
# add relations and validation to RPXIdentifier based on the actual user model class name used
|
126
|
+
#
|
136
127
|
RPXIdentifier.class_eval do
|
137
128
|
belongs_to klass.name.downcase.to_sym
|
129
|
+
validates_presence_of "#{klass.name.downcase}_id".to_sym
|
138
130
|
end
|
139
131
|
end
|
140
132
|
|
141
|
-
#
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
def using_rpx__internal?
|
147
|
-
!rpx_identifiers.empty?
|
133
|
+
# support a block given to the save
|
134
|
+
def save(perform_validation = true, &block)
|
135
|
+
result = super perform_validation
|
136
|
+
yield(result) if block_given?
|
137
|
+
result
|
148
138
|
end
|
149
139
|
|
150
140
|
# test if account it using normal password authentication
|
@@ -152,30 +142,11 @@ module AuthlogicRpx
|
|
152
142
|
!send(crypted_password_field).blank?
|
153
143
|
end
|
154
144
|
|
155
|
-
# adds RPX identification to the instance.
|
156
|
-
# Abstracts how the RPX identifier is added to allow for multiplicity of underlying implementations
|
157
|
-
# aliased to add_rpx_identifier based on authlogic_rpx configuration mode
|
158
|
-
def add_rpx_identifier__nomap( rpx_id, rpx_provider_name )
|
159
|
-
self.rpx_identifier = rpx_id
|
160
|
-
#TODO: make rpx_provider_name a std param?
|
161
|
-
end
|
162
|
-
def add_rpx_identifier__internal( rpx_id, rpx_provider_name )
|
163
|
-
self.rpx_identifiers.build(:identifier => rpx_id, :provider_name => rpx_provider_name )
|
164
|
-
end
|
165
|
-
|
166
|
-
# Checks if given identifier is an identity for this account
|
167
|
-
# aliased to identified_by based on authlogic_rpx configuration mode
|
168
|
-
def identified_by__nomap?( id )
|
169
|
-
self.rpx_identifier == id
|
170
|
-
end
|
171
|
-
def identified_by__internal?( id )
|
172
|
-
self.rpx_identifiers.find_by_identifier( id )
|
173
|
-
end
|
174
145
|
|
175
146
|
private
|
176
147
|
|
177
|
-
# tests if password authentication should be checked
|
178
|
-
def
|
148
|
+
# tests if password authentication should be checked instead of rpx (i.e. if rpx is enabled but not used by this user)
|
149
|
+
def validate_password_not_rpx?
|
179
150
|
!using_rpx? && require_password?
|
180
151
|
end
|
181
152
|
|
@@ -221,23 +192,8 @@ module AuthlogicRpx
|
|
221
192
|
|
222
193
|
map_added_rpx_data( added_rpx_data )
|
223
194
|
end
|
224
|
-
|
225
|
-
return true
|
226
195
|
end
|
227
196
|
|
228
|
-
# merge_user_id is an internal method used to merge the actual RPX identifiers
|
229
|
-
# aliased to merge_user_id based on authlogic_rpx configuration mode
|
230
|
-
def merge_user_id__nomap( from_user )
|
231
|
-
self.rpx_identifier = from_user.rpx_identifier
|
232
|
-
from_user.rpx_identifier = nil
|
233
|
-
from_user.save
|
234
|
-
from_user.reload
|
235
|
-
end
|
236
|
-
def merge_user_id__internal( from_user )
|
237
|
-
self.rpx_identifiers << from_user.rpx_identifiers
|
238
|
-
from_user.reload
|
239
|
-
end
|
240
|
-
|
241
197
|
|
242
198
|
# map_added_rpx_data maps additional fields from the RPX response into the user object during the "add RPX to existing account" process.
|
243
199
|
# Override this in your user model to perform field mapping as may be desired
|
@@ -271,4 +227,78 @@ module AuthlogicRpx
|
|
271
227
|
|
272
228
|
end
|
273
229
|
end
|
230
|
+
|
231
|
+
# Mix-in collection of methods that are specific to no-mapping mode of operation
|
232
|
+
#
|
233
|
+
module MethodSet_NoMapping
|
234
|
+
# test if account it using RPX authentication
|
235
|
+
#
|
236
|
+
def using_rpx?
|
237
|
+
!rpx_identifier.blank?
|
238
|
+
end
|
239
|
+
|
240
|
+
# adds RPX identification to the instance.
|
241
|
+
# Abstracts how the RPX identifier is added to allow for multiplicity of underlying implementations
|
242
|
+
#
|
243
|
+
def add_rpx_identifier( rpx_id, rpx_provider_name )
|
244
|
+
self.rpx_identifier = rpx_id
|
245
|
+
#TODO: make rpx_provider_name a std param?
|
246
|
+
end
|
247
|
+
|
248
|
+
# Checks if given identifier is an identity for this account
|
249
|
+
#
|
250
|
+
def identified_by?( id )
|
251
|
+
self.rpx_identifier == id
|
252
|
+
end
|
253
|
+
|
254
|
+
# merge_user_id is an internal method used to merge the actual RPX identifiers
|
255
|
+
#
|
256
|
+
def merge_user_id( from_user )
|
257
|
+
self.rpx_identifier = from_user.rpx_identifier
|
258
|
+
from_user.rpx_identifier = nil
|
259
|
+
from_user.save
|
260
|
+
from_user.reload
|
261
|
+
end
|
262
|
+
|
263
|
+
# Uses default find_by_rpx_identifier class method
|
264
|
+
|
265
|
+
# Add an rpx_identifier collection method
|
266
|
+
def rpx_identifiers
|
267
|
+
[{ :identifier => rpx_identifier, :provider_name => "Unknown" }]
|
268
|
+
end
|
269
|
+
end
|
270
|
+
|
271
|
+
|
272
|
+
# Mix-in collection of methods that are specific to internal mapping mode of operation
|
273
|
+
#
|
274
|
+
module MethodSet_InternalMapping
|
275
|
+
# test if account it using RPX authentication
|
276
|
+
#
|
277
|
+
def using_rpx?
|
278
|
+
!rpx_identifiers.empty?
|
279
|
+
end
|
280
|
+
|
281
|
+
# adds RPX identification to the instance.
|
282
|
+
# Abstracts how the RPX identifier is added to allow for multiplicity of underlying implementations
|
283
|
+
#
|
284
|
+
def add_rpx_identifier( rpx_id, rpx_provider_name )
|
285
|
+
self.rpx_identifiers.build(:identifier => rpx_id, :provider_name => rpx_provider_name )
|
286
|
+
end
|
287
|
+
|
288
|
+
# Checks if given identifier is an identity for this account
|
289
|
+
#
|
290
|
+
def identified_by?( id )
|
291
|
+
self.rpx_identifiers.find_by_identifier( id )
|
292
|
+
end
|
293
|
+
|
294
|
+
# merge_user_id is an internal method used to merge the actual RPX identifiers
|
295
|
+
#
|
296
|
+
def merge_user_id( from_user )
|
297
|
+
self.rpx_identifiers << from_user.rpx_identifiers
|
298
|
+
from_user.reload
|
299
|
+
end
|
300
|
+
|
301
|
+
|
302
|
+
end
|
303
|
+
|
274
304
|
end
|
data/lib/authlogic_rpx/helper.rb
CHANGED
@@ -36,7 +36,7 @@ module AuthlogicRpx
|
|
36
36
|
private
|
37
37
|
|
38
38
|
def build_token_url!( options )
|
39
|
-
options.delete( :return_url ) + '?' + (
|
39
|
+
options.delete( :return_url ) + (options[:return_url].include?('?') ? '&' : '?') + (
|
40
40
|
{ :authenticity_token => form_authenticity_token, :add_rpx => options.delete( :add_rpx ) }.collect { |n| "#{n[0]}=#{ u(n[1]) }" if n[1] }
|
41
41
|
).compact.join('&')
|
42
42
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 1
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 1.1.
|
8
|
+
- 5
|
9
|
+
version: 1.1.5
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Paul Gallagher / tardate
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-05-22 00:00:00 -04:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|