authlogic_crowd 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +27 -26
- data/Gemfile +1 -1
- data/authlogic_crowd.gemspec +1 -1
- data/lib/authlogic_crowd/acts_as_authentic.rb +6 -2
- data/lib/authlogic_crowd/session.rb +32 -15
- data/lib/authlogic_crowd/version.rb +1 -1
- metadata +6 -8
data/.gitignore
CHANGED
@@ -1,26 +1,27 @@
|
|
1
|
-
## MAC OS
|
2
|
-
.DS_Store
|
3
|
-
|
4
|
-
## TEXTMATE
|
5
|
-
*.tmproj
|
6
|
-
tmtags
|
7
|
-
|
8
|
-
## EMACS
|
9
|
-
*~
|
10
|
-
\#*
|
11
|
-
.\#*
|
12
|
-
|
13
|
-
## VIM
|
14
|
-
*.swp
|
15
|
-
|
16
|
-
## PROJECT::GENERAL
|
17
|
-
coverage
|
18
|
-
rdoc
|
19
|
-
doc
|
20
|
-
pkg
|
21
|
-
.bundle
|
22
|
-
.idea
|
23
|
-
.yardoc
|
24
|
-
|
25
|
-
|
26
|
-
|
1
|
+
## MAC OS
|
2
|
+
.DS_Store
|
3
|
+
|
4
|
+
## TEXTMATE
|
5
|
+
*.tmproj
|
6
|
+
tmtags
|
7
|
+
|
8
|
+
## EMACS
|
9
|
+
*~
|
10
|
+
\#*
|
11
|
+
.\#*
|
12
|
+
|
13
|
+
## VIM
|
14
|
+
*.swp
|
15
|
+
|
16
|
+
## PROJECT::GENERAL
|
17
|
+
coverage
|
18
|
+
rdoc
|
19
|
+
doc
|
20
|
+
pkg
|
21
|
+
.bundle
|
22
|
+
.idea
|
23
|
+
.yardoc
|
24
|
+
.rvmrc
|
25
|
+
|
26
|
+
## PROJECT::SPECIFIC
|
27
|
+
Gemfile.lock
|
data/Gemfile
CHANGED
data/authlogic_crowd.gemspec
CHANGED
@@ -32,7 +32,7 @@ Gem::Specification.new do |s|
|
|
32
32
|
test/helper.rb
|
33
33
|
test/test_authlogic_crowd.rb
|
34
34
|
)
|
35
|
-
s.homepage = %q{http://github.com/
|
35
|
+
s.homepage = %q{http://github.com/thinkwell/authlogic_crowd}
|
36
36
|
s.require_paths = ["lib"]
|
37
37
|
s.rubygems_version = %q{1.3.7}
|
38
38
|
s.summary = %q{Atlassian Crowd support for Authlogic}
|
@@ -42,11 +42,15 @@ module AuthlogicCrowd
|
|
42
42
|
end
|
43
43
|
alias_method :crowd_user_token_field=, :crowd_user_token_field
|
44
44
|
|
45
|
+
def crowd_enabled(value=nil)
|
46
|
+
rw_config(:crowd_enabled, value, true)
|
47
|
+
end
|
48
|
+
|
45
49
|
end
|
46
50
|
module Methods
|
47
51
|
def self.included(klass)
|
48
52
|
klass.class_eval do
|
49
|
-
validate_on_create :must_have_unique_crowd_login
|
53
|
+
validate_on_create :must_have_unique_crowd_login, :if => :using_crowd?, :unless => :crowd_record
|
50
54
|
|
51
55
|
# TODO: Cleanup and refactor into callbacks
|
52
56
|
def create
|
@@ -123,7 +127,7 @@ module AuthlogicCrowd
|
|
123
127
|
end
|
124
128
|
|
125
129
|
def using_crowd?
|
126
|
-
!(self.class.crowd_app_name.nil? || self.class.crowd_app_password.nil? || self.class.crowd_service_url.nil?)
|
130
|
+
self.class.crowd_enabled && !(self.class.crowd_app_name.nil? || self.class.crowd_app_password.nil? || self.class.crowd_service_url.nil?)
|
127
131
|
end
|
128
132
|
|
129
133
|
def validate_password_with_crowd?
|
@@ -30,14 +30,15 @@ module AuthlogicCrowd
|
|
30
30
|
alias_method :auto_register=,:auto_register
|
31
31
|
|
32
32
|
def crowd_user_token= token
|
33
|
+
# Dup token before storing to make sure we store a pure string to avoid session serialization issues.
|
34
|
+
token = token.dup if token
|
33
35
|
session_user_token = controller && controller.session[:"crowd.token_key"]
|
34
36
|
cookie_user_token = crowd_sso? && controller && controller.cookies[:"crowd.token_key"]
|
35
|
-
cached_info = Rails.cache.read('crowd_cookie_info')
|
36
37
|
@crowd_client ||= SimpleCrowd::Client.new({
|
37
38
|
:service_url => klass.crowd_service_url,
|
38
39
|
:app_name => klass.crowd_app_name,
|
39
40
|
:app_password => klass.crowd_app_password})
|
40
|
-
crowd_cookie_info
|
41
|
+
crowd_cookie_info = self.crowd_cookie_info(@crowd_client)
|
41
42
|
controller.session[:"crowd.token_key"] = token unless session_user_token == token || !controller
|
42
43
|
controller.cookies[:"crowd.token_key"] = {:domain => crowd_cookie_info[:domain],
|
43
44
|
:secure => crowd_cookie_info[:secure],
|
@@ -46,6 +47,18 @@ module AuthlogicCrowd
|
|
46
47
|
def crowd_user_token
|
47
48
|
controller && (controller.params["crowd.token_key"] || controller.cookies[:"crowd.token_key"] || controller.session[:"crowd.token_key"])
|
48
49
|
end
|
50
|
+
|
51
|
+
def crowd_cookie_info(crowd_client)
|
52
|
+
Rails.cache.fetch('crowd_cookie_info') do
|
53
|
+
# Strings returned by crowd contain singleton methods which cannot
|
54
|
+
# be serialized into the Rails.cache. Do a shallow dup of each string
|
55
|
+
# in the returned hash
|
56
|
+
crowd_client.get_cookie_info.inject({}) do |cookie_info, (key, val)|
|
57
|
+
cookie_info[key] = val ? val.dup : val
|
58
|
+
cookie_info
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
49
62
|
end
|
50
63
|
module Methods
|
51
64
|
def self.included(klass)
|
@@ -143,7 +156,7 @@ module AuthlogicCrowd
|
|
143
156
|
if !login.blank? && self.unauthorized_record.nil?
|
144
157
|
self.unauthorized_record = klass.respond_to?(:login_or_email_equals) ?
|
145
158
|
klass.send(:login_or_email_equals, login).first :
|
146
|
-
klass.send(
|
159
|
+
klass.send(find_by_login_method, login)
|
147
160
|
# If passed in login equals the user email then get the REAL login used by crowd instead
|
148
161
|
login = unauthorized_record.login if !unauthorized_record.nil? && login = unauthorized_record.email
|
149
162
|
end
|
@@ -165,7 +178,7 @@ module AuthlogicCrowd
|
|
165
178
|
user_token = nil
|
166
179
|
end
|
167
180
|
|
168
|
-
raise "No user token" if user_token.blank?
|
181
|
+
raise SimpleCrowd::CrowdError.new "No user token" if user_token.blank?
|
169
182
|
|
170
183
|
login = crowd_client.find_username_by_token user_token unless login &&
|
171
184
|
(!cookie_user_token || session_user_token == cookie_user_token) &&
|
@@ -177,7 +190,7 @@ module AuthlogicCrowd
|
|
177
190
|
if !self.unauthorized_record.nil? && self.unauthorized_record.login == login
|
178
191
|
self.attempted_record = self.unauthorized_record
|
179
192
|
else
|
180
|
-
self.attempted_record = self.unauthorized_record = klass.send(
|
193
|
+
self.attempted_record = self.unauthorized_record = klass.send(find_by_login_method, login)
|
181
194
|
end
|
182
195
|
|
183
196
|
if !attempted_record
|
@@ -217,6 +230,7 @@ module AuthlogicCrowd
|
|
217
230
|
controller.cookies.delete :"#{klass.name.underscore}_credentials"
|
218
231
|
controller.cookies.delete :"crowd.token_key", :domain => crowd_cookie_info[:domain] if sso?
|
219
232
|
end
|
233
|
+
raise unless e.kind_of? SimpleCrowd::CrowdError
|
220
234
|
false
|
221
235
|
end
|
222
236
|
end
|
@@ -263,17 +277,20 @@ module AuthlogicCrowd
|
|
263
277
|
@crowd_client ||= SimpleCrowd::Client.new(crowd_config)
|
264
278
|
end
|
265
279
|
def load_crowd_app_token
|
266
|
-
|
267
|
-
|
268
|
-
|
280
|
+
crowd_app_token = Rails.cache.read('crowd_app_token')
|
281
|
+
if crowd_app_token.nil?
|
282
|
+
crowd_app_token = crowd_client.app_token
|
283
|
+
# Strings returned by crowd contain singleton methods which cannot
|
284
|
+
# be serialized into the Rails.cache. Duping the strings removes the
|
285
|
+
# singleton methods.
|
286
|
+
Rails.cache.write('crowd_app_token', crowd_app_token.dup)
|
287
|
+
else
|
288
|
+
crowd_client.app_token = crowd_app_token
|
289
|
+
end
|
290
|
+
crowd_app_token
|
269
291
|
end
|
270
292
|
def crowd_cookie_info
|
271
|
-
|
272
|
-
cached_info = Rails.cache.read('crowd_cookie_info')
|
273
|
-
@crowd_cookie_info ||= cached_info || crowd_client.get_cookie_info
|
274
|
-
Rails.cache.write('crowd_cookie_info', @crowd_cookie_info) unless cached_info == @crowd_cookie_info
|
275
|
-
end
|
276
|
-
@crowd_cookie_info
|
293
|
+
@crowd_cookie_info ||= self.class.crowd_cookie_info(crowd_client)
|
277
294
|
end
|
278
295
|
def crowd_config
|
279
296
|
{:service_url => klass.crowd_service_url,
|
@@ -282,4 +299,4 @@ module AuthlogicCrowd
|
|
282
299
|
end
|
283
300
|
end
|
284
301
|
end
|
285
|
-
end
|
302
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: authlogic_crowd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 31
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 4
|
10
|
+
version: 0.2.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Paul Strong
|
@@ -15,8 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
19
|
-
default_executable:
|
18
|
+
date: 2012-03-28 00:00:00 Z
|
20
19
|
dependencies:
|
21
20
|
- !ruby/object:Gem::Dependency
|
22
21
|
name: thoughtbot-shoulda
|
@@ -123,8 +122,7 @@ files:
|
|
123
122
|
- lib/authlogic_crowd/version.rb
|
124
123
|
- test/helper.rb
|
125
124
|
- test/test_authlogic_crowd.rb
|
126
|
-
|
127
|
-
homepage: http://github.com/lapluviosilla/authlogic_crowd
|
125
|
+
homepage: http://github.com/thinkwell/authlogic_crowd
|
128
126
|
licenses: []
|
129
127
|
|
130
128
|
post_install_message:
|
@@ -153,7 +151,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
153
151
|
requirements: []
|
154
152
|
|
155
153
|
rubyforge_project:
|
156
|
-
rubygems_version: 1.
|
154
|
+
rubygems_version: 1.8.17
|
157
155
|
signing_key:
|
158
156
|
specification_version: 3
|
159
157
|
summary: Atlassian Crowd support for Authlogic
|