Skip to content

Commit

Permalink
No need to persist metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
zogoo authored and dmlo committed Nov 16, 2022
1 parent 23b8159 commit cd4bc04
Show file tree
Hide file tree
Showing 6 changed files with 0 additions and 46 deletions.
14 changes: 0 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,20 +220,6 @@ CERT
end
}

# `identifier` is the entity_id or issuer of the Service Provider,
# `service_provider` is a ServiceProvider object. Based on the `identifier` or the
# `service_provider` you should return the settings.to_h from above
config.service_provider.persisted_metadata_getter = ->(identifier, service_provider){
fname = identifier.to_s.gsub(/\/|:/,"_")
FileUtils.mkdir_p(Rails.root.join('cache', 'saml', 'metadata').to_s)
full_filename = Rails.root.join("cache/saml/metadata/#{fname}")
if File.file?(full_filename)
File.open full_filename, "rb" do |f|
Marshal.load f
end
end
}

# Find ServiceProvider metadata_url and fingerprint based on our settings
config.service_provider.finder = ->(issuer_or_entity_id) do
service_providers[issuer_or_entity_id]
Expand Down
1 change: 0 additions & 1 deletion lib/saml_idp/configurator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ def initialize
self.service_provider = OpenStruct.new
self.service_provider.finder = ->(_) { Default::SERVICE_PROVIDER }
self.service_provider.metadata_persister = ->(id, settings) { }
self.service_provider.persisted_metadata_getter = ->(id, service_provider) { }
self.session_expiry = 0
self.attributes = {}
end
Expand Down
14 changes: 0 additions & 14 deletions lib/saml_idp/persisted_metadata.rb

This file was deleted.

8 changes: 0 additions & 8 deletions lib/saml_idp/service_provider.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,9 @@ def metadata_url_host

def get_current_or_build
persisted = metadata_getter[identifier, self]
if persisted.is_a? Hash
PersistedMetadata.new(persisted)
end
end
private :get_current_or_build

def metadata_getter
config.service_provider.persisted_metadata_getter
end
private :metadata_getter

def metadata_persister
config.service_provider.metadata_persister
end
Expand Down
5 changes: 0 additions & 5 deletions spec/lib/saml_idp/controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,6 @@ def params
params[:SAMLRequest] = make_saml_request("https://foo.example.com/saml/consume", true)
end

it 'SP metadata sign_authn_request attribute should be true' do
# Signed auth request will be true in the metadata
expect(SamlIdp.config.service_provider.persisted_metadata_getter.call(nil,nil)[:sign_authn_request]).to eq(true)
end

it 'should call xml signature validation method' do
signed_doc = SamlIdp::XMLSecurity::SignedDocument.new(params[:SAMLRequest])
allow(signed_doc).to receive(:validate).and_return(true)
Expand Down
4 changes: 0 additions & 4 deletions spec/support/saml_request_macros.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,6 @@ def idp_configure(saml_acs_url = "https://foo.example.com/saml/consume", enable_
raw_metadata = generate_sp_metadata(saml_acs_url, enable_secure_options)
SamlIdp::IncomingMetadata.new(raw_metadata).to_h
}
config.service_provider.persisted_metadata_getter = lambda { |_identifier, _settings|
raw_metadata = generate_sp_metadata(saml_acs_url, enable_secure_options)
SamlIdp::IncomingMetadata.new(raw_metadata).to_h
}
config.service_provider.finder = lambda { |_issuer_or_entity_id|
{
response_hosts: [URI(saml_acs_url).host],
Expand Down

0 comments on commit cd4bc04

Please sign in to comment.