saml-kit 0.2.13 → 0.2.14
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 +4 -4
- data/lib/saml/kit/authentication_request.rb +3 -2
- data/lib/saml/kit/builders/templates/xml_signature.builder +1 -1
- data/lib/saml/kit/builders/xml_signature.rb +3 -3
- data/lib/saml/kit/certificate.rb +2 -2
- data/lib/saml/kit/key_pair.rb +7 -2
- data/lib/saml/kit/self_signed_certificate.rb +3 -3
- data/lib/saml/kit/signatures.rb +8 -2
- data/lib/saml/kit/templatable.rb +4 -0
- data/lib/saml/kit/version.rb +1 -1
- 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: 8c247888ce2d9b7ca65605a7169e275f60094185
|
4
|
+
data.tar.gz: 666425c5224ece36334d9fee1c0b8c249fabc7e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6dffef3e1532ceef9178bace64ffae38caf0a4580e0926ea5a1524d15242efc29148b47164aadaabcc14808ef2e62c7ae618c4dfd42954346a556081750161d6
|
7
|
+
data.tar.gz: db069d1133acf615608f846d86d46d9ba38cddc4670ea5c45899266a25a465247e0a809f6308c98f011896de3a8f1753485ac83a801f88359ef6c7ab492201d5
|
@@ -41,9 +41,10 @@ module Saml
|
|
41
41
|
# Generate a Response for a specific user.
|
42
42
|
# @param user [Object] this is a custom user object that can be used for generating a nameid and assertion attributes.
|
43
43
|
# @param binding [Symbol] the SAML binding to use `:http_post` or `:http_redirect`.
|
44
|
-
|
44
|
+
# @param configuration [Saml::Kit::Configuration] the configuration to use to build the response.
|
45
|
+
def response_for(user, binding:, relay_state: nil, configuration: Saml::Kit.configuration)
|
45
46
|
response_binding = provider.assertion_consumer_service_for(binding: binding)
|
46
|
-
builder = Saml::Kit::Response.builder(user, self) do |x|
|
47
|
+
builder = Saml::Kit::Response.builder(user, self, configuration: configuration) do |x|
|
47
48
|
x.embed_signature = provider.want_assertions_signed
|
48
49
|
yield x if block_given?
|
49
50
|
end
|
@@ -19,12 +19,12 @@ module Saml
|
|
19
19
|
|
20
20
|
attr_reader :embed_signature, :configuration
|
21
21
|
attr_reader :reference_id
|
22
|
-
attr_reader :
|
22
|
+
attr_reader :certificate
|
23
23
|
|
24
|
-
def initialize(reference_id, configuration:)
|
24
|
+
def initialize(reference_id, configuration:, certificate: )
|
25
25
|
@configuration = configuration
|
26
26
|
@reference_id = reference_id
|
27
|
-
@
|
27
|
+
@certificate = certificate
|
28
28
|
end
|
29
29
|
|
30
30
|
def signature_method
|
data/lib/saml/kit/certificate.rb
CHANGED
@@ -35,7 +35,7 @@ module Saml
|
|
35
35
|
end
|
36
36
|
|
37
37
|
def ==(other)
|
38
|
-
self.
|
38
|
+
self.fingerprint == other.fingerprint
|
39
39
|
end
|
40
40
|
|
41
41
|
def eql?(other)
|
@@ -51,7 +51,7 @@ module Saml
|
|
51
51
|
end
|
52
52
|
|
53
53
|
def to_h
|
54
|
-
{ use: @use,
|
54
|
+
{ use: @use, fingerprint: fingerprint.to_s }
|
55
55
|
end
|
56
56
|
|
57
57
|
def inspect
|
data/lib/saml/kit/key_pair.rb
CHANGED
@@ -3,15 +3,20 @@ module Saml
|
|
3
3
|
class KeyPair # :nodoc:
|
4
4
|
attr_reader :certificate, :private_key, :use
|
5
5
|
|
6
|
-
def initialize(certificate, private_key,
|
6
|
+
def initialize(certificate, private_key, passphrase, use)
|
7
7
|
@use = use
|
8
8
|
@certificate = Saml::Kit::Certificate.new(certificate, use: use)
|
9
|
-
@private_key = OpenSSL::PKey::RSA.new(private_key,
|
9
|
+
@private_key = OpenSSL::PKey::RSA.new(private_key, passphrase)
|
10
10
|
end
|
11
11
|
|
12
12
|
def for?(use)
|
13
13
|
@use == use
|
14
14
|
end
|
15
|
+
|
16
|
+
def self.generate(use:, passphrase: SecureRandom.uuid)
|
17
|
+
certificate, private_key = SelfSignedCertificate.new(passphrase).create
|
18
|
+
new(certificate, private_key, passphrase, use)
|
19
|
+
end
|
15
20
|
end
|
16
21
|
end
|
17
22
|
end
|
@@ -3,8 +3,8 @@ module Saml
|
|
3
3
|
class SelfSignedCertificate
|
4
4
|
SUBJECT="/C=CA/ST=Alberta/L=Calgary/O=SamlKit/OU=SamlKit/CN=SamlKit"
|
5
5
|
|
6
|
-
def initialize(
|
7
|
-
@
|
6
|
+
def initialize(passphrase)
|
7
|
+
@passphrase = passphrase
|
8
8
|
end
|
9
9
|
|
10
10
|
def create
|
@@ -20,7 +20,7 @@ module Saml
|
|
20
20
|
certificate.sign(rsa_key, OpenSSL::Digest::SHA256.new)
|
21
21
|
[
|
22
22
|
certificate.to_pem,
|
23
|
-
rsa_key.to_pem(OpenSSL::Cipher.new('AES-256-CBC'), @
|
23
|
+
rsa_key.to_pem(OpenSSL::Cipher.new('AES-256-CBC'), @passphrase)
|
24
24
|
]
|
25
25
|
end
|
26
26
|
end
|
data/lib/saml/kit/signatures.rb
CHANGED
@@ -7,18 +7,24 @@ module Saml
|
|
7
7
|
# @!visibility private
|
8
8
|
def initialize(configuration:)
|
9
9
|
@configuration = configuration
|
10
|
+
@key_pair = configuration.key_pairs(use: :signing).last
|
11
|
+
end
|
12
|
+
|
13
|
+
def sign_with(key_pair)
|
14
|
+
@key_pair = key_pair
|
10
15
|
end
|
11
16
|
|
12
17
|
# @!visibility private
|
13
18
|
def build(reference_id)
|
14
19
|
return nil unless configuration.sign?
|
15
|
-
|
20
|
+
certificate = @key_pair.certificate
|
21
|
+
Saml::Kit::Builders::XmlSignature.new(reference_id, configuration: configuration, certificate: certificate)
|
16
22
|
end
|
17
23
|
|
18
24
|
# @!visibility private
|
19
25
|
def complete(raw_xml)
|
20
26
|
return raw_xml unless configuration.sign?
|
21
|
-
private_key =
|
27
|
+
private_key = @key_pair.private_key
|
22
28
|
Xmldsig::SignedDocument.new(raw_xml).sign(private_key)
|
23
29
|
end
|
24
30
|
|
data/lib/saml/kit/templatable.rb
CHANGED
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: 0.2.
|
4
|
+
version: 0.2.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- mo khan
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-12-
|
11
|
+
date: 2017-12-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|