saml-kit 0.3.5 → 0.3.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/saml-kit.rb +1 -0
- data/lib/saml/kit/assertion.rb +1 -1
- data/lib/saml/kit/buildable.rb +8 -4
- data/lib/saml/kit/builders/authentication_request.rb +1 -1
- data/lib/saml/kit/builders/identity_provider_metadata.rb +1 -1
- data/lib/saml/kit/builders/logout_request.rb +1 -1
- data/lib/saml/kit/builders/logout_response.rb +1 -1
- data/lib/saml/kit/builders/metadata.rb +1 -1
- data/lib/saml/kit/builders/response.rb +1 -1
- data/lib/saml/kit/configuration.rb +16 -4
- data/lib/saml/kit/default_registry.rb +1 -1
- data/lib/saml/kit/rspec.rb +2 -0
- data/lib/saml/kit/rspec/have_query_param.rb +19 -0
- data/lib/saml/kit/rspec/have_xpath.rb +28 -0
- data/lib/saml/kit/version.rb +1 -1
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f94e30d77a2e999c93935934dccb12d6cb491924a2dae47f94a946a491ceb373
|
4
|
+
data.tar.gz: 4e2116c0e7b04010dff208231eaae5eaad02c02539d0d23235fe2effad457f68
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4b8c2639dd377b437487f76978f8afd7bbad8fa8b4a8256e5f25adae08152b2efcaa6907d67f1c201a4fc72abc8e29ab8675252657ad502e8668f87b65a0c0bf
|
7
|
+
data.tar.gz: d1f0acc593a9fae6d8f1087e59779fa6e0868e52f1b2c00280f44bb43a7ced70c8ea33c06ae7e0e87dd63edf243831ab1529f4fb13de7136457f3cf9b7635847
|
data/README.md
CHANGED
@@ -33,7 +33,7 @@ To specify a global configuration: (useful for a rails application)
|
|
33
33
|
|
34
34
|
```ruby
|
35
35
|
Saml::Kit.configure do |configuration|
|
36
|
-
configuration.
|
36
|
+
configuration.entity_id = ENV['ISSUER']
|
37
37
|
configuration.generate_key_pair_for(use: :signing)
|
38
38
|
configuration.add_key_pair(ENV["CERTIFICATE"], ENV["PRIVATE_KEY"], passphrase: ENV['PASSPHRASE'], use: :signing)
|
39
39
|
configuration.generate_key_pair_for(use: :encryption)
|
data/lib/saml-kit.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'saml/kit'
|
data/lib/saml/kit/assertion.rb
CHANGED
data/lib/saml/kit/buildable.rb
CHANGED
@@ -4,12 +4,16 @@ module Saml
|
|
4
4
|
extend ActiveSupport::Concern
|
5
5
|
|
6
6
|
class_methods do
|
7
|
-
def build(*args
|
8
|
-
builder(*args
|
7
|
+
def build(*args) # :yields builder
|
8
|
+
builder(*args) do |builder|
|
9
|
+
yield builder if block_given?
|
10
|
+
end.build
|
9
11
|
end
|
10
12
|
|
11
|
-
def build_xml(*args
|
12
|
-
builder(*args
|
13
|
+
def build_xml(*args) # :yields builder
|
14
|
+
builder(*args) do |builder|
|
15
|
+
yield builder if block_given?
|
16
|
+
end.to_xml
|
13
17
|
end
|
14
18
|
|
15
19
|
def builder(*args) # :yields builder
|
@@ -12,7 +12,7 @@ module Saml
|
|
12
12
|
def initialize(configuration: Saml::Kit.configuration)
|
13
13
|
@configuration = configuration
|
14
14
|
@id = ::Xml::Kit::Id.generate
|
15
|
-
@issuer = configuration.
|
15
|
+
@issuer = configuration.entity_id
|
16
16
|
@name_id_format = Namespaces::PERSISTENT
|
17
17
|
@now = Time.now.utc
|
18
18
|
@version = "2.0"
|
@@ -16,7 +16,7 @@ module Saml
|
|
16
16
|
def initialize(configuration: Saml::Kit.configuration)
|
17
17
|
@attributes = []
|
18
18
|
@configuration = configuration
|
19
|
-
@entity_id = configuration.
|
19
|
+
@entity_id = configuration.entity_id
|
20
20
|
@id = ::Xml::Kit::Id.generate
|
21
21
|
@logout_urls = []
|
22
22
|
@name_id_formats = [Namespaces::PERSISTENT]
|
@@ -13,7 +13,7 @@ module Saml
|
|
13
13
|
@configuration = configuration
|
14
14
|
@user = user
|
15
15
|
@id = ::Xml::Kit::Id.generate
|
16
|
-
@issuer = configuration.
|
16
|
+
@issuer = configuration.entity_id
|
17
17
|
@name_id_format = Saml::Kit::Namespaces::PERSISTENT
|
18
18
|
@now = Time.now.utc
|
19
19
|
@version = "2.0"
|
@@ -12,7 +12,7 @@ module Saml
|
|
12
12
|
def initialize(request, configuration: Saml::Kit.configuration)
|
13
13
|
@configuration = configuration
|
14
14
|
@id = ::Xml::Kit::Id.generate
|
15
|
-
@issuer = configuration.
|
15
|
+
@issuer = configuration.entity_id
|
16
16
|
@now = Time.now.utc
|
17
17
|
@request = request
|
18
18
|
@status_code = Namespaces::SUCCESS
|
@@ -3,7 +3,7 @@ module Saml
|
|
3
3
|
# This class represents the main configuration that is use for generating SAML documents.
|
4
4
|
#
|
5
5
|
# Saml::Kit::Configuration.new do |config|
|
6
|
-
# config.
|
6
|
+
# config.entity_id = "com:saml:kit"
|
7
7
|
# config.signature_method = :SHA256
|
8
8
|
# config.digest_method = :SHA256
|
9
9
|
# config.registry = Saml::Kit::DefaultRegistry.new
|
@@ -15,14 +15,14 @@ module Saml
|
|
15
15
|
# that runs at the start of the program.
|
16
16
|
#
|
17
17
|
# Saml::Kit.configure do |configuration|
|
18
|
-
# configuration.
|
18
|
+
# configuration.entity_id = "https://www.example.com/saml/metadata"
|
19
19
|
# configuration.generate_key_pair_for(use: :signing)
|
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
23
|
USES = [:signing, :encryption]
|
24
|
-
# The issuer or
|
25
|
-
attr_accessor :
|
24
|
+
# The issuer to use in requests or responses from this entity to use.
|
25
|
+
attr_accessor :entity_id
|
26
26
|
# The signature method to use when generating signatures (See {Saml::Kit::Builders::XmlSignature::SIGNATURE_METHODS})
|
27
27
|
attr_accessor :signature_method
|
28
28
|
# The digest method to use when generating signatures (See {Saml::Kit::Builders::XmlSignature::DIGEST_METHODS})
|
@@ -112,6 +112,18 @@ module Saml
|
|
112
112
|
certificates(use: :signing).any?
|
113
113
|
end
|
114
114
|
|
115
|
+
# @deprecated Use {#entity_id} instead of this method.
|
116
|
+
def issuer
|
117
|
+
Saml::Kit.deprecate("issuer is deprecated. Use entity_id instead")
|
118
|
+
self.entity_id
|
119
|
+
end
|
120
|
+
|
121
|
+
# @deprecated Use {#entity_id=} instead of this method.
|
122
|
+
def issuer=(value)
|
123
|
+
Saml::Kit.deprecate("issuer= is deprecated. Use entity_id= instead")
|
124
|
+
self.entity_id = value
|
125
|
+
end
|
126
|
+
|
115
127
|
private
|
116
128
|
|
117
129
|
def ensure_proper_use!(use)
|
@@ -22,7 +22,7 @@ module Saml
|
|
22
22
|
# end
|
23
23
|
#
|
24
24
|
# Saml::Kit.configure do |configuration|
|
25
|
-
# configuration.
|
25
|
+
# configuration.entity_id = ENV['ENTITY_ID']
|
26
26
|
# configuration.registry = OnDemandRegistry.new(configuration.registry)
|
27
27
|
# configuration.logger = Rails.logger
|
28
28
|
# end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'uri'
|
2
|
+
|
3
|
+
RSpec::Matchers.define :have_query_param do |key|
|
4
|
+
match do |url|
|
5
|
+
query_params_from(url)[key].present?
|
6
|
+
end
|
7
|
+
|
8
|
+
def query_params_from(url)
|
9
|
+
Hash[query_for(url).split("&").map { |x| x.split('=', 2) }]
|
10
|
+
end
|
11
|
+
|
12
|
+
def uri_for(url)
|
13
|
+
URI.parse(url)
|
14
|
+
end
|
15
|
+
|
16
|
+
def query_for(url)
|
17
|
+
uri_for(url).query
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
RSpec::Matchers.define :have_xpath do |xpath|
|
2
|
+
match do |actual|
|
3
|
+
namespaces = {
|
4
|
+
"NameFormat": Saml::Kit::Namespaces::ATTR_SPLAT,
|
5
|
+
"ds": ::Xml::Kit::Namespaces::XMLDSIG,
|
6
|
+
"md": Saml::Kit::Namespaces::METADATA,
|
7
|
+
"saml": Saml::Kit::Namespaces::ASSERTION,
|
8
|
+
"samlp": Saml::Kit::Namespaces::PROTOCOL,
|
9
|
+
}
|
10
|
+
xml_document(actual).xpath(xpath, namespaces).any?
|
11
|
+
end
|
12
|
+
|
13
|
+
failure_message do |actual|
|
14
|
+
"Expected xpath: #{xpath.inspect} to match in:\n #{xml_pretty_print(actual)}"
|
15
|
+
end
|
16
|
+
|
17
|
+
failure_message_when_negated do |actual|
|
18
|
+
"Expected xpath: #{xpath.inspect} not to match in:\n #{xml_pretty_print(actual)}"
|
19
|
+
end
|
20
|
+
|
21
|
+
def xml_pretty_print(raw_xml)
|
22
|
+
xml_document(raw_xml).to_xml(indent: 2)
|
23
|
+
end
|
24
|
+
|
25
|
+
def xml_document(raw_xml)
|
26
|
+
Nokogiri::XML(raw_xml)
|
27
|
+
end
|
28
|
+
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.6
|
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-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -145,6 +145,7 @@ files:
|
|
145
145
|
- exe/saml-kit-create-self-signed-certificate
|
146
146
|
- exe/saml-kit-decode-http-post
|
147
147
|
- exe/saml-kit-decode-http-redirect
|
148
|
+
- lib/saml-kit.rb
|
148
149
|
- lib/saml/kit.rb
|
149
150
|
- lib/saml/kit/assertion.rb
|
150
151
|
- lib/saml/kit/authentication_request.rb
|
@@ -187,6 +188,9 @@ files:
|
|
187
188
|
- lib/saml/kit/requestable.rb
|
188
189
|
- lib/saml/kit/respondable.rb
|
189
190
|
- lib/saml/kit/response.rb
|
191
|
+
- lib/saml/kit/rspec.rb
|
192
|
+
- lib/saml/kit/rspec/have_query_param.rb
|
193
|
+
- lib/saml/kit/rspec/have_xpath.rb
|
190
194
|
- lib/saml/kit/serializable.rb
|
191
195
|
- lib/saml/kit/service_provider_metadata.rb
|
192
196
|
- lib/saml/kit/signature.rb
|