saml-kit 0.2.6 → 0.2.7
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.rb +1 -1
- data/lib/saml/kit/authentication_request.rb +1 -1
- data/lib/saml/kit/bindings/http_redirect.rb +1 -1
- data/lib/saml/kit/builders.rb +1 -0
- data/lib/saml/kit/builders/assertion.rb +1 -1
- data/lib/saml/kit/builders/identity_provider_metadata.rb +7 -2
- data/lib/saml/kit/builders/metadata.rb +50 -0
- data/lib/saml/kit/builders/response.rb +1 -1
- data/lib/saml/kit/builders/service_provider_metadata.rb +6 -4
- data/lib/saml/kit/builders/templates/identity_provider_metadata.builder +17 -28
- data/lib/saml/kit/builders/templates/metadata.builder +13 -0
- data/lib/saml/kit/builders/templates/service_provider_metadata.builder +14 -25
- data/lib/saml/kit/builders/xml_signature.rb +1 -1
- data/lib/saml/kit/identity_provider_metadata.rb +1 -1
- data/lib/saml/kit/metadata.rb +4 -0
- data/lib/saml/kit/templatable.rb +7 -2
- data/lib/saml/kit/version.rb +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '029d3a033d81aac8add1be06a783516f239b7b38cec4bb6e701e010c80b82e98'
|
4
|
+
data.tar.gz: a29f4fd46aa450d8392376cdb38fe2510575b7a51e1217987719f1828c1defbc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 694fe63f05d9b011d998f4c144faf75f9b852e63ad01badf522b23e654038c5d6655334a24b9c366d5920df0f01772fbfdf0190c5946cbca79a007b1a74eb64c
|
7
|
+
data.tar.gz: 4b497ec560bbd279cc957ee2765bd1e6f1ea48a591e54a58f434522984bcf0ebcf210e343b8a02ecc0e268d6d95221cd21138fb2b655b008203f0520cc8cebb4
|
data/lib/saml/kit.rb
CHANGED
@@ -18,7 +18,7 @@ module Saml
|
|
18
18
|
def response_for(user, binding:, relay_state: nil)
|
19
19
|
response_binding = provider.assertion_consumer_service_for(binding: binding)
|
20
20
|
builder = Saml::Kit::Response.builder(user, self) do |x|
|
21
|
-
x.
|
21
|
+
x.embed_signature = provider.want_assertions_signed
|
22
22
|
yield x if block_given?
|
23
23
|
end
|
24
24
|
response_binding.serialize(builder, relay_state: relay_state)
|
@@ -9,7 +9,7 @@ module Saml
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def serialize(builder, relay_state: nil)
|
12
|
-
builder.
|
12
|
+
builder.embed_signature = false
|
13
13
|
builder.destination = location
|
14
14
|
document = builder.build
|
15
15
|
[UrlBuilder.new(configuration: builder.configuration).build(document, relay_state: relay_state), {}]
|
data/lib/saml/kit/builders.rb
CHANGED
@@ -3,6 +3,7 @@ require 'saml/kit/builders/authentication_request'
|
|
3
3
|
require 'saml/kit/builders/identity_provider_metadata'
|
4
4
|
require 'saml/kit/builders/logout_request'
|
5
5
|
require 'saml/kit/builders/logout_response'
|
6
|
+
require 'saml/kit/builders/metadata'
|
6
7
|
require 'saml/kit/builders/response'
|
7
8
|
require 'saml/kit/builders/service_provider_metadata'
|
8
9
|
require 'saml/kit/builders/xml_encryption'
|
@@ -5,7 +5,7 @@ module Saml
|
|
5
5
|
include Templatable
|
6
6
|
extend Forwardable
|
7
7
|
|
8
|
-
def_delegators :@response_builder, :encrypt, :
|
8
|
+
def_delegators :@response_builder, :encrypt, :embed_signature, :request, :issuer, :reference_id, :now, :configuration, :user, :version, :destination, :encryption_certificate
|
9
9
|
|
10
10
|
def initialize(response_builder)
|
11
11
|
@response_builder = response_builder
|
@@ -3,10 +3,13 @@ module Saml
|
|
3
3
|
module Builders
|
4
4
|
class IdentityProviderMetadata
|
5
5
|
include Saml::Kit::Templatable
|
6
|
-
|
6
|
+
extend Forwardable
|
7
|
+
attr_accessor :attributes, :name_id_formats
|
7
8
|
attr_accessor :want_authn_requests_signed
|
8
9
|
attr_reader :logout_urls, :single_sign_on_urls
|
9
10
|
attr_reader :configuration
|
11
|
+
attr_reader :metadata
|
12
|
+
def_delegators :metadata, :id, :id=, :entity_id, :entity_id=, :organization_name, :organization_name=, :organization_url, :organization_url=, :contact_email, :contact_email=, :to_xml
|
10
13
|
|
11
14
|
def initialize(configuration: Saml::Kit.configuration)
|
12
15
|
@attributes = []
|
@@ -17,6 +20,8 @@ module Saml
|
|
17
20
|
@name_id_formats = [Namespaces::PERSISTENT]
|
18
21
|
@single_sign_on_urls = []
|
19
22
|
@want_authn_requests_signed = true
|
23
|
+
@metadata = Saml::Kit::Builders::Metadata.new(configuration: configuration)
|
24
|
+
@metadata.identity_provider = self
|
20
25
|
end
|
21
26
|
|
22
27
|
def add_single_sign_on_service(url, binding: :http_post)
|
@@ -43,7 +48,7 @@ module Saml
|
|
43
48
|
}
|
44
49
|
end
|
45
50
|
|
46
|
-
def
|
51
|
+
def descriptor_options
|
47
52
|
{
|
48
53
|
WantAuthnRequestsSigned: want_authn_requests_signed,
|
49
54
|
protocolSupportEnumeration: Namespaces::PROTOCOL,
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module Saml
|
2
|
+
module Kit
|
3
|
+
module Builders
|
4
|
+
class Metadata
|
5
|
+
include Templatable
|
6
|
+
|
7
|
+
attr_accessor :entity_id
|
8
|
+
attr_accessor :id
|
9
|
+
attr_accessor :identity_provider
|
10
|
+
attr_accessor :organization_name, :organization_url, :contact_email
|
11
|
+
attr_accessor :service_provider
|
12
|
+
attr_reader :configuration
|
13
|
+
|
14
|
+
def initialize(configuration: Saml::Kit.configuration)
|
15
|
+
@id = Id.generate
|
16
|
+
@entity_id = configuration.issuer
|
17
|
+
@configuration = configuration
|
18
|
+
end
|
19
|
+
|
20
|
+
def build_service_provider
|
21
|
+
@service_provider = Saml::Kit::ServiceProviderMetadata.builder(configuration: configuration) do |x|
|
22
|
+
yield x if block_given?
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def build_identity_provider
|
27
|
+
@identity_provider = Saml::Kit::IdentityProviderMetadata.builder(configuration: configuration) do |x|
|
28
|
+
yield x if block_given?
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def build
|
33
|
+
Saml::Kit::Metadata.from(to_xml)
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def entity_descriptor_options
|
39
|
+
{
|
40
|
+
'xmlns': Namespaces::METADATA,
|
41
|
+
'xmlns:ds': Namespaces::XMLDSIG,
|
42
|
+
'xmlns:saml': Namespaces::ASSERTION,
|
43
|
+
ID: id,
|
44
|
+
entityID: entity_id,
|
45
|
+
}
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -18,7 +18,7 @@ module Saml
|
|
18
18
|
@version = "2.0"
|
19
19
|
@status_code = Namespaces::SUCCESS
|
20
20
|
@issuer = configuration.issuer
|
21
|
-
@
|
21
|
+
@embed_signature = want_assertions_signed
|
22
22
|
@encrypt = encryption_certificate.present?
|
23
23
|
@configuration = configuration
|
24
24
|
end
|
@@ -3,19 +3,21 @@ module Saml
|
|
3
3
|
module Builders
|
4
4
|
class ServiceProviderMetadata
|
5
5
|
include Saml::Kit::Templatable
|
6
|
-
|
7
|
-
attr_accessor :
|
6
|
+
extend Forwardable
|
7
|
+
attr_accessor :acs_urls, :logout_urls, :name_id_formats
|
8
8
|
attr_accessor :want_assertions_signed
|
9
9
|
attr_reader :configuration
|
10
|
+
attr_reader :metadata
|
11
|
+
def_delegators :metadata, :id, :id=, :entity_id, :entity_id=, :organization_name, :organization_name=, :organization_url, :organization_url=, :contact_email, :contact_email=, :to_xml
|
10
12
|
|
11
13
|
def initialize(configuration: Saml::Kit.configuration)
|
12
14
|
@acs_urls = []
|
13
15
|
@configuration = configuration
|
14
|
-
@entity_id = configuration.issuer
|
15
|
-
@id = Id.generate
|
16
16
|
@logout_urls = []
|
17
17
|
@name_id_formats = [Namespaces::PERSISTENT]
|
18
18
|
@want_assertions_signed = true
|
19
|
+
@metadata = Saml::Kit::Builders::Metadata.new(configuration: configuration)
|
20
|
+
@metadata.service_provider = self
|
19
21
|
end
|
20
22
|
|
21
23
|
def add_assertion_consumer_service(url, binding: :http_post)
|
@@ -1,32 +1,21 @@
|
|
1
|
-
xml
|
2
|
-
xml.
|
3
|
-
|
4
|
-
|
5
|
-
configuration.certificates(use: :signing).each do |certificate|
|
6
|
-
render certificate, xml: xml
|
7
|
-
end
|
8
|
-
configuration.certificates(use: :encryption).each do |certificate|
|
9
|
-
render certificate, xml: xml
|
10
|
-
end
|
11
|
-
logout_urls.each do |item|
|
12
|
-
xml.SingleLogoutService Binding: item[:binding], Location: item[:location]
|
13
|
-
end
|
14
|
-
name_id_formats.each do |format|
|
15
|
-
xml.NameIDFormat format
|
16
|
-
end
|
17
|
-
single_sign_on_urls.each do |item|
|
18
|
-
xml.SingleSignOnService Binding: item[:binding], Location: item[:location]
|
19
|
-
end
|
20
|
-
attributes.each do |attribute|
|
21
|
-
xml.tag! 'saml:Attribute', Name: attribute
|
22
|
-
end
|
1
|
+
signature_for(reference_id: id, xml: xml)
|
2
|
+
xml.IDPSSODescriptor descriptor_options do
|
3
|
+
configuration.certificates(use: :signing).each do |certificate|
|
4
|
+
render certificate, xml: xml
|
23
5
|
end
|
24
|
-
|
25
|
-
|
26
|
-
xml.OrganizationDisplayName organization_name, 'xml:lang': "en"
|
27
|
-
xml.OrganizationURL organization_url, 'xml:lang': "en"
|
6
|
+
configuration.certificates(use: :encryption).each do |certificate|
|
7
|
+
render certificate, xml: xml
|
28
8
|
end
|
29
|
-
|
30
|
-
xml.
|
9
|
+
logout_urls.each do |item|
|
10
|
+
xml.SingleLogoutService Binding: item[:binding], Location: item[:location]
|
11
|
+
end
|
12
|
+
name_id_formats.each do |format|
|
13
|
+
xml.NameIDFormat format
|
14
|
+
end
|
15
|
+
single_sign_on_urls.each do |item|
|
16
|
+
xml.SingleSignOnService Binding: item[:binding], Location: item[:location]
|
17
|
+
end
|
18
|
+
attributes.each do |attribute|
|
19
|
+
xml.tag! 'saml:Attribute', Name: attribute
|
31
20
|
end
|
32
21
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
xml.instruct!
|
2
|
+
xml.EntityDescriptor entity_descriptor_options do
|
3
|
+
render identity_provider, xml: xml
|
4
|
+
render service_provider, xml: xml
|
5
|
+
xml.Organization do
|
6
|
+
xml.OrganizationName organization_name, 'xml:lang': "en"
|
7
|
+
xml.OrganizationDisplayName organization_name, 'xml:lang': "en"
|
8
|
+
xml.OrganizationURL organization_url, 'xml:lang': "en"
|
9
|
+
end
|
10
|
+
xml.ContactPerson contactType: "technical" do
|
11
|
+
xml.Company "mailto:#{contact_email}"
|
12
|
+
end
|
13
|
+
end
|
@@ -1,29 +1,18 @@
|
|
1
|
-
xml
|
2
|
-
xml.
|
3
|
-
|
4
|
-
|
5
|
-
configuration.certificates(use: :signing).each do |certificate|
|
6
|
-
render certificate, xml: xml
|
7
|
-
end
|
8
|
-
configuration.certificates(use: :encryption).each do |certificate|
|
9
|
-
render certificate, xml: xml
|
10
|
-
end
|
11
|
-
logout_urls.each do |item|
|
12
|
-
xml.SingleLogoutService Binding: item[:binding], Location: item[:location]
|
13
|
-
end
|
14
|
-
name_id_formats.each do |format|
|
15
|
-
xml.NameIDFormat format
|
16
|
-
end
|
17
|
-
acs_urls.each_with_index do |item, index|
|
18
|
-
xml.AssertionConsumerService Binding: item[:binding], Location: item[:location], index: index, isDefault: index == 0 ? true : false
|
19
|
-
end
|
1
|
+
signature_for(reference_id: id, xml: xml)
|
2
|
+
xml.SPSSODescriptor descriptor_options do
|
3
|
+
configuration.certificates(use: :signing).each do |certificate|
|
4
|
+
render certificate, xml: xml
|
20
5
|
end
|
21
|
-
|
22
|
-
|
23
|
-
xml.OrganizationDisplayName organization_name, 'xml:lang': "en"
|
24
|
-
xml.OrganizationURL organization_url, 'xml:lang': "en"
|
6
|
+
configuration.certificates(use: :encryption).each do |certificate|
|
7
|
+
render certificate, xml: xml
|
25
8
|
end
|
26
|
-
|
27
|
-
xml.
|
9
|
+
logout_urls.each do |item|
|
10
|
+
xml.SingleLogoutService Binding: item[:binding], Location: item[:location]
|
11
|
+
end
|
12
|
+
name_id_formats.each do |format|
|
13
|
+
xml.NameIDFormat format
|
14
|
+
end
|
15
|
+
acs_urls.each_with_index do |item, index|
|
16
|
+
xml.AssertionConsumerService Binding: item[:binding], Location: item[:location], index: index, isDefault: index == 0 ? true : false
|
28
17
|
end
|
29
18
|
end
|
@@ -31,7 +31,7 @@ module Saml
|
|
31
31
|
|
32
32
|
def login_request_for(binding:, relay_state: nil)
|
33
33
|
builder = Saml::Kit::AuthenticationRequest.builder do |x|
|
34
|
-
x.
|
34
|
+
x.embed_signature = want_authn_requests_signed
|
35
35
|
yield x if block_given?
|
36
36
|
end
|
37
37
|
request_binding = single_sign_on_service_for(binding: binding)
|
data/lib/saml/kit/metadata.rb
CHANGED
data/lib/saml/kit/templatable.rb
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
module Saml
|
2
2
|
module Kit
|
3
3
|
module Templatable
|
4
|
-
attr_accessor :
|
4
|
+
attr_accessor :embed_signature
|
5
|
+
|
6
|
+
def sign=(value)
|
7
|
+
Saml::Kit.deprecate("sign= is deprecated. Use embed_signature= instead")
|
8
|
+
self.embed_signature = value
|
9
|
+
end
|
5
10
|
|
6
11
|
def to_xml(xml: ::Builder::XmlMarkup.new)
|
7
12
|
signatures.complete(render(self, xml: xml))
|
@@ -13,7 +18,7 @@ module Saml
|
|
13
18
|
end
|
14
19
|
|
15
20
|
def sign?
|
16
|
-
|
21
|
+
embed_signature.nil? ? configuration.sign? : embed_signature && configuration.sign?
|
17
22
|
end
|
18
23
|
|
19
24
|
def signatures
|
data/lib/saml/kit/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: saml-kit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- mo khan
|
@@ -202,6 +202,7 @@ files:
|
|
202
202
|
- lib/saml/kit/builders/identity_provider_metadata.rb
|
203
203
|
- lib/saml/kit/builders/logout_request.rb
|
204
204
|
- lib/saml/kit/builders/logout_response.rb
|
205
|
+
- lib/saml/kit/builders/metadata.rb
|
205
206
|
- lib/saml/kit/builders/response.rb
|
206
207
|
- lib/saml/kit/builders/service_provider_metadata.rb
|
207
208
|
- lib/saml/kit/builders/templates/assertion.builder
|
@@ -210,6 +211,7 @@ files:
|
|
210
211
|
- lib/saml/kit/builders/templates/identity_provider_metadata.builder
|
211
212
|
- lib/saml/kit/builders/templates/logout_request.builder
|
212
213
|
- lib/saml/kit/builders/templates/logout_response.builder
|
214
|
+
- lib/saml/kit/builders/templates/metadata.builder
|
213
215
|
- lib/saml/kit/builders/templates/nil_class.builder
|
214
216
|
- lib/saml/kit/builders/templates/response.builder
|
215
217
|
- lib/saml/kit/builders/templates/service_provider_metadata.builder
|