libsaml 2.1.6 → 2.1.7

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: 777d61727d4b2593863f72a4621312e617a18178
4
- data.tar.gz: ca56f6007f85800d1d6808cbbd5cd95024c88635
3
+ metadata.gz: 5f0ad6ec3944e2e6c2656605f22859cf6de287a6
4
+ data.tar.gz: 93f72e0c10f8eeae202a550f25b607ca7c6518b9
5
5
  SHA512:
6
- metadata.gz: 89f6aa619c04a9d42e842d43cf56ded84bbe3a53bd6a258b4b93d28a868dfcbbf848d8c37913b2d6b8d999c8e4f08d3826d299b83d5bc6ade8882c3b01007ab9
7
- data.tar.gz: 56be7dd01abb97f50a773347c5ba841e6a401c2077e4d7a265bd7d0bf3955e49361819cf483db76bc6b7122b0266ac36985e8e60b3ca602908c4715d3dd9719e
6
+ metadata.gz: 199243697919b1cbc4676c75bd54822feec568b567551640729e1774e229a06748338be453d5fdae013722ca0f7d771f49fb15e08150707fc9ff38c8348ee741
7
+ data.tar.gz: e32fef49de53c91fa57d3d5fccb670ae1457d7d5a03caddc61fd2e3bc016e637b8e2bdd58702ee67687780edc0f4d6f0a4824e924f09781adf2c1df23233de7b
@@ -4,6 +4,7 @@ require 'saml/base'
4
4
  require 'saml/xml_helpers'
5
5
  require 'saml/encoding'
6
6
  require 'saml/util'
7
+ require 'saml/notification'
7
8
  require 'xmlenc'
8
9
  require 'xmldsig'
9
10
  require "net/https"
@@ -1,11 +1,12 @@
1
1
  module Saml
2
2
  module Bindings
3
3
  class HTTPArtifact
4
+ include Saml::Notification
4
5
 
5
6
  class << self
6
7
  # @param [Saml::ArtifactResponse] artifact_response
7
8
  def create_response_xml(artifact_response)
8
- Saml::Util.sign_xml(artifact_response, :soap)
9
+ notify('create_response', Saml::Util.sign_xml(artifact_response, :soap))
9
10
  end
10
11
 
11
12
  def create_response(artifact_response)
@@ -23,7 +24,7 @@ module Saml
23
24
  end
24
25
 
25
26
  def receive_message(request)
26
- raw_xml = request.body.dup.read
27
+ raw_xml = notify('receive_message', request.body.dup.read)
27
28
  artifact_resolve = Saml::ArtifactResolve.parse(raw_xml, single: true)
28
29
 
29
30
  Saml::Util.verify_xml(artifact_resolve, raw_xml)
@@ -33,9 +34,10 @@ module Saml
33
34
  artifact = request.params["SAMLart"]
34
35
  artifact_resolve = Saml::ArtifactResolve.new(artifact: artifact, destination: location)
35
36
 
36
- response = Saml::Util.post(location, Saml::Util.sign_xml(artifact_resolve, :soap))
37
+ response = Saml::Util.post(location, notify('create_post', Saml::Util.sign_xml(artifact_resolve, :soap)))
37
38
 
38
39
  if response.code == "200"
40
+ notify('receive_response', response.body)
39
41
  artifact_response = Saml::ArtifactResponse.parse(response.body, single: true)
40
42
  verified_artifact_response = Saml::Util.verify_xml(artifact_response, response.body)
41
43
 
@@ -1,11 +1,13 @@
1
1
  module Saml
2
2
  module Bindings
3
3
  class HTTPPost
4
+ include Saml::Notification
5
+
4
6
  class << self
5
7
  def create_form_attributes(message, options = {})
6
8
  param = message.is_a?(Saml::ComplexTypes::StatusResponseType) ? "SAMLResponse" : "SAMLRequest"
7
9
 
8
- xml = Saml::Util.sign_xml(message)
10
+ xml = notify('create_message', Saml::Util.sign_xml(message))
9
11
 
10
12
  variables = {}
11
13
  variables[param] = Saml::Encoding.encode_64(xml)
@@ -19,6 +21,7 @@ module Saml
19
21
 
20
22
  def receive_message(request, type)
21
23
  message = Saml::Encoding.decode_64(request.params["SAMLRequest"] || request.params["SAMLResponse"])
24
+ notify('receive_message', message)
22
25
  request_or_response = Saml.parse_message(message, type)
23
26
 
24
27
  verified_request_or_response = Saml::Util.verify_xml(request_or_response, message)
@@ -28,4 +31,4 @@ module Saml
28
31
  end
29
32
  end
30
33
  end
31
- end
34
+ end
@@ -1,6 +1,8 @@
1
1
  module Saml
2
2
  module Bindings
3
3
  class HTTPRedirect
4
+ include Saml::Notification
5
+
4
6
  class << self
5
7
  def create_url(request_or_response, options = {})
