Class: Saml::Kit::DefaultRegistry

Inherits:
Object
  • Object
show all
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.

Defined Under Namespace

Classes: HttpApi

Instance Method Summary collapse

Constructor Details

#initialize(items = {}) ⇒ DefaultRegistry

Returns a new instance of DefaultRegistry.



6
7
8
# File 'lib/saml/kit/default_registry.rb', line 6

def initialize(items = {})
  @items = items
end

Instance Method Details

#metadata_for(entity_id) ⇒ Object

Returns the metadata document associated with an issuer or entityID.

Parameters:

  • entity_id (String) —

    the unique entityID/Issuer associated with metadata.



31
32
33
# File 'lib/saml/kit/default_registry.rb', line 31

def (entity_id)
  @items[entity_id]
end

#register(metadata) ⇒ Object

Register a metadata document

Parameters:



13
14
15
16
# File 'lib/saml/kit/default_registry.rb', line 13

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.

Parameters:

  • url (String) —

    the url to download the metadata from.

  • verify_ssl (Boolean) (defaults to: true) —

    enable/disable SSL peer verification.



23
24
25
26
# File 'lib/saml/kit/default_registry.rb', line 23

def register_url(url, verify_ssl: true)
  content = HttpApi.new(url, verify_ssl: verify_ssl).get
  register(Saml::Kit::Metadata.from(content))
end