saml_idp 0.9.0 → 0.14.0
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 +4 -4
- data/README.md +39 -45
- data/lib/saml_idp.rb +2 -1
- data/lib/saml_idp/assertion_builder.rb +28 -3
- data/lib/saml_idp/configurator.rb +4 -1
- data/lib/saml_idp/controller.rb +11 -9
- data/lib/saml_idp/encryptor.rb +0 -1
- data/lib/saml_idp/fingerprint.rb +19 -0
- data/lib/saml_idp/incoming_metadata.rb +13 -0
- data/lib/saml_idp/metadata_builder.rb +23 -8
- data/lib/saml_idp/persisted_metadata.rb +4 -0
- data/lib/saml_idp/request.rb +9 -3
- data/lib/saml_idp/response_builder.rb +19 -5
- data/lib/saml_idp/saml_response.rb +37 -16
- data/lib/saml_idp/service_provider.rb +1 -6
- data/lib/saml_idp/signable.rb +1 -2
- data/lib/saml_idp/version.rb +1 -1
- data/saml_idp.gemspec +8 -8
- data/spec/lib/saml_idp/assertion_builder_spec.rb +73 -0
- data/spec/lib/saml_idp/configurator_spec.rb +1 -0
- data/spec/lib/saml_idp/controller_spec.rb +24 -0
- data/spec/lib/saml_idp/fingerprint_spec.rb +14 -0
- data/spec/lib/saml_idp/incoming_metadata_spec.rb +15 -1
- data/spec/lib/saml_idp/metadata_builder_spec.rb +23 -0
- data/spec/lib/saml_idp/response_builder_spec.rb +3 -1
- data/spec/lib/saml_idp/saml_response_spec.rb +25 -2
- data/spec/rails_app/app/controllers/saml_controller.rb +1 -5
- data/spec/rails_app/app/controllers/saml_idp_controller.rb +47 -8
- data/{app → spec/rails_app/app}/views/saml_idp/idp/new.html.erb +1 -5
- data/{app → spec/rails_app/app}/views/saml_idp/idp/saml_post.html.erb +1 -1
- data/spec/rails_app/config/environments/development.rb +2 -0
- data/spec/spec_helper.rb +20 -1
- data/spec/support/certificates/sp_cert_req.csr +12 -0
- data/spec/support/certificates/sp_private_key.pem +16 -0
- data/spec/support/certificates/sp_x509_cert.crt +18 -0
- data/spec/support/saml_request_macros.rb +62 -3
- data/spec/support/security_helpers.rb +10 -0
- metadata +51 -28
- data/app/controllers/saml_idp/idp_controller.rb +0 -59
@@ -6,12 +6,14 @@ module SamlIdp
|
|
6
6
|
let(:saml_acs_url) { "http://sportngin.com" }
|
7
7
|
let(:saml_request_id) { "134" }
|
8
8
|
let(:assertion_and_signature) { "<Assertion xmlns=\"urn:oasis:names:tc:SAML:2.0:assertion\" ID=\"_abc\" IssueInstant=\"2013-07-31T05:00:00Z\" Version=\"2.0\"><Issuer>http://sportngin.com</Issuer><signature>stuff</signature><Subject><NameID Format=\"urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress\">jon.phenow@sportngin.com</NameID><SubjectConfirmation Method=\"urn:oasis:names:tc:SAML:2.0:cm:bearer\"><SubjectConfirmationData InResponseTo=\"123\" NotOnOrAfter=\"2013-07-31T05:03:00Z\" Recipient=\"http://saml.acs.url\"/></SubjectConfirmation></Subject><Conditions NotBefore=\"2013-07-31T04:59:55Z\" NotOnOrAfter=\"2013-07-31T06:00:00Z\"><AudienceRestriction><Audience>http://example.com</Audience></AudienceRestriction></Conditions><AttributeStatement><Attribute Name=\"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress\"><AttributeValue>jon.phenow@sportngin.com</AttributeValue></Attribute></AttributeStatement><AuthnStatment AuthnInstant=\"2013-07-31T05:00:00Z\" SessionIndex=\"_abc\"><AuthnContext><AuthnContextClassRef>urn:federation:authentication:windows</AuthnContextClassRef></AuthnContext></AuthnStatment></Assertion>" }
|
9
|
+
let(:algorithm) { :sha256 }
|
9
10
|
subject { described_class.new(
|
10
11
|
response_id,
|
11
12
|
issuer_uri,
|
12
13
|
saml_acs_url,
|
13
14
|
saml_request_id,
|
14
|
-
assertion_and_signature
|
15
|
+
assertion_and_signature,
|
16
|
+
algorithm
|
15
17
|
) }
|
16
18
|
|
17
19
|
before do
|
@@ -24,6 +24,8 @@ module SamlIdp
|
|
24
24
|
key_transport: 'rsa-oaep-mgf1p',
|
25
25
|
}
|
26
26
|
end
|
27
|
+
let(:signed_response_opts) { true }
|
28
|
+
let(:unsigned_response_opts) { false }
|
27
29
|
let(:subject_encrypted) { described_class.new(reference_id,
|
28
30
|
response_id,
|
29
31
|
issuer_uri,
|
@@ -35,7 +37,8 @@ module SamlIdp
|
|
35
37
|
authn_context_classref,
|
36
38
|
expiry,
|
37
39
|
encryption_opts,
|
38
|
-
session_expiry
|
40
|
+
session_expiry,
|
41
|
+
unsigned_response_opts
|
39
42
|
)
|
40
43
|
}
|
41
44
|
|
@@ -50,7 +53,8 @@ module SamlIdp
|
|
50
53
|
authn_context_classref,
|
51
54
|
expiry,
|
52
55
|
nil,
|
53
|
-
session_expiry
|
56
|
+
session_expiry,
|
57
|
+
signed_response_opts
|
54
58
|
)
|
55
59
|
}
|
56
60
|
|
@@ -77,6 +81,25 @@ module SamlIdp
|
|
77
81
|
expect(saml_resp.is_valid?).to eq(true)
|
78
82
|
end
|
79
83
|
|
84
|
+
it "will build signed valid response" do
|
85
|
+
expect { subject.build }.not_to raise_error
|
86
|
+
signed_encoded_xml = subject.build
|
87
|
+
resp_settings = saml_settings(saml_acs_url)
|
88
|
+
resp_settings.private_key = Default::SECRET_KEY
|
89
|
+
resp_settings.issuer = audience_uri
|
90
|
+
saml_resp = OneLogin::RubySaml::Response.new(signed_encoded_xml, settings: resp_settings)
|
91
|
+
expect(
|
92
|
+
Nokogiri::XML(saml_resp.response).at_xpath(
|
93
|
+
"//p:Response//ds:Signature",
|
94
|
+
{
|
95
|
+
"p" => "urn:oasis:names:tc:SAML:2.0:protocol",
|
96
|
+
"ds" => "http://www.w3.org/2000/09/xmldsig#"
|
97
|
+
}
|
98
|
+
)).to be_present
|
99
|
+
expect(saml_resp.send(:validate_signature)).to eq(true)
|
100
|
+
expect(saml_resp.is_valid?).to eq(true)
|
101
|
+
end
|
102
|
+
|
80
103
|
it "sets session expiration" do
|
81
104
|
saml_resp = OneLogin::RubySaml::Response.new(subject.build)
|
82
105
|
expect(saml_resp.session_expires_at).to eq Time.local(1990, "jan", 2).iso8601
|
@@ -2,11 +2,7 @@ class SamlController < ApplicationController
|
|
2
2
|
|
3
3
|
def consume
|
4
4
|
response = OneLogin::RubySaml::Response.new(params[:SAMLResponse])
|
5
|
-
|
6
|
-
render :text => response.name_id
|
7
|
-
else
|
8
|
-
render :plain => response.name_id
|
9
|
-
end
|
5
|
+
render :plain => response.name_id
|
10
6
|
end
|
11
7
|
|
12
8
|
end
|
@@ -1,9 +1,48 @@
|
|
1
|
-
class SamlIdpController <
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
1
|
+
class SamlIdpController < ApplicationController
|
2
|
+
include SamlIdp::Controller
|
3
|
+
|
4
|
+
before_action :validate_saml_request, only: [:new, :create, :logout]
|
5
|
+
|
6
|
+
def new
|
7
|
+
render template: "saml_idp/idp/new"
|
8
|
+
end
|
9
|
+
|
10
|
+
def show
|
11
|
+
render xml: SamlIdp.metadata.signed
|
12
|
+
end
|
13
|
+
|
14
|
+
def create
|
15
|
+
unless params[:email].blank? && params[:password].blank?
|
16
|
+
person = idp_authenticate(params[:email], params[:password])
|
17
|
+
if person.nil?
|
18
|
+
@saml_idp_fail_msg = "Incorrect email or password."
|
19
|
+
else
|
20
|
+
@saml_response = idp_make_saml_response(person)
|
21
|
+
render :template => "saml_idp/idp/saml_post", :layout => false
|
22
|
+
return
|
23
|
+
end
|
24
|
+
end
|
25
|
+
render :template => "saml_idp/idp/new"
|
26
|
+
end
|
27
|
+
|
28
|
+
def logout
|
29
|
+
idp_logout
|
30
|
+
@saml_response = idp_make_saml_response(nil)
|
31
|
+
render :template => "saml_idp/idp/saml_post", :layout => false
|
32
|
+
end
|
33
|
+
|
34
|
+
def idp_logout
|
35
|
+
raise NotImplementedError
|
36
|
+
end
|
37
|
+
private :idp_logout
|
38
|
+
|
39
|
+
def idp_authenticate(email, password)
|
40
|
+
{ :email => email }
|
41
|
+
end
|
42
|
+
protected :idp_authenticate
|
43
|
+
|
44
|
+
def idp_make_saml_response(person)
|
45
|
+
encode_response(person[:email])
|
46
|
+
end
|
47
|
+
protected :idp_make_saml_response
|
9
48
|
end
|
@@ -1,22 +1,18 @@
|
|
1
1
|
<% if @saml_idp_fail_msg %>
|
2
2
|
<div id="saml_idp_fail_msg" class="flash error"><%= @saml_idp_fail_msg %></div>
|
3
3
|
<% end %>
|
4
|
-
|
5
4
|
<%= form_tag do %>
|
6
5
|
<%= hidden_field_tag("SAMLRequest", params[:SAMLRequest]) %>
|
7
6
|
<%= hidden_field_tag("RelayState", params[:RelayState]) %>
|
8
|
-
|
9
7
|
<p>
|
10
8
|
<%= label_tag :email %>
|
11
9
|
<%= email_field_tag :email, params[:email], :autocapitalize => "off", :autocorrect => "off", :autofocus => "autofocus", :spellcheck => "false", :size => 30, :class => "email_pwd txt" %>
|
12
10
|
</p>
|
13
|
-
|
14
11
|
<p>
|
15
12
|
<%= label_tag :password %>
|
16
13
|
<%= password_field_tag :password, params[:password], :autocapitalize => "off", :autocorrect => "off", :spellcheck => "false", :size => 30, :class => "email_pwd txt" %>
|
17
14
|
</p>
|
18
|
-
|
19
15
|
<p>
|
20
16
|
<%= submit_tag "Sign in", :class => "button big blueish" %>
|
21
17
|
</p>
|
22
|
-
<% end %>
|
18
|
+
<% end %>
|
@@ -29,4 +29,6 @@ RailsApp::Application.configure do
|
|
29
29
|
# Log the query plan for queries taking more than this (works
|
30
30
|
# with SQLite, MySQL, and PostgreSQL)
|
31
31
|
#config.active_record.auto_explain_threshold_in_seconds = 0.5
|
32
|
+
|
33
|
+
config.hosts << "foo.example.com" if config.respond_to?(:hosts)
|
32
34
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -43,9 +43,28 @@ RSpec.configure do |config|
|
|
43
43
|
}
|
44
44
|
end
|
45
45
|
end
|
46
|
+
|
47
|
+
# To reset to default config
|
48
|
+
config.after do
|
49
|
+
SamlIdp.instance_variable_set(:@config, nil)
|
50
|
+
SamlIdp.configure do |c|
|
51
|
+
c.attributes = {
|
52
|
+
emailAddress: {
|
53
|
+
name: "email-address",
|
54
|
+
getter: ->(p) { "foo@example.com" }
|
55
|
+
}
|
56
|
+
}
|
57
|
+
|
58
|
+
c.name_id.formats = {
|
59
|
+
"1.1" => {
|
60
|
+
email_address: ->(p) { "foo@example.com" }
|
61
|
+
}
|
62
|
+
}
|
63
|
+
end
|
64
|
+
end
|
46
65
|
end
|
47
66
|
|
48
67
|
SamlIdp::Default::SERVICE_PROVIDER[:metadata_url] = 'https://example.com/meta'
|
49
68
|
SamlIdp::Default::SERVICE_PROVIDER[:response_hosts] = ['foo.example.com']
|
50
69
|
SamlIdp::Default::SERVICE_PROVIDER[:assertion_consumer_logout_service_url] = 'https://foo.example.com/saml/logout'
|
51
|
-
Capybara.default_host = "https://
|
70
|
+
Capybara.default_host = "https://foo.example.com"
|
@@ -0,0 +1,12 @@
|
|
1
|
+
-----BEGIN CERTIFICATE REQUEST-----
|
2
|
+
MIIByTCCATICAQAwgYgxCzAJBgNVBAYTAmpwMQ4wDAYDVQQIDAVUb2t5bzELMAkG
|
3
|
+
A1UECgwCR1MxIDAeBgNVBAMMF2h0dHBzOi8vZm9vLmV4YW1wbGUuY29tMQwwCgYD
|
4
|
+
VQQHDANGb28xDDAKBgNVBAsMA0JvbzEeMBwGCSqGSIb3DQEJARYPZm9vQGV4YW1w
|
5
|
+
bGUuY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC8DVj2mVLQV7AjT+cn
|
6
|
+
Lv3kDnQFvAo3RdUeGGhplsYFacYByzNRD/jeguu1ahrvznDyZN8p3yB7OPbmt0r0
|
7
|
+
aGr+yYzPh6brgkf5u6FMtWTj94vLQuT/uyQGuzdBkiLb5mAWRMtm43oHXDK0v25J
|
8
|
+
tsG1PJnntkXfBDpFP1eWLO+jZwIDAQABoAAwDQYJKoZIhvcNAQENBQADgYEAd/J6
|
9
|
+
5zjrMhg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13
|
+
awGbKA37vVnw+zAfBgNVHSMEGDAWgBQMtOtrh2VS/mh4awGbKA37vVnw+zAMBgNV
|
14
|
+
HRMEBTADAQH/MA0GCSqGSIb3DQEBDQUAA4GBAHjTTm4Hyx1rfzygknc6q1dYwpEv
|
15
|
+
/3AsPiTnF4AfH/5kGIIXNzwg0ADsziFMJYRRR9eMu97CHQbr8gHt99P8uaen6cmJ
|
16
|
+
4VCwJLP2N8gZrycssimA3M83DWRRVZbxZhpuUWNajtYIxwyUbB7eRSJgz3Tc0opF
|
17
|
+
933YwucWuFzKSqn3
|
18
|
+
-----END CERTIFICATE-----
|
@@ -1,9 +1,9 @@
|
|
1
1
|
require 'saml_idp/logout_request_builder'
|
2
2
|
|
3
3
|
module SamlRequestMacros
|
4
|
-
def make_saml_request(requested_saml_acs_url = "https://foo.example.com/saml/consume")
|
4
|
+
def make_saml_request(requested_saml_acs_url = "https://foo.example.com/saml/consume", enable_secure_options = false)
|
5
5
|
auth_request = OneLogin::RubySaml::Authrequest.new
|
6
|
-
auth_url = auth_request.create(saml_settings(requested_saml_acs_url))
|
6
|
+
auth_url = auth_request.create(saml_settings(requested_saml_acs_url, enable_secure_options))
|
7
7
|
CGI.unescape(auth_url.split("=").last)
|
8
8
|
end
|
9
9
|
|
@@ -18,7 +18,12 @@ module SamlRequestMacros
|
|
18
18
|
Base64.strict_encode64(request_builder.signed)
|
19
19
|
end
|
20
20
|
|
21
|
-
def
|
21
|
+
def generate_sp_metadata(saml_acs_url = "https://foo.example.com/saml/consume", enable_secure_options = false)
|
22
|
+
sp_metadata = OneLogin::RubySaml::Metadata.new
|
23
|
+
sp_metadata.generate(saml_settings(saml_acs_url, enable_secure_options), true)
|
24
|
+
end
|
25
|
+
|
26
|
+
def saml_settings(saml_acs_url = "https://foo.example.com/saml/consume", enable_secure_options = false)
|
22
27
|
settings = OneLogin::RubySaml::Settings.new
|
23
28
|
settings.assertion_consumer_service_url = saml_acs_url
|
24
29
|
settings.issuer = "http://example.com/issuer"
|
@@ -26,9 +31,63 @@ module SamlRequestMacros
|
|
26
31
|
settings.assertion_consumer_logout_service_url = 'https://foo.example.com/saml/logout'
|
27
32
|
settings.idp_cert_fingerprint = SamlIdp::Default::FINGERPRINT
|
28
33
|
settings.name_identifier_format = SamlIdp::Default::NAME_ID_FORMAT
|
34
|
+
add_securty_options(settings) if enable_secure_options
|
29
35
|
settings
|
30
36
|
end
|
31
37
|
|
38
|
+
def add_securty_options(settings, authn_requests_signed: true,
|
39
|
+
embed_sign: true,
|
40
|
+
logout_requests_signed: true,
|
41
|
+
logout_responses_signed: true,
|
42
|
+
digest_method: XMLSecurity::Document::SHA256,
|
43
|
+
signature_method: XMLSecurity::Document::RSA_SHA256)
|
44
|
+
# Security section
|
45
|
+
settings.idp_cert = SamlIdp::Default::X509_CERTIFICATE
|
46
|
+
# Signed embedded singature
|
47
|
+
settings.security[:authn_requests_signed] = authn_requests_signed
|
48
|
+
settings.security[:embed_sign] = embed_sign
|
49
|
+
settings.security[:logout_requests_signed] = logout_requests_signed
|
50
|
+
settings.security[:logout_responses_signed] = logout_responses_signed
|
51
|
+
settings.security[:metadata_signed] = digest_method
|
52
|
+
settings.security[:digest_method] = digest_method
|
53
|
+
settings.security[:signature_method] = signature_method
|
54
|
+
settings.private_key = sp_pv_key
|
55
|
+
settings.certificate = sp_x509_cert
|
56
|
+
end
|
57
|
+
|
58
|
+
def idp_configure(saml_acs_url = "https://foo.example.com/saml/consume", enable_secure_options = false)
|
59
|
+
SamlIdp.configure do |config|
|
60
|
+
config.x509_certificate = SamlIdp::Default::X509_CERTIFICATE
|
61
|
+
config.secret_key = SamlIdp::Default::SECRET_KEY
|
62
|
+
config.password = nil
|
63
|
+
config.algorithm = :sha256
|
64
|
+
config.organization_name = 'idp.com'
|
65
|
+
config.organization_url = 'http://idp.com'
|
66
|
+
config.base_saml_location = 'http://idp.com/saml/idp'
|
67
|
+
config.single_logout_service_post_location = 'http://idp.com/saml/idp/logout'
|
68
|
+
config.single_logout_service_redirect_location = 'http://idp.com/saml/idp/logout'
|
69
|
+
config.attribute_service_location = 'http://idp.com/saml/idp/attribute'
|
70
|
+
config.single_service_post_location = 'http://idp.com/saml/idp/sso'
|
71
|
+
config.name_id.formats = SamlIdp::Default::NAME_ID_FORMAT
|
72
|
+
config.service_provider.metadata_persister = lambda { |_identifier, _service_provider|
|
73
|
+
raw_metadata = generate_sp_metadata(saml_acs_url, enable_secure_options)
|
74
|
+
SamlIdp::IncomingMetadata.new(raw_metadata).to_h
|
75
|
+
}
|
76
|
+
config.service_provider.persisted_metadata_getter = lambda { |_identifier, _settings|
|
77
|
+
raw_metadata = generate_sp_metadata(saml_acs_url, enable_secure_options)
|
78
|
+
SamlIdp::IncomingMetadata.new(raw_metadata).to_h
|
79
|
+
}
|
80
|
+
config.service_provider.finder = lambda { |_issuer_or_entity_id|
|
81
|
+
{
|
82
|
+
response_hosts: [URI(saml_acs_url).host],
|
83
|
+
acs_url: saml_acs_url,
|
84
|
+
cert: sp_x509_cert,
|
85
|
+
fingerprint: SamlIdp::Fingerprint.certificate_digest(sp_x509_cert)
|
86
|
+
}
|
87
|
+
}
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
32
91
|
def print_pretty_xml(xml_string)
|
33
92
|
doc = REXML::Document.new xml_string
|
34
93
|
outbuf = ""
|
@@ -58,4 +58,14 @@ module SecurityHelpers
|
|
58
58
|
def r1_signature_2
|
59
59
|
@signature2 ||= File.read(File.join(File.dirname(__FILE__), 'certificates', 'r1_certificate2_base64'))
|
60
60
|
end
|
61
|
+
|
62
|
+
# Generated by SAML tool https://www.samltool.com/self_signed_certs.php
|
63
|
+
def sp_pv_key
|
64
|
+
@sp_pv_key ||= File.read(File.join(File.dirname(__FILE__), 'certificates', 'sp_private_key.pem'))
|
65
|
+
end
|
66
|
+
|
67
|
+
# Generated by SAML tool https://www.samltool.com/self_signed_certs.php, expired date is 9999
|
68
|
+
def sp_x509_cert
|
69
|
+
@sp_x509_cert ||= File.read(File.join(File.dirname(__FILE__), 'certificates', 'sp_x509_cert.crt'))
|
70
|
+
end
|
61
71
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: saml_idp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.14.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jon Phenow
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-07-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -16,56 +16,70 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '5.2'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '5.2'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: builder
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '3.0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '3.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: nokogiri
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 1.6.2
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 1.6.2
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: xmlenc
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 0.7.1
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 0.7.1
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rexml
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: rake
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -128,28 +142,28 @@ dependencies:
|
|
128
142
|
requirements:
|
129
143
|
- - ">="
|
130
144
|
- !ruby/object:Gem::Version
|
131
|
-
version: '
|
145
|
+
version: '5.2'
|
132
146
|
type: :development
|
133
147
|
prerelease: false
|
134
148
|
version_requirements: !ruby/object:Gem::Requirement
|
135
149
|
requirements:
|
136
150
|
- - ">="
|
137
151
|
- !ruby/object:Gem::Version
|
138
|
-
version: '
|
152
|
+
version: '5.2'
|
139
153
|
- !ruby/object:Gem::Dependency
|
140
154
|
name: activeresource
|
141
155
|
requirement: !ruby/object:Gem::Requirement
|
142
156
|
requirements:
|
143
157
|
- - ">="
|
144
158
|
- !ruby/object:Gem::Version
|
145
|
-
version: '
|
159
|
+
version: '5.1'
|
146
160
|
type: :development
|
147
161
|
prerelease: false
|
148
162
|
version_requirements: !ruby/object:Gem::Requirement
|
149
163
|
requirements:
|
150
164
|
- - ">="
|
151
165
|
- !ruby/object:Gem::Version
|
152
|
-
version: '
|
166
|
+
version: '5.1'
|
153
167
|
- !ruby/object:Gem::Dependency
|
154
168
|
name: capybara
|
155
169
|
requirement: !ruby/object:Gem::Requirement
|
@@ -179,21 +193,21 @@ dependencies:
|
|
179
193
|
- !ruby/object:Gem::Version
|
180
194
|
version: '0.8'
|
181
195
|
- !ruby/object:Gem::Dependency
|
182
|
-
name:
|
196
|
+
name: appraisal
|
183
197
|
requirement: !ruby/object:Gem::Requirement
|
184
198
|
requirements:
|
185
199
|
- - ">="
|
186
200
|
- !ruby/object:Gem::Version
|
187
|
-
version: 0
|
201
|
+
version: '0'
|
188
202
|
type: :development
|
189
203
|
prerelease: false
|
190
204
|
version_requirements: !ruby/object:Gem::Requirement
|
191
205
|
requirements:
|
192
206
|
- - ">="
|
193
207
|
- !ruby/object:Gem::Version
|
194
|
-
version: 0
|
208
|
+
version: '0'
|
195
209
|
- !ruby/object:Gem::Dependency
|
196
|
-
name:
|
210
|
+
name: byebug
|
197
211
|
requirement: !ruby/object:Gem::Requirement
|
198
212
|
requirements:
|
199
213
|
- - ">="
|
@@ -215,9 +229,6 @@ files:
|
|
215
229
|
- Gemfile
|
216
230
|
- LICENSE
|
217
231
|
- README.md
|
218
|
-
- app/controllers/saml_idp/idp_controller.rb
|
219
|
-
- app/views/saml_idp/idp/new.html.erb
|
220
|
-
- app/views/saml_idp/idp/saml_post.html.erb
|
221
232
|
- lib/saml_idp.rb
|
222
233
|
- lib/saml_idp/algorithmable.rb
|
223
234
|
- lib/saml_idp/assertion_builder.rb
|
@@ -228,6 +239,7 @@ files:
|
|
228
239
|
- lib/saml_idp/default.rb
|
229
240
|
- lib/saml_idp/encryptor.rb
|
230
241
|
- lib/saml_idp/engine.rb
|
242
|
+
- lib/saml_idp/fingerprint.rb
|
231
243
|
- lib/saml_idp/hashable.rb
|
232
244
|
- lib/saml_idp/incoming_metadata.rb
|
233
245
|
- lib/saml_idp/logout_builder.rb
|
@@ -254,6 +266,7 @@ files:
|
|
254
266
|
- spec/lib/saml_idp/configurator_spec.rb
|
255
267
|
- spec/lib/saml_idp/controller_spec.rb
|
256
268
|
- spec/lib/saml_idp/encryptor_spec.rb
|
269
|
+
- spec/lib/saml_idp/fingerprint_spec.rb
|
257
270
|
- spec/lib/saml_idp/incoming_metadata_spec.rb
|
258
271
|
- spec/lib/saml_idp/logout_request_builder_spec.rb
|
259
272
|
- spec/lib/saml_idp/logout_response_builder_spec.rb
|
@@ -279,6 +292,8 @@ files:
|
|
279
292
|
- spec/rails_app/app/mailers/.gitkeep
|
280
293
|
- spec/rails_app/app/models/.gitkeep
|
281
294
|
- spec/rails_app/app/views/layouts/application.html.erb
|
295
|
+
- spec/rails_app/app/views/saml_idp/idp/new.html.erb
|
296
|
+
- spec/rails_app/app/views/saml_idp/idp/saml_post.html.erb
|
282
297
|
- spec/rails_app/config.ru
|
283
298
|
- spec/rails_app/config/application.rb
|
284
299
|
- spec/rails_app/config/boot.rb
|
@@ -319,6 +334,9 @@ files:
|
|
319
334
|
- spec/spec_helper.rb
|
320
335
|
- spec/support/certificates/certificate1
|
321
336
|
- spec/support/certificates/r1_certificate2_base64
|
337
|
+
- spec/support/certificates/sp_cert_req.csr
|
338
|
+
- spec/support/certificates/sp_private_key.pem
|
339
|
+
- spec/support/certificates/sp_x509_cert.crt
|
322
340
|
- spec/support/responses/adfs_response_sha1.xml
|
323
341
|
- spec/support/responses/adfs_response_sha256.xml
|
324
342
|
- spec/support/responses/adfs_response_sha384.xml
|
@@ -347,7 +365,7 @@ metadata:
|
|
347
365
|
homepage_uri: https://github.com/saml-idp/saml_idp
|
348
366
|
source_code_uri: https://github.com/saml-idp/saml_idp
|
349
367
|
bug_tracker_uri: https://github.com/saml-idp/saml_idp/issues
|
350
|
-
documentation_uri: http://rdoc.info/gems/saml_idp/0.
|
368
|
+
documentation_uri: http://rdoc.info/gems/saml_idp/0.14.0
|
351
369
|
post_install_message: |
|
352
370
|
If you're just recently updating saml_idp - please be aware we've changed the default
|
353
371
|
certificate. See the PR and a description of why we've done this here:
|
@@ -371,15 +389,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
371
389
|
requirements:
|
372
390
|
- - ">="
|
373
391
|
- !ruby/object:Gem::Version
|
374
|
-
version: '2.
|
392
|
+
version: '2.5'
|
375
393
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
376
394
|
requirements:
|
377
395
|
- - ">="
|
378
396
|
- !ruby/object:Gem::Version
|
379
397
|
version: '0'
|
380
398
|
requirements: []
|
381
|
-
|
382
|
-
rubygems_version: 2.7.6
|
399
|
+
rubygems_version: 3.1.2
|
383
400
|
signing_key:
|
384
401
|
specification_version: 4
|
385
402
|
summary: SAML Indentity Provider for Ruby
|
@@ -392,6 +409,7 @@ test_files:
|
|
392
409
|
- spec/lib/saml_idp/configurator_spec.rb
|
393
410
|
- spec/lib/saml_idp/controller_spec.rb
|
394
411
|
- spec/lib/saml_idp/encryptor_spec.rb
|
412
|
+
- spec/lib/saml_idp/fingerprint_spec.rb
|
395
413
|
- spec/lib/saml_idp/incoming_metadata_spec.rb
|
396
414
|
- spec/lib/saml_idp/logout_request_builder_spec.rb
|
397
415
|
- spec/lib/saml_idp/logout_response_builder_spec.rb
|
@@ -417,6 +435,8 @@ test_files:
|
|
417
435
|
- spec/rails_app/app/mailers/.gitkeep
|
418
436
|
- spec/rails_app/app/models/.gitkeep
|
419
437
|
- spec/rails_app/app/views/layouts/application.html.erb
|
438
|
+
- spec/rails_app/app/views/saml_idp/idp/new.html.erb
|
439
|
+
- spec/rails_app/app/views/saml_idp/idp/saml_post.html.erb
|
420
440
|
- spec/rails_app/config.ru
|
421
441
|
- spec/rails_app/config/application.rb
|
422
442
|
- spec/rails_app/config/boot.rb
|
@@ -457,6 +477,9 @@ test_files:
|
|
457
477
|
- spec/spec_helper.rb
|
458
478
|
- spec/support/certificates/certificate1
|
459
479
|
- spec/support/certificates/r1_certificate2_base64
|
480
|
+
- spec/support/certificates/sp_cert_req.csr
|
481
|
+
- spec/support/certificates/sp_private_key.pem
|
482
|
+
- spec/support/certificates/sp_x509_cert.crt
|
460
483
|
- spec/support/responses/adfs_response_sha1.xml
|
461
484
|
- spec/support/responses/adfs_response_sha256.xml
|
462
485
|
- spec/support/responses/adfs_response_sha384.xml
|