rack-cas 0.12.1 → 0.13.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3a65d4abd71dea1c784a406e3ca8a042f5503eb6
4
- data.tar.gz: 4d5cdbcdbfbf1a16cb07acc947d15b99ac2a389e
3
+ metadata.gz: cc8336d0e3209b2a97a12f4edf8c75ab4eba5394
4
+ data.tar.gz: 75d90457796e73f01d1a68e94c17fc833823306c
5
5
  SHA512:
6
- metadata.gz: 6882a52abd94f341672e8ac0e5aa2a1aaa1be4e5769f16fba6a2b8ed70a7070b61876351fbcdb6d9c15e74ce63c0118f69ad5e2ef528e68f449bb0235d834d2a
7
- data.tar.gz: a9f768448351fdf7d5aee6357d6b94bec8c171dba878ea4201fe09ae73bc9b1a1b3eadf3a0c88366b7cc4542e8317757d4420b3ceed2b7dabb443d065d581693
6
+ metadata.gz: 9e3411f27cb4033cdc3a9f908680fa456d9b0b36ea61e49abe55411d1e299fb44fa97eef5451aabf5b71bc18e1ea896dd830e4109466f322111e2fe24686ee05
7
+ data.tar.gz: e4fa2a3b97670d12d5ab8967c8e7413eeff4405d15e062e0b58d908983dcbd71ec0958c0c764b51ea7461111657f33ab974cb62d1333faf9789582ca05ad55c0
@@ -13,7 +13,7 @@ module RackCAS
13
13
 
14
14
  def user
15
15
  if success?
16
- xml.xpath('/cas:serviceResponse/cas:authenticationSuccess/cas:user').text
16
+ xml.at('//serviceResponse/authenticationSuccess/user').text
17
17
  else
18
18
  case failure_code
19
19
  when 'INVALID_REQUEST'
@@ -34,21 +34,12 @@ module RackCAS
34
34
  raise AuthenticationFailure, failure_message unless success?
35
35
 
36
36
  # Jasig style
37
- if attr_node = xml.at('/cas:serviceResponse/cas:authenticationSuccess/cas:attributes')
38
- attr_node.children.each do |node|
39
- if node.is_a? Nokogiri::XML::Element
40
- if attrs.has_key?(node.name)
41
- attrs[node.name] = [attrs[node.name]] if attrs[node.name].is_a? String
42
- attrs[node.name] << node.text
43
- else
44
- attrs[node.name] = node.text
45
- end
46
- end
47
- end
37
+ if attr_node = xml.at('//serviceResponse/authenticationSuccess/attributes')
38
+ attrs = parse_user_info(attr_node)
48
39
 
49
40
  # RubyCas-Server style
50
41
  else
51
- xml.at('/cas:serviceResponse/cas:authenticationSuccess').children.each do |node|
42
+ xml.at('//serviceResponse/authenticationSuccess').children.each do |node|
52
43
  if node.is_a? Nokogiri::XML::Element
53
44
  if !node.namespace || !node.namespace.prefix == 'cas'
54
45
  # TODO: support JSON encoding
@@ -64,11 +55,11 @@ module RackCAS
64
55
  protected
65
56
 
66
57
  def success?
67
- @success ||= !!xml.at('/cas:serviceResponse/cas:authenticationSuccess')
58
+ @success ||= !!xml.at('//serviceResponse/authenticationSuccess')
68
59
  end
69
60
 
70
61
  def authentication_failure
71
- @authentication_failure ||= xml.at('/cas:serviceResponse/cas:authenticationFailure')
62
+ @authentication_failure ||= xml.at('//serviceResponse/authenticationFailure')
72
63
  end
73
64
 
74
65
  def failure_message
@@ -103,7 +94,36 @@ module RackCAS
103
94
  def xml
104
95
  return @xml unless @xml.nil?
105
96
 
106
- @xml = Nokogiri::XML(response.body)
97
+ @xml = Nokogiri::XML(response.body).remove_namespaces!
98
+ end
99
+
100
+ # initially borrowed from omniauth-cas
101
+ def parse_user_info(node)
102
+ return nil if node.nil?
103
+ {}.tap do |hash|
104
+ node.children.each do |e|
105
+ unless e.kind_of?(Nokogiri::XML::Text) || e.name == 'proxies'
106
+ # There are no child elements
107
+ if e.element_children.count == 0
108
+ if hash.has_key?(e.name)
109
+ hash[e.name] = [hash[e.name]] if hash[e.name].is_a? String
110
+ hash[e.name] << e.content
111
+ else
112
+ hash[e.name] = e.content
113
+ end
114
+ elsif e.element_children.count
115
+ # JASIG style extra attributes
116
+ if e.name == 'attributes'
117
+ hash.merge!(parse_user_info(e))
118
+ else
119
+ hash[e.name] = [] if hash[e.name].nil?
120
+ hash[e.name] = [hash[e.name]] if hash[e.name].is_a? String
121
+ hash[e.name].push(parse_user_info(e))
122
+ end
123
+ end
124
+ end
125
+ end
126
+ end
107
127
  end
108
128
  end
109
129
  end
@@ -1,3 +1,3 @@
1
1
  module RackCAS
2
- VERSION = '0.12.1'
2
+ VERSION = '0.13.0'
3
3
  end
@@ -38,7 +38,7 @@ class Rack::CAS
38
38
  if cas_request.logout?
39
39
  log env, 'rack-cas: Intercepting logout request.'
40
40
 
41
- request.session.send respond_to?(:destroy) ? :destroy : :clear
41
+ request.session.send (request.session.respond_to?(:destroy) ? :destroy : :clear)
42
42
  return redirect_to server.logout_url(request.params).to_s
43
43
  end
44
44
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-cas
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.1
4
+ version: 0.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Crownoble
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-20 00:00:00.000000000 Z
11
+ date: 2016-04-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -155,9 +155,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
155
155
  version: '0'
156
156
  requirements: []
157
157
  rubyforge_project:
158
- rubygems_version: 2.2.2
158
+ rubygems_version: 2.5.1
159
159
  signing_key:
160
160
  specification_version: 4
161
161
  summary: Rack-based CAS client
162
162
  test_files: []
163
- has_rdoc: