spid 0.10.0 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,107 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "uri"
4
-
5
- module Spid
6
- class ServiceProvider # :nodoc:
7
- attr_reader :host
8
- attr_reader :acs_path
9
- attr_reader :slo_path
10
- attr_reader :metadata_path
11
- attr_reader :private_key
12
- attr_reader :certificate
13
- attr_reader :digest_method
14
- attr_reader :signature_method
15
- attr_reader :attribute_service_name
16
-
17
- # rubocop:disable Metrics/ParameterLists
18
- def initialize(
19
- host:,
20
- acs_path:,
21
- slo_path:,
22
- metadata_path:,
23
- private_key:,
24
- certificate:,
25
- digest_method:,
26
- signature_method:,
27
- attribute_service_name:
28
- )
29
- @host = host
30
- @acs_path = acs_path
31
- @slo_path = slo_path
32
- @metadata_path = metadata_path
33
- @private_key = private_key
34
- @certificate = certificate
35
- @digest_method = digest_method
36
- @signature_method = signature_method
37
- @attribute_service_name = attribute_service_name
38
- validate_attributes
39
- end
40
- # rubocop:enable Metrics/ParameterLists
41
-
42
- def acs_url
43
- @acs_url ||= URI.join(host, acs_path).to_s
44
- end
45
-
46
- def slo_url
47
- @slo_url ||= URI.join(host, slo_path).to_s
48
- end
49
-
50
- def metadata_url
51
- @metadata_url ||= URI.join(host, metadata_path).to_s
52
- end
53
-
54
- # rubocop:disable Metrics/MethodLength
55
- def sso_attributes
56
- @sso_attributes ||=
57
- begin
58
- {
59
- assertion_consumer_service_url: acs_url,
60
- issuer: host,
61
- private_key: private_key,
62
- certificate: certificate,
63
- security: {
64
- authn_requests_signed: true,
65
- embed_sign: false,
66
- digest_method: digest_method,
67
- signature_method: signature_method
68
- }
69
- }
70
- end
71
- end
72
- # rubocop:enable Metrics/MethodLength
73
-
74
- # rubocop:disable Metrics/MethodLength
75
- def slo_attributes
76
- @slo_attributes ||=
77
- begin
78
- {
79
- issuer: host,
80
- private_key: private_key,
81
- certificate: certificate,
82
- security: {
83
- logout_requests_signed: true,
84
- embed_sign: false,
85
- digest_method: digest_method,
86
- signature_method: signature_method
87
- }
88
- }
89
- end
90
- end
91
- # rubocop:enable Metrics/MethodLength
92
-
93
- private
94
-
95
- def validate_attributes
96
- if !DIGEST_METHODS.include?(digest_method)
97
- raise UnknownDigestMethodError,
98
- "Provided digest method is not valid:" \
99
- " use one of #{DIGEST_METHODS.join(', ')}"
100
- elsif !SIGNATURE_METHODS.include?(signature_method)
101
- raise UnknownSignatureMethodError,
102
- "Provided digest method is not valid:" \
103
- " use one of #{SIGNATURE_METHODS.join(', ')}"
104
- end
105
- end
106
- end
107
- end
@@ -1,53 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "onelogin/ruby-saml/settings"
4
-
5
- module Spid
6
- module Slo
7
- class Settings # :nodoc:
8
- attr_reader :service_provider
9
- attr_reader :identity_provider
10
- attr_reader :session_index
11
-
12
- def initialize(
13
- service_provider:,
14
- identity_provider:,
15
- session_index:
16
- )
17
- @service_provider = service_provider
18
- @identity_provider = identity_provider
19
- @session_index = session_index
20
- end
21
-
22
- def saml_settings
23
- ::OneLogin::RubySaml::Settings.new(slo_attributes)
24
- end
25
-
26
- def slo_attributes
27
- [
28
- service_provider.slo_attributes,
29
- identity_provider.slo_attributes,
30
- inner_slo_attributes
31
- ].inject(:merge)
32
- end
33
-
34
- def inner_slo_attributes
35
- {
36
- name_identifier_value: generated_name_identifier_value,
37
- name_identifier_format: name_identifier_format_value,
38
- sessionindex: session_index
39
- }
40
- end
41
-
42
- private
43
-
44
- def generated_name_identifier_value
45
- ::OneLogin::RubySaml::Utils.uuid
46
- end
47
-
48
- def name_identifier_format_value
49
- "urn:oasis:names:tc:SAML:2.0:nameid-format:transient"
50
- end
51
- end
52
- end
53
- end
@@ -1,62 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Spid
4
- module Sso
5
- class Settings # :nodoc:
6
- attr_reader :service_provider
7
- attr_reader :identity_provider
8
- attr_reader :authn_context
9
-
10
- def initialize(
11
- service_provider:,
12
- identity_provider:,
13
- authn_context: Spid::L1
14
- )
15
-
16
- unless AUTHN_CONTEXTS.include?(authn_context)
17
- raise Spid::UnknownAuthnContextError,
18
- "Provided authn_context is not valid:" \
19
- " use one of #{AUTHN_CONTEXTS.join(', ')}"
20
- end
21
-
22
- @service_provider = service_provider
23
- @identity_provider = identity_provider
24
- @authn_context = authn_context
25
- end
26
-
27
- def saml_settings
28
- ::OneLogin::RubySaml::Settings.new(sso_attributes)
29
- end
30
-
31
- def sso_attributes
32
- [
33
- service_provider.sso_attributes,
34
- identity_provider.sso_attributes,
35
- inner_sso_attributes,
36
- force_authn_attributes
37
- ].inject(:merge)
38
- end
39
-
40
- def inner_sso_attributes
41
- {
42
- protocol_binding: protocol_binding_value,
43
- authn_context: authn_context,
44
- authn_context_comparison: Spid::MINIMUM_COMPARISON
45
- }
46
- end
47
-
48
- def force_authn_attributes
49
- return {} if authn_context <= Spid::L1
50
- {
51
- force_authn: true
52
- }
53
- end
54
-
55
- private
56
-
57
- def protocol_binding_value
58
- "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"
59
- end
60
- end
61
- end
62
- end