saml-kit 1.0.23 → 1.0.24
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/saml/kit/assertion.rb +18 -11
- data/lib/saml/kit/builders/assertion.rb +14 -10
- data/lib/saml/kit/builders/response.rb +8 -10
- data/lib/saml/kit/concerns/xsd_validatable.rb +1 -1
- data/lib/saml/kit/document.rb +3 -2
- data/lib/saml/kit/locales/en.yml +5 -1
- data/lib/saml/kit/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3ff0dd35ecb05542b7f21d3ead4c22f232a337eaa41c9ddfa56b6d82b8f8873b
|
4
|
+
data.tar.gz: 4d189291119912edfc23847cffa213fb5c53eca8f95a27810d40f8c111ff533e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8354776fdbb5c0ae66ed2e4a18baa38c3073e2e99f49117638419e01d111c012b0cdbe862654798bf285d9e0d5bbe78fab3f0d66e7ce79ee5c6a8ca95c58e676
|
7
|
+
data.tar.gz: da11bf9e0f5d4f9fec869b7908f0249d63454ba2edefe40e3b0080037d02615d1129ad6b9cd9c72ed1794d64da25eb789e1412ad4db35070d1a28f5e00829f76
|
data/lib/saml/kit/assertion.rb
CHANGED
@@ -5,10 +5,7 @@ module Saml
|
|
5
5
|
# This class validates the Assertion
|
6
6
|
# element nested in a Response element
|
7
7
|
# of a SAML document.
|
8
|
-
class Assertion
|
9
|
-
include ActiveModel::Validations
|
10
|
-
include Translatable
|
11
|
-
include XmlParseable
|
8
|
+
class Assertion < Document
|
12
9
|
extend Forwardable
|
13
10
|
XPATH = [
|
14
11
|
'/samlp:Response/saml:Assertion',
|
@@ -21,26 +18,35 @@ module Saml
|
|
21
18
|
validate :must_match_issuer, if: :decryptable?
|
22
19
|
validate :must_be_active_session, if: :decryptable?
|
23
20
|
validate :must_have_valid_signature, if: :decryptable?
|
24
|
-
attr_reader :name
|
21
|
+
attr_reader :name, :configuration
|
25
22
|
attr_accessor :occurred_at
|
26
23
|
|
27
24
|
def initialize(
|
28
25
|
node, configuration: Saml::Kit.configuration, private_keys: []
|
29
26
|
)
|
30
27
|
@name = 'Assertion'
|
31
|
-
@to_nokogiri = node
|
28
|
+
@to_nokogiri = node.is_a?(String) ? Nokogiri::XML(node).root : node
|
32
29
|
@configuration = configuration
|
33
30
|
@occurred_at = Time.current
|
34
31
|
@cannot_decrypt = false
|
35
32
|
@encrypted = false
|
36
33
|
keys = configuration.private_keys(use: :encryption) + private_keys
|
37
34
|
decrypt(::Xml::Kit::Decryption.new(private_keys: keys.uniq))
|
35
|
+
super(to_s, name: 'Assertion', configuration: configuration)
|
36
|
+
end
|
37
|
+
|
38
|
+
def id
|
39
|
+
at_xpath('./@ID').try(:value)
|
38
40
|
end
|
39
41
|
|
40
42
|
def issuer
|
41
43
|
at_xpath('./saml:Issuer').try(:text)
|
42
44
|
end
|
43
45
|
|
46
|
+
def version
|
47
|
+
at_xpath('./@Version').try(:value)
|
48
|
+
end
|
49
|
+
|
44
50
|
def name_id
|
45
51
|
at_xpath('./saml:Subject/saml:NameID').try(:text)
|
46
52
|
end
|
@@ -66,9 +72,12 @@ module Saml
|
|
66
72
|
now > drifted_started_at && !expired?(now)
|
67
73
|
end
|
68
74
|
|
69
|
-
def
|
70
|
-
|
71
|
-
|
75
|
+
def expected_type?
|
76
|
+
at_xpath('../saml:Assertion|../saml:EncryptedAssertion').present?
|
77
|
+
end
|
78
|
+
|
79
|
+
def attribute_statement(xpath = './saml:AttributeStatement')
|
80
|
+
@attribute_statement ||= AttributeStatement.new(search(xpath))
|
72
81
|
end
|
73
82
|
|
74
83
|
def conditions
|
@@ -90,8 +99,6 @@ module Saml
|
|
90
99
|
|
91
100
|
private
|
92
101
|
|
93
|
-
attr_reader :configuration
|
94
|
-
|
95
102
|
def decrypt(decryptor)
|
96
103
|
encrypted_assertion = at_xpath('./xmlenc:EncryptedData')
|
97
104
|
@encrypted = encrypted_assertion.present?
|
@@ -7,17 +7,21 @@ module Saml
|
|
7
7
|
# {include:file:lib/saml/kit/builders/templates/assertion.builder}
|
8
8
|
class Assertion
|
9
9
|
include XmlTemplatable
|
10
|
-
extend Forwardable
|
11
|
-
|
12
|
-
def_delegators :@response_builder,
|
13
|
-
:request, :issuer, :reference_id, :now, :configuration, :user,
|
14
|
-
:version, :destination
|
15
10
|
|
11
|
+
attr_reader :user, :request, :configuration
|
12
|
+
attr_accessor :reference_id
|
13
|
+
attr_accessor :now, :destination
|
14
|
+
attr_accessor :issuer, :version
|
16
15
|
attr_accessor :default_name_id_format
|
17
16
|
|
18
|
-
def initialize(
|
19
|
-
@
|
20
|
-
|
17
|
+
def initialize(user, request, configuration: Saml::Kit.configuration)
|
18
|
+
@user = user
|
19
|
+
@request = request
|
20
|
+
@configuration = configuration
|
21
|
+
@issuer = configuration.entity_id
|
22
|
+
@reference_id = ::Xml::Kit::Id.generate
|
23
|
+
@version = '2.0'
|
24
|
+
@now = Time.now.utc
|
21
25
|
self.default_name_id_format = Saml::Kit::Namespaces::UNSPECIFIED_NAMEID
|
22
26
|
end
|
23
27
|
|
@@ -34,8 +38,8 @@ module Saml
|
|
34
38
|
user.assertion_attributes_for(request)
|
35
39
|
end
|
36
40
|
|
37
|
-
def
|
38
|
-
|
41
|
+
def build
|
42
|
+
Saml::Kit::Assertion.new(to_xml, configuration: configuration)
|
39
43
|
end
|
40
44
|
|
41
45
|
private
|
@@ -8,7 +8,7 @@ module Saml
|
|
8
8
|
class Response
|
9
9
|
include XmlTemplatable
|
10
10
|
attr_reader :user, :request
|
11
|
-
attr_accessor :id, :
|
11
|
+
attr_accessor :id, :now
|
12
12
|
attr_accessor :version, :status_code, :status_message
|
13
13
|
attr_accessor :issuer, :destination
|
14
14
|
attr_reader :configuration
|
@@ -19,7 +19,6 @@ module Saml
|
|
19
19
|
@user = user
|
20
20
|
@request = request
|
21
21
|
@id = ::Xml::Kit::Id.generate
|
22
|
-
@reference_id = ::Xml::Kit::Id.generate
|
23
22
|
@now = Time.now.utc
|
24
23
|
@version = '2.0'
|
25
24
|
@status_code = Namespaces::SUCCESS
|
@@ -46,14 +45,13 @@ module Saml
|
|
46
45
|
def assertion
|
47
46
|
@assertion ||=
|
48
47
|
begin
|
49
|
-
assertion =
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
end
|
48
|
+
assertion = Assertion.new(user, request, configuration: configuration)
|
49
|
+
assertion.sign_with(@signing_key_pair) if @signing_key_pair
|
50
|
+
assertion.embed_signature = embed_signature unless embed_signature.nil?
|
51
|
+
assertion.now = now
|
52
|
+
assertion.destination = destination
|
53
|
+
assertion.issuer = issuer
|
54
|
+
encrypt ? EncryptedAssertion.new(self, assertion) : assertion
|
57
55
|
end
|
58
56
|
end
|
59
57
|
|
data/lib/saml/kit/document.rb
CHANGED
@@ -83,10 +83,11 @@ module Saml
|
|
83
83
|
# @!visibility private
|
84
84
|
def builder_class # :nodoc:
|
85
85
|
{
|
86
|
-
|
87
|
-
LogoutResponse.to_s => Saml::Kit::Builders::LogoutResponse,
|
86
|
+
Assertion.to_s => Saml::Kit::Builders::Assertion,
|
88
87
|
AuthenticationRequest.to_s => Saml::Kit::Builders::AuthenticationRequest,
|
89
88
|
LogoutRequest.to_s => Saml::Kit::Builders::LogoutRequest,
|
89
|
+
LogoutResponse.to_s => Saml::Kit::Builders::LogoutResponse,
|
90
|
+
Response.to_s => Saml::Kit::Builders::Response,
|
90
91
|
}[name] || (raise ArgumentError, "Unknown SAML Document #{name}")
|
91
92
|
end
|
92
93
|
end
|
data/lib/saml/kit/locales/en.yml
CHANGED
@@ -5,8 +5,12 @@ en:
|
|
5
5
|
Assertion:
|
6
6
|
cannot_decrypt: "cannot be decrypted."
|
7
7
|
expired: "must not be expired."
|
8
|
-
|
8
|
+
invalid: "must contain Assertion."
|
9
|
+
invalid_fingerprint: "is not registered."
|
10
|
+
invalid_version: "must be 2.0."
|
9
11
|
must_contain_single_assertion: "must contain single Assertion."
|
12
|
+
must_match_issuer: "must match entityId."
|
13
|
+
unregistered: "is unregistered."
|
10
14
|
AuthnRequest:
|
11
15
|
invalid: "must contain AuthnRequest."
|
12
16
|
invalid_fingerprint: "is not registered."
|
data/lib/saml/kit/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: saml-kit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.24
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- mo khan
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-09-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|