saml-kit 0.3.5 → 0.3.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: aa6e4cc97ac1b952312da27f68858628cc913868c59184ace6d64b04369e045e
4
- data.tar.gz: e86e6d0a6551896ebaa627827d176f8d300b155811af1c27b42a963356f32589
3
+ metadata.gz: f94e30d77a2e999c93935934dccb12d6cb491924a2dae47f94a946a491ceb373
4
+ data.tar.gz: 4e2116c0e7b04010dff208231eaae5eaad02c02539d0d23235fe2effad457f68
5
5
  SHA512:
6
- metadata.gz: 91c05ab684c6e4da67e9a2b28d905d36c1e9edbe320879e61c9cc5fc79b8bdb8d0b7bae58c816aa6e2842521da524947183c6d65b6c55c32e5e052731f908f40
7
- data.tar.gz: 2a78ce0bd35526550ab46e8cc4070be57a46e4805ab02a41105ba35a222f7dc4e9db67137c036914a84ff1df80b87ecb46e35523f0ba15d47cbcf1da033ae38c
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.issuer = ENV['ISSUER']
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)
@@ -0,0 +1 @@
1
+ require 'saml/kit'
@@ -100,7 +100,7 @@ module Saml
100
100
  end
101
101
 
102
102
  def must_match_issuer
103
- unless audiences.include?(configuration.issuer)
103
+ unless audiences.include?(configuration.entity_id)
104
104
  errors[:audience] << error_message(:must_match_issuer)
105
105
  end
106
106
  end
@@ -4,12 +4,16 @@ module Saml
4
4
  extend ActiveSupport::Concern
5
5
 
6
6
  class_methods do
7
- def build(*args, &block) # :yields builder
8
- builder(*args, &block).build
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, &block) # :yields builder
12
- builder(*args, &block).to_xml
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.issuer
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.issuer
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.issuer
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.issuer
15
+ @issuer = configuration.entity_id
16
16
  @now = Time.now.utc
17
17
  @request = request
18
18
  @status_code = Namespaces::SUCCESS
@@ -15,7 +15,7 @@ module Saml
15
15
 
16
16
  def initialize(configuration: Saml::Kit.configuration)
17
17
  @id = ::Xml::Kit::Id.generate
18
- @entity_id = configuration.issuer
18
+ @entity_id = configuration.entity_id
19
19
  @configuration = configuration
20
20
  end
21
21
 
@@ -19,7 +19,7 @@ module Saml
19
19
  @now = Time.now.utc
20
20
  @version = "2.0"
21
21
  @status_code = Namespaces::SUCCESS
22
- @issuer = configuration.issuer
22
+ @issuer = configuration.entity_id
23
23
  @encrypt = encryption_certificate.present?
24
24
  @configuration = configuration
25
25
  end
@@ -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.issuer = "com:saml:kit"
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.issuer = "https://www.example.com/saml/metadata"
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 entity_id to use.
25
- attr_accessor :issuer
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.issuer = ENV['ISSUER']
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,2 @@
1
+ require 'saml/kit/rspec/have_query_param'
2
+ require 'saml/kit/rspec/have_xpath'
@@ -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
@@ -1,5 +1,5 @@
1
1
  module Saml
2
2
  module Kit
3
- VERSION = "0.3.5"
3
+ VERSION = "0.3.6"
4
4
  end
5
5
  end
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.5
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-13 00:00:00.000000000 Z
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