Changeset 455
Upgraded OpenID-Auth Plugin to the latest Rails-OpenID-GEM version (>=2.0.0)
Feb 10 2008 * 19:07 (9 months ago)
Committed by ddenissenko
Affected files:
extensions/1-1/openid_auth/ext/account_controller.rb
(Download diff)
| r298 | r455 |
|---|
1 | #-- | 1 | #-- |
2 | # Copyright (C) 2007 Dimitrij Denissenko | 2 | # Copyright (C) 2008 Dimitrij Denissenko |
3 | # Please read LICENSE document for more information. | 3 | # Please read LICENSE document for more information. |
4 | #++ | 4 | #++ |
5 | class AccountController < ApplicationController | 5 | class AccountController < ApplicationController |
|---|
... | | ... | |
|---|
9 | before_filter :verify_identity_url, :only => [:openid_registration] | 9 | before_filter :verify_identity_url, :only => [:openid_registration] |
10 | | 10 | |
11 | def openid_registration | 11 | def openid_registration |
12 | openid_request = openid_consumer.begin(params[:identity_url]) | 12 | begin |
13 | case openid_request.status | 13 | openid_request = openid_consumer.begin(params[:identity_url]) |
14 | when OpenID::SUCCESS | | |
15 | openid_request.add_extension_arg 'sreg', 'required', 'nickname,email,fullname' | 14 | openid_request.add_extension_arg 'sreg', 'required', 'nickname,email,fullname' |
16 | url = openid_request.redirect_url(url_for(home_url), url_for(:action => 'complete_openid_registration')) | 15 | url = openid_request.redirect_url(url_for(home_url), url_for(:action => 'complete_openid_registration')) |
17 | redirect_to(url) | 16 | redirect_to(url) |
18 | when OpenID::FAILURE | 17 | rescue OpenID::DiscoveryFailure |
19 | failed_registration _('Sorry, the OpenID server could not be found.') | 18 | failed_registration _('Sorry, the OpenID server could not be found.') |
20 | end | 19 | end |
21 | end | 20 | end |
22 | | 21 | |
23 | def complete_openid_registration | 22 | def complete_openid_registration |
24 | openid_response = openid_consumer.complete(params) | 23 | return_to = url_for(:action => 'complete_openid_registration', :only_path => false) |
| | 24 | parameters = params.reject{ |k,v| request.path_parameters[k] } |
| | 25 | openid_response = openid_consumer.complete(parameters, return_to) |
25 | case openid_response.status | 26 | case openid_response.status |
26 | when OpenID::SUCCESS | 27 | when OpenID::Consumer::SUCCESS |
27 | User.destroy_all_expired | 28 | User.destroy_all_expired |
28 | @user = User.new | 29 | @user = User.new |
29 | @user.identity_url = openid_response.identity_url | 30 | @user.identity_url = openid_response.identity_url |
|---|
... | | ... | |
|---|
36 | else | 37 | else |
37 | failed_registration _('Your OpenID profile registration failed: %s', @user.errors.full_messages.to_sentence) | 38 | failed_registration _('Your OpenID profile registration failed: %s', @user.errors.full_messages.to_sentence) |
38 | end | 39 | end |
39 | when OpenID::CANCEL | 40 | when OpenID::Consumer::CANCEL |
40 | failed_registration _("OpenID verification was canceled.") | 41 | failed_registration _("OpenID verification was canceled.") |
41 | else | 42 | else |
42 | failed_registration _("Sorry, the OpenID verification failed.") | 43 | failed_registration _("Sorry, the OpenID verification failed.") |
|---|
extensions/1-1/openid_auth/ext/login_controller.rb
(Download diff)
| r356 | r455 |
|---|
1 | #-- | 1 | #-- |
2 | # Copyright (C) 2007 Dimitrij Denissenko | 2 | # Copyright (C) 2008 Dimitrij Denissenko |
3 | # Please read LICENSE document for more information. | 3 | # Please read LICENSE document for more information. |
4 | #++ | 4 | #++ |
5 | class LoginController < ApplicationController | 5 | class LoginController < ApplicationController |
|---|
... | | ... | |
|---|
8 | before_filter :verify_identity_url, :only => [:openid_login] | 8 | before_filter :verify_identity_url, :only => [:openid_login] |
9 | | 9 | |
10 | def openid_login | 10 | def openid_login |
11 | openid_request = openid_consumer.begin(@identity_url) | 11 | begin |
12 | case openid_request.status | 12 | openid_request = openid_consumer.begin(@identity_url) |
13 | when OpenID::SUCCESS | | |
14 | redirect_url = openid_request.redirect_url(url_for(home_url), url_for(:action => 'complete_openid_login')) | 13 | redirect_url = openid_request.redirect_url(url_for(home_url), url_for(:action => 'complete_openid_login')) |
15 | redirect_to(redirect_url) | 14 | redirect_to(redirect_url) |
16 | when OpenID::FAILURE | 15 | rescue OpenID::DiscoveryFailure |
17 | failed_login _('Sorry, the OpenID server could not be found.') | 16 | failed_login _('Sorry, the OpenID server could not be found.') |
18 | end | 17 | end |
19 | end | 18 | end |
20 | | 19 | |
21 | def complete_openid_login | 20 | def complete_openid_login |
22 | openid_response = openid_consumer.complete(params) | 21 | return_to = url_for(:action => 'complete_openid_login', :only_path => false) |
| | 22 | parameters = params.reject{ |k,v| request.path_parameters[k] } |
| | 23 | openid_response = openid_consumer.complete(parameters, return_to) |
23 | case openid_response.status | 24 | case openid_response.status |
24 | when OpenID::SUCCESS | 25 | when OpenID::Consumer::SUCCESS |
25 | identity_url = IdentityURL.normalize(openid_response.identity_url) | 26 | identity_url = IdentityURL.normalize(openid_response.identity_url) |
26 | if user = User.openid_authenticate(identity_url) | 27 | if user = User.openid_authenticate(identity_url) |
27 | successful_login(user) | 28 | successful_login(user) |
28 | else | 29 | else |
29 | failed_login _('Sorry, no user by that identity URL exists.') | 30 | failed_login _('Sorry, no user by that identity URL exists.') |
30 | end | 31 | end |
31 | when OpenID::CANCEL | 32 | when OpenID::Consumer::CANCEL |
32 | failed_login _('OpenID verification was canceled.') | 33 | failed_login _('OpenID verification was canceled.') |
33 | else | 34 | else |
34 | failed_login _('Sorry, the OpenID verification failed.') | 35 | failed_login _('Sorry, the OpenID verification failed.') + openid_response.message.inspect + openid_response.status.inspect |
35 | end | 36 | end |
36 | return false | 37 | return false |
37 | end | 38 | end |
|---|
extensions/1-1/openid_auth/ext_info.rb
(Download diff)
| r354 | r455 |
|---|
1 | #-- | 1 | #-- |
2 | # Copyright (C) 2007 Dimitrij Denissenko | 2 | # Copyright (C) 2008 Dimitrij Denissenko |
3 | # Please read LICENSE document for more information. | 3 | # Please read LICENSE document for more information. |
4 | #++ | 4 | #++ |
| | 5 | gem 'ruby-openid', '>= 2.0.0' |
5 | require 'openid' | 6 | require 'openid' |
| | 7 | require 'openid/store/filesystem' |
6 | | 8 | |
7 | module Retrospectiva | 9 | module Retrospectiva |
8 | module Extension | 10 | module Extension |
|---|
extensions/1-1/openid_auth/lib/openid_auth/consumer.rb
(Download diff)
| r293 | r455 |
|---|
1 | #-- | 1 | #-- |
2 | # Copyright (C) 2007 Dimitrij Denissenko | 2 | # Copyright (C) 2008 Dimitrij Denissenko |
3 | # Please read LICENSE document for more information. | 3 | # Please read LICENSE document for more information. |
4 | #++ | 4 | #++ |
5 | module Retrospectiva::Extension::OpenidAuth::Consumer | 5 | module Retrospectiva::Extension::OpenidAuth::Consumer |
6 | | 6 | |
7 | def openid_consumer | 7 | def openid_consumer |
8 | unless @openid_consumer | 8 | unless @openid_consumer |
9 | store = OpenID::FilesystemStore.new(File.join(RAILS_ROOT, 'tmp', 'openid')) | 9 | store = OpenID::Store::Filesystem.new(File.join(RAILS_ROOT, 'tmp', 'openid')) |
10 | @openid_consumer = OpenID::Consumer.new(session, store) | 10 | @openid_consumer = OpenID::Consumer.new(session, store) |
11 | end | 11 | end |
12 | @openid_consumer | 12 | @openid_consumer |
|---|