spid 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 11409a6db93f8bc29e6a8b0d6678e9c893441ad99fc67302667ad2493a0b0dc8
4
- data.tar.gz: 9e6e5c2c079bf2bc232e92fc7585b7f461614dc521de1eff92427a782d60e8ea
3
+ metadata.gz: ad2f25b0c8941611175ed84f131a2e25e0dd1d1b05169bbc8fd32b83314429e5
4
+ data.tar.gz: f4d37ffd19ac1076dfcb1adefee4cd62578a77f17653fd9c416b014726f9cdd7
5
5
  SHA512:
6
- metadata.gz: 015c7a6b37a8640123c3bb15df3aadfdc9ea21a76acc9ee5886191cdec2b3c95a013b1e8b5039efd0250351180c2f97c6e928161539f435353e985a555895ec3
7
- data.tar.gz: 52445d55b3bf64d28ee9caf601b7a1e3146df9721f87beafed2ecc63a6f46f41c45d7ae09deeef9d2bb0c00f857a972d4890f35fd0af889080d7055a957b5742
6
+ metadata.gz: a468176f451c2fdd3fda26b6e23e074d244bbab2976e6ee0dd414d40dfe63925b682a8f9bb059be0a43c53dea3d9d2dc03b4cb61e4bb3dede1b7c4d9991af331
7
+ data.tar.gz: 2e2bf9a6acf5b7a0dfd4d326b2abd79a72410e5dc520d06bf2e8540882f396c282cdcfd9bbc7980eeea9f3f9b38178f091212ed2f54fe6216f9a72dc86cf00a4
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [0.5.0] - 2018-07-13
6
+ ### Added
7
+ - Sso Settings with all saml settings required attributes
8
+
5
9
  ## [0.4.0] - 2018-07-13
6
10
  ### Added
7
11
  - ServiceProviderConfiguration class handles configuration for a specific host
@@ -44,7 +48,8 @@
44
48
  - Coveralls Integration
45
49
  - Rubygems version badge in README
46
50
 
47
- [Unreleased]: https://github.com/italia/spid-ruby/compare/v0.4.0...HEAD
51
+ [Unreleased]: https://github.com/italia/spid-ruby/compare/v0.5.0...HEAD
52
+ [0.5.0]: https://github.com/italia/spid-ruby/compare/v0.4.0...v0.5.0
48
53
  [0.4.0]: https://github.com/italia/spid-ruby/compare/v0.3.1...v0.4.0
49
54
  [0.3.1]: https://github.com/italia/spid-ruby/compare/v0.3.0...v0.3.1
50
55
  [0.3.0]: https://github.com/italia/spid-ruby/compare/v0.2.2...v0.3.0
@@ -9,6 +9,7 @@ require "spid/idp_metadata"
9
9
  require "spid/version"
10
10
  require "spid/identity_provider_configuration"
11
11
  require "spid/service_provider_configuration"
12
+ require "spid/sso_settings"
12
13
 
13
14
  module Spid # :nodoc:
14
15
  class UnknownAuthnComparisonMethodError < StandardError; end
@@ -5,86 +5,20 @@ require "onelogin/ruby-saml/settings"
5
5
 
6
6
  module Spid
7
7
  class SsoRequest # :nodoc:
8
- attr_reader :service_provider_configuration,
9
- :identity_provider_configuration,
10
- :authn_context,
11
- :authn_context_comparison
8
+ attr_reader :sso_settings
12
9
 
13
- # rubocop:disable Metrics/MethodLength
14
- def initialize(
15
- identity_provider_configuration:,
16
- service_provider_configuration:,
17
- authn_context: Spid::L1,
18
- authn_context_comparison: Spid::EXACT_COMPARISON
19
- )
20
-
21
- unless AUTHN_CONTEXTS.include?(authn_context)
22
- raise Spid::UnknownAuthnContextError,
23
- "Provided authn_context is not valid:" \
24
- " use one of #{AUTHN_CONTEXTS.join(', ')}"
25
- end
26
-
27
- unless COMPARISON_METHODS.include?(authn_context_comparison)
28
- raise Spid::UnknownAuthnComparisonMethodError,
29
- "Provided authn_context_comparison_method is not valid:" \
30
- " use one of #{COMPARISON_METHODS.join(', ')}"
31
- end
32
-
33
- @service_provider_configuration = service_provider_configuration
34
- @identity_provider_configuration = identity_provider_configuration
35
- @authn_context = authn_context
36
- @authn_context_comparison = authn_context_comparison
10
+ def initialize(sso_settings:)
11
+ @sso_settings = sso_settings
37
12
  end
38
- # rubocop:enable Metrics/MethodLength
39
13
 
40
14
  def to_saml
41
- authn_request.create(saml_settings)
15
+ authn_request.create(sso_settings)
42
16
  end
43
17
 
