devise_cas_authenticatable 1.4.0 → 1.4.1
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0fd1ffe6c25dc2058cd0af67774f494903499870
|
4
|
+
data.tar.gz: 860044267583de954f4c642d41cb938ad329b5c5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b99de7fc043aad27818675b314fb652815e1f926eb53782c7ca414b5ee6c289bc6fb796ff32c3be795a1335616bd591aa4abb0721cd09393c167b4fce5e5c0b7
|
7
|
+
data.tar.gz: aebd6374f1595782c13f466b0fdea694913362bf84c08586134b1ff17dd1c4997654fac4f006526542b70115d9b040420db8670d7f478a909565f4b4e368c16d
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# Changelog for devise\_cas\_authenticatable
|
2
2
|
|
3
|
+
## Version 1.4.1 - July 23, 2015
|
4
|
+
|
5
|
+
* Internal refactor to avoid conflicting with common route names, specifically logout_url (thanks to @eturino!)
|
6
|
+
|
3
7
|
## Version 1.4.0 - May 8, 2015
|
4
8
|
|
5
9
|
* Allow changing the CAS response field used as the unique key for finding users (thanks once again to @gmoore!)
|
@@ -27,7 +27,7 @@ class Devise::CasSessionsController < Devise::SessionsController
|
|
27
27
|
reset_session
|
28
28
|
end
|
29
29
|
|
30
|
-
redirect_to(
|
30
|
+
redirect_to(cas_logout_url)
|
31
31
|
end
|
32
32
|
|
33
33
|
def single_sign_out
|
@@ -83,7 +83,7 @@ class Devise::CasSessionsController < Devise::SessionsController
|
|
83
83
|
@request_url
|
84
84
|
end
|
85
85
|
|
86
|
-
def
|
86
|
+
def cas_destination_url
|
87
87
|
return unless ::Devise.cas_logout_url_param == 'destination'
|
88
88
|
if !::Devise.cas_destination_url.blank?
|
89
89
|
url = Devise.cas_destination_url
|
@@ -93,7 +93,7 @@ class Devise::CasSessionsController < Devise::SessionsController
|
|
93
93
|
end
|
94
94
|
end
|
95
95
|
|
96
|
-
def
|
96
|
+
def cas_follow_url
|
97
97
|
return unless ::Devise.cas_logout_url_param == 'follow'
|
98
98
|
if !::Devise.cas_follow_url.blank?
|
99
99
|
url = Devise.cas_follow_url
|
@@ -103,16 +103,16 @@ class Devise::CasSessionsController < Devise::SessionsController
|
|
103
103
|
end
|
104
104
|
end
|
105
105
|
|
106
|
-
def
|
106
|
+
def cas_service_url
|
107
107
|
::Devise.cas_service_url(request_url.dup, devise_mapping)
|
108
108
|
end
|
109
109
|
|
110
|
-
def
|
110
|
+
def cas_logout_url
|
111
111
|
begin
|
112
|
-
::Devise.cas_client.logout_url(
|
112
|
+
::Devise.cas_client.logout_url(cas_destination_url, cas_follow_url, cas_service_url)
|
113
113
|
rescue ArgumentError
|
114
114
|
# Older rubycas-clients don't accept a service_url
|
115
|
-
::Devise.cas_client.logout_url(
|
115
|
+
::Devise.cas_client.logout_url(cas_destination_url, cas_follow_url)
|
116
116
|
end
|
117
117
|
end
|
118
118
|
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{devise_cas_authenticatable}
|
5
|
-
s.version = "1.4.
|
5
|
+
s.version = "1.4.1"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Nat Budin", "Jeremy Haile"]
|
@@ -22,34 +22,21 @@ module Devise
|
|
22
22
|
identifier = nil
|
23
23
|
ticket_response = ticket.respond_to?(:user) ? ticket : ticket.response
|
24
24
|
|
25
|
-
|
26
|
-
identifier = ticket_response.user
|
27
|
-
else
|
28
|
-
identifier = ticket_response.extra_attributes[::Devise.cas_user_identifier]
|
29
|
-
end
|
25
|
+
identifier = extract_user_identifier(ticket_response)
|
30
26
|
|
31
|
-
# If cas_user_identifier isn't in extra_attributes,
|
32
|
-
|
33
|
-
|
34
|
-
logger.warn("Make sure config.cas_user_identifier is set to a field that appears in cas_extra_attributes")
|
35
|
-
return nil
|
36
|
-
end
|
27
|
+
# If cas_user_identifier isn't in extra_attributes,
|
28
|
+
# or the value is blank, then we're done here
|
29
|
+
return log_and_exit if identifier.nil?
|
37
30
|
|
38
31
|
logger.debug("Using conditions {#{::Devise.cas_username_column} => #{identifier}} to find the User")
|
39
|
-
|
40
|
-
|
41
|
-
resource =
|
42
|
-
find_for_authentication(conditions)
|
43
|
-
else
|
44
|
-
find(:first, :conditions => conditions)
|
45
|
-
end
|
46
|
-
|
47
|
-
resource = new(conditions) if (resource.nil? and should_create_cas_users?)
|
32
|
+
|
33
|
+
conditions = { ::Devise.cas_username_column => identifier }
|
34
|
+
resource = find_or_build_resource_from_conditions(conditions)
|
48
35
|
return nil unless resource
|
49
36
|
|
50
|
-
|
51
|
-
resource.cas_extra_attributes
|
52
|
-
|
37
|
+
resource.cas_extra_attributes = ticket_response.extra_attributes \
|
38
|
+
if resource.respond_to?(:cas_extra_attributes=)
|
39
|
+
|
53
40
|
resource.save
|
54
41
|
resource
|
55
42
|
end
|
@@ -59,6 +46,29 @@ module Devise
|
|
59
46
|
def should_create_cas_users?
|
60
47
|
respond_to?(:cas_create_user?) ? cas_create_user? : ::Devise.cas_create_user?
|
61
48
|
end
|
49
|
+
|
50
|
+
def extract_user_identifier(response)
|
51
|
+
return response.user if ::Devise.cas_user_identifier.blank?
|
52
|
+
response.extra_attributes[::Devise.cas_user_identifier]
|
53
|
+
end
|
54
|
+
|
55
|
+
def log_and_exit
|
56
|
+
logger.warn("Could not find a value for [#{::Devise.cas_user_identifier}] in cas_extra_attributes so we cannot find the User.")
|
57
|
+
logger.warn("Make sure config.cas_user_identifier is set to a field that appears in cas_extra_attributes")
|
58
|
+
return nil
|
59
|
+
end
|
60
|
+
|
61
|
+
def find_or_build_resource_from_conditions(conditions)
|
62
|
+
resource = find_resource_with_conditions(conditions)
|
63
|
+
resource = new(conditions) if (resource.nil? and should_create_cas_users?)
|
64
|
+
return resource
|
65
|
+
end
|
66
|
+
|
67
|
+
def find_resource_with_conditions(conditions)
|
68
|
+
# We don't want to override Devise 1.1's find_for_authentication
|
69
|
+
return find_for_authentication(conditions) if respond_to?(:find_for_authentication)
|
70
|
+
find(:first, :conditions => conditions)
|
71
|
+
end
|
62
72
|
end
|
63
73
|
end
|
64
74
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: devise_cas_authenticatable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nat Budin
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-07-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: devise
|