authlogic_rpx 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +5 -0
- data/README.rdoc +63 -27
- data/authlogic_rpx.gemspec +2 -2
- data/lib/authlogic_rpx/session.rb +17 -5
- data/lib/authlogic_rpx/version.rb +1 -1
- metadata +2 -2
data/CHANGELOG.rdoc
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
== 1.0.3 released 2009-10-07
|
2
|
+
|
3
|
+
* added general error handler for session validation to give clean 'failure' when underlying errors encountered (e.g. user model database constraint violation)
|
4
|
+
* updated documentation
|
5
|
+
|
1
6
|
== 1.0.2 released 2009-09-27
|
2
7
|
|
3
8
|
* Fixed issue with rpx_popup that was causing an error on some webkit-based browsers (incl chrome)
|
data/README.rdoc
CHANGED
@@ -17,6 +17,7 @@ Key features and capabilities:
|
|
17
17
|
* <b>Authlogic_RPX issues and feedback:</b> [http://github.com/tardate/authlogic_rpx/issues]
|
18
18
|
|
19
19
|
The demonstration Rails application is where you can see Authlogic_RPX in action:
|
20
|
+
|
20
21
|
* <b>Live Demonstration Site:</b> [http://rails-authlogic-rpx-sample.heroku.com]
|
21
22
|
* <b>Demonstration site source repository:</b> [http://github.com/tardate/rails-authlogic-rpx-sample]
|
22
23
|
|
@@ -30,19 +31,19 @@ The demonstration Rails application is where you can see Authlogic_RPX in action
|
|
30
31
|
|
31
32
|
== Installing Authlogic RPX gem
|
32
33
|
|
33
|
-
Three gems are required: authlogic, grosser-rpx_now, and
|
34
|
+
Three gems are required: authlogic, grosser-rpx_now, and authlogic_rpx. Install these as appropriate to your environment and preferences.
|
34
35
|
|
35
36
|
Currently tested versions:
|
36
|
-
* authlogic 2.1.1
|
37
|
+
* authlogic 2.1.2,2.1.1
|
37
38
|
* grosser-rpx_now 0.5.10
|
38
|
-
*
|
39
|
+
* authlogic_rpx 1.0.3
|
39
40
|
|
40
41
|
|
41
42
|
=== 1. Direct gem installation
|
42
43
|
|
43
44
|
sudo gem install authlogic
|
44
45
|
sudo gem install grosser-rpx_now --source http://gems.github.com
|
45
|
-
sudo gem install
|
46
|
+
sudo gem install authlogic_rpx --source http://gemcutter.org
|
46
47
|
|
47
48
|
|
48
49
|
=== 2. Using Rails config.gems
|
@@ -51,7 +52,7 @@ Include in config/environment.rb:
|
|
51
52
|
|
52
53
|
config.gem "authlogic"
|
53
54
|
config.gem "grosser-rpx_now", :lib => "rpx_now", :source => 'http://gems.github.com'
|
54
|
-
config.gem "
|
55
|
+
config.gem "authlogic_rpx", :source => 'http://gemcutter.org'
|
55
56
|
|
56
57
|
Then to install, run from the command line:
|
57
58
|
|
@@ -64,7 +65,7 @@ Include in RAILS_ROOT/.gems:
|
|
64
65
|
|
65
66
|
authlogic
|
66
67
|
grosser-rpx_now --source gems.github.com
|
67
|
-
|
68
|
+
authlogic_rpx --source gemcutter.org
|
68
69
|
|
69
70
|
|
70
71
|
== Using Authlogic RPX
|
@@ -114,10 +115,10 @@ You may need to remove database constraints on other fields if they will be unus
|
|
114
115
|
The user model then needs to be tagged with "acts_as_authentic", and you must add rpx_identifier to the attr_accessible configuration (if you are using it)
|
115
116
|
|
116
117
|
class User < ActiveRecord::Base
|
117
|
-
|
118
|
+
acts_as_authentic do |c|
|
118
119
|
c.my_config_option = my_value # for available options see documentation in: Authlogic::ActsAsAuthentic
|
119
120
|
end # block optional
|
120
|
-
|
121
|
+
attr_accessible :username, :email, :password, :password_confirmation, :rpx_identifier
|
121
122
|
end
|
122
123
|
|
123
124
|
{See the source for the sample user.rb}[http://github.com/tardate/rails-authlogic-rpx-sample/blob/master/app/models/user.rb].
|
@@ -155,9 +156,19 @@ For example, to disable auto-registration and enable extended info:
|
|
155
156
|
|
156
157
|
{See the source for the sample user_session.rb}[http://github.com/tardate/rails-authlogic-rpx-sample/blob/master/app/models/user_session.rb].
|
157
158
|
|
158
|
-
=== 3. Add custom user profile mapping (optional)
|
159
|
+
=== 3. Add custom user profile mapping during auto-registration (optional)
|
160
|
+
|
159
161
|
When users auto-register, profile data from RPX is available to be inserted in the user's record on your site. By default, authlogic_rpx will map the username and email fields.
|
160
162
|
|
163
|
+
WARNING: if you are using auto-registration, any fields you map should NOT have unique constraints enforced at the database level.
|
164
|
+
Authlogic_rpx will optimistically attempt to save the user record during registration, and violating a unique constraint will cause the authentication/registration to fail.
|
165
|
+
|
166
|
+
You can/should enforce any required validations at the model level e.g.
|
167
|
+
|
168
|
+
validates_uniqueness_of :username, :case_sensitive => false
|
169
|
+
|
170
|
+
This will allow the auto-registration to proceed, and the user can be given a chance to rectify the validation errors on your user profile page.
|
171
|
+
|
161
172
|
If you have other fields you want to map, you can provide your own implementation of the map_rpx_data method in the UserSession model. In that method, you will be updating the "self.attempted_record" object, with information from the "@rpx_data" object. See the {RPX documentation}[https://rpxnow.com/docs#profile_data] to find out about the set of information that is available.
|
162
173
|
|
163
174
|
class UserSession < Authlogic::Session::Base
|
@@ -166,22 +177,22 @@ If you have other fields you want to map, you can provide your own implementatio
|
|
166
177
|
|
167
178
|
private
|
168
179
|
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
180
|
+
# map_rpx_data maps additional fields from the RPX response into the user object
|
181
|
+
# override this in your session controller to change the field mapping
|
182
|
+
# see https://rpxnow.com/docs#profile_data for the definition of available attributes
|
183
|
+
#
|
184
|
+
def map_rpx_data
|
185
|
+
# map core profile data using authlogic indirect column names
|
186
|
+
self.attempted_record.send("#{klass.login_field}=", @rpx_data['profile']['preferredUsername'] ) if attempted_record.send(klass.login_field).blank?
|
187
|
+
self.attempted_record.send("#{klass.email_field}=", @rpx_data['profile']['email'] ) if attempted_record.send(klass.email_field).blank?
|
188
|
+
|
189
|
+
# map some other columns explicitly
|
190
|
+
self.attempted_record.fullname = @rpx_data['profile']['displayName'] if attempted_record.fullname.blank?
|
191
|
+
|
192
|
+
if rpx_extended_info?
|
193
|
+
# map some extended attributes
|
194
|
+
end
|
195
|
+
end
|
185
196
|
|
186
197
|
end
|
187
198
|
|
@@ -353,7 +364,7 @@ So how to put a "login" link on your page? Two helper methods are provided:
|
|
353
364
|
|
354
365
|
Each takes an options hash:
|
355
366
|
* <tt>link_text:</tt> text to use in the link (only used by rpx_popup)
|
356
|
-
* <tt>app_name:</tt> name of the application (will be prepended to RPX domain and used in RPX dialogues)
|
367
|
+
* <tt>app_name:</tt> name of the application you set when registering your service at rpxnow.com (will be prepended to RPX domain and used in RPX dialogues)
|
357
368
|
* <tt>return_url:</tt> url for the RPX callback (e.g. user_sessions_url)
|
358
369
|
* <tt>add_rpx:</tt> Optional. If true, requests RPX callback to add to current session. Else runs normal authentication process (default). See "7. Allow users to "Add RPX" to existing accounts"
|
359
370
|
|
@@ -412,9 +423,18 @@ If you have issues or feedback, please log them in the {issues list on github}[h
|
|
412
423
|
Some of the improvements currently on the radar:
|
413
424
|
* Still figuring out how to write some good automated tests
|
414
425
|
* Implement/verify support for RPX "paid" service features of their "Plus" and "Pro" accounts (to date, only tested with free RPX "Basic" account)
|
415
|
-
* Add support for proxy/direct authentication (i.e. so you can programmatically "authenticate" as an existing user based on the RPX id)
|
416
426
|
|
417
427
|
|
428
|
+
== Note on programmatically grabbing an authenticated session
|
429
|
+
|
430
|
+
If you need to programmatically perform proxy authentication as a specific user (e.g. to run a batch process on behalf of the user), authlogic provides the necessary capability and this can be used with RPX-authenticated users too:
|
431
|
+
|
432
|
+
app.get "/" # force Authlogic::Session::Base.controller activation
|
433
|
+
user = User.find(:first)
|
434
|
+
session = UserSession.create(user, true) # skip authentication and log the user in directly, the true means "remember me"
|
435
|
+
session.valid?
|
436
|
+
=> true
|
437
|
+
|
418
438
|
|
419
439
|
== Internals
|
420
440
|
|
@@ -423,7 +443,23 @@ Some design principles:
|
|
423
443
|
* All direct RPX processing is handled in the AuthlogicRpx::Session class (not in the ActiveRecord model)
|
424
444
|
* It uses the plug-in architecture introduced in Authlogic v2.0.
|
425
445
|
|
446
|
+
==== building the gem
|
426
447
|
|
448
|
+
* increment the version in lib/authlogic_rpx/version.rb
|
449
|
+
* update gem version refs in README.rdoc
|
450
|
+
* update CHANGELOG.rdoc
|
451
|
+
|
452
|
+
# update manifest file
|
453
|
+
$ rake manifest
|
454
|
+
|
455
|
+
# update gemspec
|
456
|
+
$ rake build_gemspec
|
457
|
+
|
458
|
+
# build the gem
|
459
|
+
gem build authlogic_rpx.gemspec
|
460
|
+
|
461
|
+
# push the gem to gemcutter (e.g. for version 1.0.3)
|
462
|
+
gem push authlogic_rpx-1.0.3.gem
|
427
463
|
|
428
464
|
== Kudos and Kopywrite
|
429
465
|
|
data/authlogic_rpx.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{authlogic_rpx}
|
5
|
-
s.version = "1.0.
|
5
|
+
s.version = "1.0.3"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Paul Gallagher / tardate"]
|
9
|
-
s.date = %q{2009-10-
|
9
|
+
s.date = %q{2009-10-07}
|
10
10
|
s.description = %q{Authlogic extension/plugin that provides RPX (rpxnow.com) authentication support}
|
11
11
|
s.email = %q{gallagher.paul@gmail.com}
|
12
12
|
s.extra_rdoc_files = ["CHANGELOG.rdoc", "README.rdoc", "lib/authlogic_rpx.rb", "lib/authlogic_rpx/acts_as_authentic.rb", "lib/authlogic_rpx/helper.rb", "lib/authlogic_rpx/session.rb", "lib/authlogic_rpx/version.rb"]
|
@@ -67,7 +67,7 @@ module AuthlogicRpx
|
|
67
67
|
validate :validate_by_rpx, :if => :authenticating_with_rpx?
|
68
68
|
end
|
69
69
|
end
|
70
|
-
|
70
|
+
|
71
71
|
# Determines if the authenticated user is also a new registration.
|
72
72
|
# For use in the session controller to help direct the most appropriate action to follow.
|
73
73
|
#
|
@@ -159,12 +159,24 @@ module AuthlogicRpx
|
|
159
159
|
return false
|
160
160
|
end
|
161
161
|
end
|
162
|
-
|
162
|
+
|
163
|
+
rescue
|
164
|
+
errors.add_to_base("There was an error in authentication. Please try again or contact the system administrators for assistance")
|
165
|
+
return false
|
163
166
|
end
|
164
167
|
|
165
|
-
# map_rpx_data maps additional fields from the RPX response into the user object
|
166
|
-
#
|
167
|
-
#
|
168
|
+
# map_rpx_data maps additional fields from the RPX response into the user object during auto-registration.
|
169
|
+
# Override this in your session controller to change the field mapping
|
170
|
+
# See https://rpxnow.com/docs#profile_data for the definition of available attributes
|
171
|
+
#
|
172
|
+
# WARNING: if you are using auto-registration, any fields you map should NOT have unique constraints enforced at the database level.
|
173
|
+
# authlogic_rpx will optimistically attempt to save the user record during registration, and
|
174
|
+
# violating a unique constraint will cause the authentication/registration to fail.
|
175
|
+
#
|
176
|
+
# You can/should enforce any required validations at the model level e.g.
|
177
|
+
# validates_uniqueness_of :username, :case_sensitive => false
|
178
|
+
# This will allow the auto-registration to proceed, and the user can be given a chance to rectify the validation errors
|
179
|
+
# on your user profile page.
|
168
180
|
#
|
169
181
|
def map_rpx_data
|
170
182
|
self.attempted_record.send("#{klass.login_field}=", @rpx_data['profile']['preferredUsername'] ) if attempted_record.send(klass.login_field).blank?
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: authlogic_rpx
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paul Gallagher / tardate
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-10-
|
12
|
+
date: 2009-10-07 00:00:00 +08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|