samlr 2.0.2 → 2.0.3

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of samlr might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f6094cc422e3c1b4b142851b36834b9730951800
4
- data.tar.gz: 00b21f42fa02b1f0b99f0c7683c023a6afa450f4
3
+ metadata.gz: ff0c127da7d3901b26a715c4a9466d08ff82af1c
4
+ data.tar.gz: 3f8fdb9e448341a7b1128569e456dccf1e44d552
5
5
  SHA512:
6
- metadata.gz: 25091398892548578f7eaf39cb8541c48c1de673e703c5433713872f7c69301bb29206dc8fa7254178fc5ca1f9bb705531c03ff4345d7da067dc4489baf57fbc
7
- data.tar.gz: 08cdd18525af9b2b938635ce658b2f1ff828e65d349948f239f6dd8ce49022e0dcaf665bcd0cdb646d88f889dd3b906872074561983a47570e8ab2dfb07ab43c
6
+ metadata.gz: 4705d104543371a3c61a72ac723f136c7d7cdb00c8aa51f5fd6d6b2909a9942ef03bf6f0388e3407e6c035c777fd5b02414cb81529b3219af652e838a3cb17b4
7
+ data.tar.gz: 7a4e6fadb9d14f2691d6008ab82e78427d6d1b6c71d64904bf5913aa23163083f9d837a081cf7c5699e1178238a2a60b4f53d62e14fd90bcd7e80870d8f4f39d
@@ -5,8 +5,6 @@ module Samlr
5
5
  # Use this for building the SAML logout request XML
6
6
  module LogoutRequestBuilder
7
7
  def self.build(options = {})
8
- name_id_format = options[:name_id_format] || EMAIL_FORMAT
9
-
10
8
  # Mandatory
11
9
  name_id = options.fetch(:name_id)
12
10
  issuer = options.fetch(:issuer)
@@ -14,14 +12,32 @@ module Samlr
14
12
  builder = Nokogiri::XML::Builder.new do |xml|
15
13
  xml.LogoutRequest("xmlns:samlp" => NS_MAP["samlp"], "xmlns:saml" => NS_MAP["saml"], "ID" => Samlr::Tools.uuid, "IssueInstant" => Samlr::Tools::Timestamp.stamp, "Version" => "2.0") do
16
14
  xml.doc.root.namespace = xml.doc.root.namespace_definitions.find { |ns| ns.prefix == "samlp" }
17
-
18
15
  xml["saml"].Issuer(issuer)
19
- xml["saml"].NameID(name_id, "Format" => name_id_format)
16
+ xml["saml"].NameID(name_id, logout_options(options))
20
17
  end
21
18
  end
22
19
 
23
20
  builder.to_xml(COMPACT)
24
21
  end
22
+
23
+ def self.logout_options(options)
24
+ name_id_options = options[:name_id_options] || {}
25
+ options = { "Format" => format_option(options) }
26
+ options.merge!("NameQualifier" => name_id_options[:name_qualifier]) if name_id_options[:name_qualifier]
27
+ options.merge!("SPNameQualifier" => name_id_options[:spname_qualifier]) if name_id_options[:spname_qualifier]
28
+ options
29
+ end
30
+
31
+ def self.format_option(options)
32
+ if options[:name_id_format]
33
+ warn "[DEPRECATION] options[:name_id_format] is deprecated. Please use options[:name_id_options][:format] instead"
34
+ options[:name_id_format]
35
+ elsif options[:name_id_options] && options[:name_id_options][:format]
36
+ options[:name_id_options][:format]
37
+ else
38
+ EMAIL_FORMAT
39
+ end
40
+ end
25
41
  end
26
42
  end
27
43
  end
@@ -1,4 +1,4 @@
1
- Gem::Specification.new "samlr", "2.0.2" do |s|
1
+ Gem::Specification.new "samlr", "2.0.3" do |s|
2
2
  s.summary = "Ruby tools for SAML"
3
3
  s.description = "Helps you implement a SAML SP"
4
4
  s.authors = ["Morten Primdahl"]
@@ -1,11 +1,15 @@
1
1
  require File.expand_path("test/test_helper")
2
2
 
3
3
  describe Samlr::LogoutRequest do
4
- before do
5
- @request = Samlr::LogoutRequest.new(
4
+ let(:options) {
5
+ {
6
6
  :issuer => "https://sp.example.com/saml2",
7
7
  :name_id => "test@test.com"
8
- )
8
+ }
9
+ }
10
+
11
+ before do
12
+ @request = Samlr::LogoutRequest.new(options)
9
13
  end
10
14
 
11
15
  describe "#body" do
@@ -36,4 +40,34 @@ describe Samlr::LogoutRequest do
36
40
  end
37
41
  end
38
42
  end
43
+
44
+ describe "with optional params" do
45
+ it "understands name_id_format" do
46
+ options.merge!(:name_id_format => "some format")
47
+ request = Samlr::LogoutRequest.new(options)
48
+
49
+ assert_match /<saml:NameID Format="some format">/, request.body
50
+ end
51
+
52
+ it "understands [:name_id_options][:format]" do
53
+ options.merge!(:name_id_options => {:format => "some format"})
54
+ request = Samlr::LogoutRequest.new(options)
55
+
56
+ assert_match /<saml:NameID Format="some format">/, request.body
57
+ end
58
+
59
+ it "understands NameQualifier" do
60
+ options.merge!(:name_id_options => {:name_qualifier => "Some name qualifier"})
61
+ request = Samlr::LogoutRequest.new(options)
62
+
63
+ assert_match /NameQualifier="Some name qualifier"/, request.body
64
+ end
65
+
66
+ it "understands SPNameQualifier" do
67
+ options.merge!(:name_id_options => {:spname_qualifier => "Some SPName qualifier"})
68
+ request = Samlr::LogoutRequest.new(options)
69
+
70
+ assert_match /SPNameQualifier="Some SPName qualifier"/, request.body
71
+ end
72
+ end
39
73
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: samlr
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.2
4
+ version: 2.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Morten Primdahl
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-06 00:00:00.000000000 Z
11
+ date: 2014-08-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri