saml-kit 0.3.4 → 0.3.5
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/configuration.rb +12 -0
- 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: aa6e4cc97ac1b952312da27f68858628cc913868c59184ace6d64b04369e045e
|
4
|
+
data.tar.gz: e86e6d0a6551896ebaa627827d176f8d300b155811af1c27b42a963356f32589
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 91c05ab684c6e4da67e9a2b28d905d36c1e9edbe320879e61c9cc5fc79b8bdb8d0b7bae58c816aa6e2842521da524947183c6d65b6c55c32e5e052731f908f40
|
7
|
+
data.tar.gz: 2a78ce0bd35526550ab46e8cc4070be57a46e4805ab02a41105ba35a222f7dc4e9db67137c036914a84ff1df80b87ecb46e35523f0ba15d47cbcf1da033ae38c
|
@@ -20,6 +20,7 @@ module Saml
|
|
20
20
|
# configuration.add_key_pair(ENV["X509_CERTIFICATE"], ENV["PRIVATE_KEY"], passphrase: ENV['PRIVATE_KEY_PASSPHRASE'], use: :encryption)
|
21
21
|
# end
|
22
22
|
class Configuration
|
23
|
+
USES = [:signing, :encryption]
|
23
24
|
# The issuer or entity_id to use.
|
24
25
|
attr_accessor :issuer
|
25
26
|
# The signature method to use when generating signatures (See {Saml::Kit::Builders::XmlSignature::SIGNATURE_METHODS})
|
@@ -53,6 +54,7 @@ module Saml
|
|
53
54
|
# @param passphrase [String] the password to decrypt the private key.
|
54
55
|
# @param use [Symbol] the type of key pair, `:signing` or `:encryption`
|
55
56
|
def add_key_pair(certificate, private_key, passphrase: '', use: :signing)
|
57
|
+
ensure_proper_use!(use)
|
56
58
|
@key_pairs.push(::Xml::Kit::KeyPair.new(certificate, private_key, passphrase, use.to_sym))
|
57
59
|
end
|
58
60
|
|
@@ -61,6 +63,7 @@ module Saml
|
|
61
63
|
# @param use [Symbol] the type of key pair, `:signing` or `:encryption`
|
62
64
|
# @param passphrase [String] the private key passphrase to use.
|
63
65
|
def generate_key_pair_for(use:, passphrase: SecureRandom.uuid)
|
66
|
+
ensure_proper_use!(use)
|
64
67
|
certificate, private_key = ::Xml::Kit::SelfSignedCertificate.new.create(passphrase: passphrase)
|
65
68
|
add_key_pair(certificate, private_key, passphrase: passphrase, use: use)
|
66
69
|
end
|
@@ -108,6 +111,15 @@ module Saml
|
|
108
111
|
def sign?
|
109
112
|
certificates(use: :signing).any?
|
110
113
|
end
|
114
|
+
|
115
|
+
private
|
116
|
+
|
117
|
+
def ensure_proper_use!(use)
|
118
|
+
unless USES.include?(use)
|
119
|
+
error_message = "Use must be either :signing or :encryption"
|
120
|
+
raise ArgumentError.new(error_message)
|
121
|
+
end
|
122
|
+
end
|
111
123
|
end
|
112
124
|
end
|
113
125
|
end
|
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.3.
|
4
|
+
version: 0.3.5
|
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-01-
|
11
|
+
date: 2018-01-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|