Class: Saml::Kit::DefaultRegistry
- Inherits:
-
Object
- Object
- Saml::Kit::DefaultRegistry
- Includes:
- Enumerable
- Defined in:
- lib/saml/kit/default_registry.rb
Overview
The default metadata registry is used to fetch the metadata associated with an issuer or entity id. The metadata associated with an issuer is used to verify trust for any SAML documents that are received.
You can replace the default registry with your own at startup.
Example:
class OnDemandRegistry
def initialize(original)
@original = original
end
def (entity_id)
found = @original.(entity_id)
return found if found
@original.register_url(entity_id, verify_ssl: Rails.env.production?)
@original.(entity_id)
end
end
Saml::Kit.configure do |configuration|
configuration.entity_id = ENV['ENTITY_ID']
configuration.registry = OnDemandRegistry.new(configuration.registry)
configuration.logger = Rails.logger
end
Defined Under Namespace
Classes: HttpApi
Instance Method Summary collapse
-
#each ⇒ Object
Yields each registered [Saml::Kit::Metadata] to the block.
-
#initialize(items = {}) ⇒ DefaultRegistry
constructor
A new instance of DefaultRegistry.
-
#metadata_for(entity_id) ⇒ Object
Returns the metadata document associated with an issuer or entityID.
-
#register(metadata) ⇒ Object
Register a metadata document.
-
#register_url(url, verify_ssl: true) ⇒ Object
Register metadata via a remote URL.
Constructor Details
#initialize(items = {}) ⇒ DefaultRegistry
Returns a new instance of DefaultRegistry.
34 35 36 |
# File 'lib/saml/kit/default_registry.rb', line 34 def initialize(items = {}) @items = items end |
Instance Method Details
#each ⇒ Object
Yields each registered [Saml::Kit::Metadata] to the block.
64 65 66 67 68 |
# File 'lib/saml/kit/default_registry.rb', line 64 def each @items.each do |key, value| yield value end end |
#metadata_for(entity_id) ⇒ Object
Returns the metadata document associated with an issuer or entityID.
59 60 61 |
# File 'lib/saml/kit/default_registry.rb', line 59 def (entity_id) @items[entity_id] end |
#register(metadata) ⇒ Object
Register a metadata document
41 42 43 44 |
# File 'lib/saml/kit/default_registry.rb', line 41 def register() Saml::Kit.logger.debug(.to_xml(pretty: true)) @items[.entity_id] = end |
#register_url(url, verify_ssl: true) ⇒ Object
Register metadata via a remote URL. This will attempt to connect to the remove URL to download the metadata and register it in the registry.
51 52 53 54 |
# File 'lib/saml/kit/default_registry.rb', line 51 def register_url(url, verify_ssl: true) content = HttpApi.new(url, verify_ssl: verify_ssl).get register(Saml::Kit::Metadata.from(content)) end |