6
8
  options[:signature_algorithm] ||= 'http://www.w3.org/2000/09/xmldsig#rsa-sha1'
@@ -26,7 +28,7 @@ module Saml
26
28
  private
27
29
 
28
30
  def parse_request_or_response(type, params)
29
- message = decode_message(params["SAMLRequest"] || params["SAMLResponse"])
31
+ message = notify('receive_message', decode_message(params["SAMLRequest"] || params["SAMLResponse"]))
30
32
 
31
33
  Saml.parse_message(message, type)
32
34
  end
@@ -73,7 +75,7 @@ module Saml
73
75
  end
74
76
 
75
77
  def encoded_message
76
- Saml::Encoding.encode_64(Saml::Encoding.encode_gzip(request_or_response.to_xml))
78
+ Saml::Encoding.encode_64(Saml::Encoding.encode_gzip(notify('create_message', request_or_response.to_xml)))
77
79
  end
78
80
 
79
81
  def encoded_params
@@ -1,21 +1,23 @@
1
1
  module Saml
2
2
  module Bindings
3
3
  class SOAP
4
+ include Saml::Notification
5
+
4
6
  class << self
5
7
 
6
8
  SOAP_ACTION = 'http://www.oasis-open.org/committees/security'
7
9
 
8
10
  def create_response_xml(response)
9
- Saml::Util.sign_xml(response, :soap)
11
+ notify('create_response', Saml::Util.sign_xml(response, :soap))
10
12
  end
11
13
 
12
14
  def post_message(message, response_type)
13
- signed_message = Saml::Util.sign_xml(message, :soap)
15
+ signed_message = notify('create_post', Saml::Util.sign_xml(message, :soap))
14
16
 
15
17
  http_response = Saml::Util.post(message.destination, signed_message, { 'SOAPAction' => SOAP_ACTION } )
16
18
 
17
19
  if http_response.code == "200"
18
- response = Saml.parse_message(http_response.body, response_type)
20
+ response = notify('receive_response', Saml.parse_message(http_response.body, response_type))
19
21
  Saml::Util.verify_xml(response, http_response.body)
20
22
  else
21
23
  nil
@@ -24,6 +26,7 @@ module Saml
24
26
 
25
27
  def receive_message(request, type)
26
28
  raw_xml = request.body.dup.read
29
+ notify('receive_message', raw_xml)
27
30
  message = Saml.parse_message(raw_xml, type)
28
31
 
29
32
  Saml::Util.verify_xml(message, raw_xml)
@@ -0,0 +1,55 @@
1
+ module Saml
2
+ module Notification
3
+ extend ActiveSupport::Concern
4
+
5
+ def notify(method, result)
6
+ self.class.notify(method, result)
7
+ end
8
+
9
+ module ClassMethods
10
+ def wrap_with_notification(method, instance_method)
11
+ wrapper = <<-RUBY
12
+ define_method "#{method}_with_notification" do |*args|
13
+ notify "#{method}", send("#{method}_without_notification", *args)
14
+ end
15
+ alias_method_chain :#{method}, :notification
16
+ RUBY
17
+
18
+ if instance_method
19
+ class_eval wrapper
20
+ else
21
+ class_eval "class << self; #{wrapper}; end"
22
+ end
23
+ end
24
+
25
+ def notify(method, result)
26
+ class_name = self.name.demodulize.underscore
27
+ ActiveSupport::Notifications.instrument "#{method}.#{class_name}.saml", result
28
+ result
29
+ end
30
+
31
+ def notify_on(*options)
32
+ options.present? ? @notify_on = options : @notify_on
33
+ end
34
+
35
+ def should_wrap?(name)
36
+ @notify_on ||= []
37
+ @exclude ||= []
38
+
39
+ return false if @notify_on.exclude?(name) || @exclude.include?(name.to_s)
40
+ @exclude << "#{name}_with_notification"
41
+ @exclude << "#{name}_without_notification"
42
+ @exclude << "#{name}"
43
+ true
44
+ end
45
+
46
+ def singleton_method_added(name)
47
+ wrap_with_notification(name, false) if should_wrap?(name)
48
+ end
49
+
50
+ def method_added(name)
51
+ wrap_with_notification(name, true) if should_wrap?(name)
52
+ end
53
+ end
54
+ end
55
+ end
@@ -1,3 +1,3 @@
1
1
  module Saml
2
- VERSION = "2.1.6"
2
+ VERSION = "2.1.7"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: libsaml
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.6
4
+ version: 2.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Benoist Claassen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-20 00:00:00.000000000 Z
11
+ date: 2014-01-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -191,6 +191,7 @@ files:
191
191
  - lib/saml/encoding.rb
192
192
  - lib/saml/logout_request.rb
193
193
  - lib/saml/logout_response.rb
194
+ - lib/saml/notification.rb
194
195
  - lib/saml/null_provider.rb
195
196
  - lib/saml/provider.rb
196
197
  - lib/saml/provider_stores/file.rb