samlr 2.0.2 → 2.0.3
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.
Potentially problematic release.
This version of samlr might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/lib/samlr/tools/logout_request_builder.rb +20 -4
- data/samlr.gemspec +1 -1
- data/test/unit/test_logout_request.rb +37 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ff0c127da7d3901b26a715c4a9466d08ff82af1c
|
4
|
+
data.tar.gz: 3f8fdb9e448341a7b1128569e456dccf1e44d552
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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,
|
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
|
data/samlr.gemspec
CHANGED
@@ -1,11 +1,15 @@
|
|
1
1
|
require File.expand_path("test/test_helper")
|
2
2
|
|
3
3
|
describe Samlr::LogoutRequest do
|
4
|
-
|
5
|
-
|
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.
|
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-
|
11
|
+
date: 2014-08-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|