44
- # rubocop:disable Metrics/MethodLength
45
- # rubocop:disable Metrics/AbcSize
46
- def authn_request_attributes
47
- return @authn_request_attributes if @authn_request_attributes.present?
48
- @authn_request_attributes = {
49
- idp_sso_target_url: identity_provider_configuration.sso_target_url,
50
- assertion_consumer_service_url: service_provider_configuration.sso_url,
51
- protocol_binding: protocol_binding,
52
- issuer: service_provider_configuration.host,
53
- private_key: service_provider_configuration.private_key,
54
- certificate: service_provider_configuration.certificate,
55
- name_identifier_format: name_identifier_format,
56
- authn_context: authn_context,
57
- authn_context_comparison: authn_context_comparison,
58
- idp_cert_fingerprint: identity_provider_configuration.cert_fingerprint,
59
- security: {
60
- authn_requests_signed: true,
61
- embed_sign: true,
62
- digest_method: service_provider_configuration.digest_method,
63
- signature_method: service_provider_configuration.signature_method
64
- }
65
- }
66
- @authn_request_attributes[:force_authn] = true if authn_context > Spid::L1
67
- @authn_request_attributes
68
- end
69
- # rubocop:enable Metrics/AbcSize
70
- # rubocop:enable Metrics/MethodLength
18
+ private
71
19
 
72
20
  def authn_request
73
21
  AuthnRequest.new
74
22
  end
75
-
76
- def saml_settings
77
- ::OneLogin::RubySaml::Settings.new authn_request_attributes
78
- end
79
-
80
- private
81
-
82
- def protocol_binding
83
- "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"
84
- end
85
-
86
- def name_identifier_format
87
- "urn:oasis:names:tc:SAML:2.0:nameid-format:transient"
88
- end
89
23
  end
90
24
  end
@@ -0,0 +1,77 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Spid
4
+ class SsoSettings < ::OneLogin::RubySaml::Settings # :nodoc:
5
+ attr_reader :service_provider_configuration,
6
+ :identity_provider_configuration,
7
+ :authn_context,
8
+ :authn_context_comparison
9
+
10
+ # rubocop:disable Metrics/MethodLength
11
+ def initialize(
12
+ service_provider_configuration:,
13
+ identity_provider_configuration:,
14
+ authn_context: Spid::L1,
15
+ authn_context_comparison: Spid::EXACT_COMPARISON
16
+ )
17
+
18
+ unless AUTHN_CONTEXTS.include?(authn_context)
19
+ raise Spid::UnknownAuthnContextError,
20
+ "Provided authn_context is not valid:" \
21
+ " use one of #{AUTHN_CONTEXTS.join(', ')}"
22
+ end
23
+
24
+ unless COMPARISON_METHODS.include?(authn_context_comparison)
25
+ raise Spid::UnknownAuthnComparisonMethodError,
26
+ "Provided authn_context_comparison_method is not valid:" \
27
+ " use one of #{COMPARISON_METHODS.join(', ')}"
28
+ end
29
+
30
+ @service_provider_configuration = service_provider_configuration
31
+ @identity_provider_configuration = identity_provider_configuration
32
+ @authn_context = authn_context
33
+ @authn_context_comparison = authn_context_comparison
34
+
35
+ super(sso_attributes)
36
+ end
37
+ # rubocop:enable Metrics/MethodLength
38
+
39
+ # rubocop:disable Metrics/MethodLength
40
+ # rubocop:disable Metrics/AbcSize
41
+ def sso_attributes
42
+ return @sso_attributes if @sso_attributes.present?
43
+ @sso_attributes = {
44
+ idp_sso_target_url: identity_provider_configuration.sso_target_url,
45
+ assertion_consumer_service_url: service_provider_configuration.sso_url,
46
+ protocol_binding: protocol_binding_value,
47
+ issuer: service_provider_configuration.host,
48
+ private_key: service_provider_configuration.private_key,
49
+ certificate: service_provider_configuration.certificate,
50
+ name_identifier_format: name_identifier_format_value,
51
+ authn_context: authn_context,
52
+ authn_context_comparison: authn_context_comparison,
53
+ idp_cert_fingerprint: identity_provider_configuration.cert_fingerprint,
54
+ security: {
55
+ authn_requests_signed: true,
56
+ embed_sign: true,
57
+ digest_method: service_provider_configuration.digest_method,
58
+ signature_method: service_provider_configuration.signature_method
59
+ }
60
+ }
61
+ @sso_attributes[:force_authn] = true if authn_context > Spid::L1
62
+ @sso_attributes
63
+ end
64
+ # rubocop:enable Metrics/AbcSize
65
+ # rubocop:enable Metrics/MethodLength
66
+
67
+ private
68
+
69
+ def protocol_binding_value
70
+ "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"
71
+ end
72
+
73
+ def name_identifier_format_value
74
+ "urn:oasis:names:tc:SAML:2.0:nameid-format:transient"
75
+ end
76
+ end
77
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Spid
4
- VERSION = "0.4.0"
4
+ VERSION = "0.5.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Librera
@@ -285,6 +285,7 @@ files:
285
285
  - lib/spid/service_provider_configuration.rb
286
286
  - lib/spid/sso_request.rb
287
287
  - lib/spid/sso_response.rb
288
+ - lib/spid/sso_settings.rb
288
289
  - lib/spid/version.rb
289
290
  - spid.gemspec
290
291
  homepage: https://github.com/italia/spid-ruby