open_id_authentication 1.0.0 → 1.1.0

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.
@@ -1,4 +1,4 @@
1
1
  module OpenIdAuthentication
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  end
4
-
4
+
@@ -37,6 +37,21 @@ module OpenIdAuthentication
37
37
 
38
38
  self.store = nil
39
39
 
40
+ if Rails.version >= '3'
41
+ class Railtie < ::Rails::Railtie
42
+ config.app_middleware.use OpenIdAuthentication
43
+
44
+ config.after_initialize do
45
+ OpenID::Util.logger = Rails.logger
46
+ end
47
+
48
+ ActiveSupport.on_load :action_controller do
49
+ ActionController::Base.send :include, ControllerMethods
50
+ #ActionController::Base.extend ControllerMethods
51
+ end
52
+ end
53
+ end
54
+
40
55
  class Result
41
56
  ERROR_MESSAGES = {
42
57
  :missing => "Sorry, the OpenID server couldn't be found",
@@ -73,57 +88,59 @@ module OpenIdAuthentication
73
88
  end
74
89
  end
75
90
 
76
- protected
77
- # The parameter name of "openid_identifier" is used rather than
78
- # the Rails convention "open_id_identifier" because that's what
79
- # the specification dictates in order to get browser auto-complete
80
- # working across sites
81
- def using_open_id?(identifier = nil) #:doc:
82
- identifier ||= open_id_identifier
83
- !identifier.blank? || request.env[Rack::OpenID::RESPONSE]
84
- end
91
+ module ControllerMethods
92
+ protected
93
+ # The parameter name of "openid_identifier" is used rather than
94
+ # the Rails convention "open_id_identifier" because that's what
95
+ # the specification dictates in order to get browser auto-complete
96
+ # working across sites
97
+ def using_open_id?(identifier = nil) #:doc:
98
+ identifier ||= open_id_identifier
99
+ !identifier.blank? || request.env[Rack::OpenID::RESPONSE]
100
+ end
85
101
 
86
- def authenticate_with_open_id(identifier = nil, options = {}, &block) #:doc:
87
- identifier ||= open_id_identifier
102
+ def authenticate_with_open_id(identifier = nil, options = {}, &block) #:doc:
103
+ identifier ||= open_id_identifier
88
104
 
89
- if request.env[Rack::OpenID::RESPONSE]
90
- complete_open_id_authentication(&block)
91
- else
92
- begin_open_id_authentication(identifier, options, &block)
105
+ if request.env[Rack::OpenID::RESPONSE]
106
+ complete_open_id_authentication(&block)
107
+ else
108
+ begin_open_id_authentication(identifier, options, &block)
109
+ end
93
110
  end
94
- end
95
111
 
96
- private
97
- def open_id_identifier
98
- params[:openid_identifier] || params[:openid_url]
99
- end
112
+ private
113
+ def open_id_identifier
114
+ params[:openid_identifier] || params[:openid_url]
115
+ end
100
116
 
101
- def begin_open_id_authentication(identifier, options = {})
102
- options[:identifier] = identifier
103
- value = Rack::OpenID.build_header(options)
104
- response.headers[Rack::OpenID::AUTHENTICATE_HEADER] = value
105
- head :unauthorized
106
- end
117
+ def begin_open_id_authentication(identifier, options = {})
118
+ options[:identifier] = identifier
119
+ value = Rack::OpenID.build_header(options)
120
+ response.headers[Rack::OpenID::AUTHENTICATE_HEADER] = value
121
+ head :unauthorized
122
+ end
107
123
 
108
- def complete_open_id_authentication
109
- response = request.env[Rack::OpenID::RESPONSE]
110
- identifier = response.display_identifier
111
-
112
- case response.status
113
- when OpenID::Consumer::SUCCESS
114
- yield Result[:successful], identifier,
115
- OpenID::SReg::Response.from_success_response(response),
116
- OpenID::AX::FetchResponse.from_success_response(response)
117
- when :missing
118
- yield Result[:missing], identifier, nil
119
- when :invalid
120
- yield Result[:invalid], identifier, nil
121
- when OpenID::Consumer::CANCEL
122
- yield Result[:canceled], identifier, nil
123
- when OpenID::Consumer::FAILURE
124
- yield Result[:failed], identifier, nil
125
- when OpenID::Consumer::SETUP_NEEDED
126
- yield Result[:setup_needed], response.setup_url, nil
124
+ def complete_open_id_authentication
125
+ response = request.env[Rack::OpenID::RESPONSE]
126
+ identifier = response.display_identifier
127
+
128
+ case response.status
129
+ when OpenID::Consumer::SUCCESS
130
+ yield Result[:successful], identifier,
131
+ OpenID::SReg::Response.from_success_response(response),
132
+ OpenID::AX::FetchResponse.from_success_response(response)
133
+ when :missing
134
+ yield Result[:missing], identifier, nil
135
+ when :invalid
136
+ yield Result[:invalid], identifier, nil
137
+ when OpenID::Consumer::CANCEL
138
+ yield Result[:canceled], identifier, nil
139
+ when OpenID::Consumer::FAILURE
140
+ yield Result[:failed], identifier, nil
141
+ when OpenID::Consumer::SETUP_NEEDED
142
+ yield Result[:setup_needed], response.setup_url, nil
143
+ end
127
144
  end
128
- end
145
+ end
129
146
  end
metadata CHANGED
@@ -1,8 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: open_id_authentication
3
3
  version: !ruby/object:Gem::Version
4
- prerelease:
5
- version: 1.0.0
4
+ hash: 19
5
+ prerelease: false
6
+ segments:
7
+ - 1
8
+ - 1
9
+ - 0
10
+ version: 1.1.0
6
11
  platform: ruby
7
12
  authors:
8
13
  - Patrick Robertson
@@ -10,7 +15,7 @@ autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
17
 
13
- date: 2011-08-01 00:00:00 -04:00
18
+ date: 2011-09-18 00:00:00 -04:00
14
19
  default_executable:
15
20
  dependencies:
16
21
  - !ruby/object:Gem::Dependency
@@ -21,6 +26,10 @@ dependencies:
21
26
  requirements:
22
27
  - - ~>
23
28
  - !ruby/object:Gem::Version
29
+ hash: 9
30
+ segments:
31
+ - 1
32
+ - 3
24
33
  version: "1.3"
25
34
  type: :runtime
26
35
  version_requirements: *id001
@@ -54,17 +63,23 @@ required_ruby_version: !ruby/object:Gem::Requirement
54
63
  requirements:
55
64
  - - ">="
56
65
  - !ruby/object:Gem::Version
66
+ hash: 3
67
+ segments:
68
+ - 0
57
69
  version: "0"
58
70
  required_rubygems_version: !ruby/object:Gem::Requirement
59
71
  none: false
60
72
  requirements:
61
73
  - - ">="
62
74
  - !ruby/object:Gem::Version
75
+ hash: 3
76
+ segments:
77
+ - 0
63
78
  version: "0"
64
79
  requirements: []
65
80
 
66
81
  rubyforge_project:
67
- rubygems_version: 1.6.2
82
+ rubygems_version: 1.3.7
68
83
  signing_key:
69
84
  specification_version: 3
70
85
  summary: open_id_authentication provides a thin wrapper around the excellent rack-openid gem.