Module: Saml

Defined in:
lib/saml.rb,
lib/saml/base.rb,
lib/saml/util.rb,
lib/saml/config.rb,
lib/saml/version.rb,
lib/saml/artifact.rb,
lib/saml/encoding.rb,
lib/saml/provider.rb,
lib/saml/response.rb,
lib/saml/assertion.rb,
lib/saml/xml_helpers.rb,
lib/saml/notification.rb,
lib/saml/authn_request.rb,
lib/saml/bindings/soap.rb,
lib/saml/null_provider.rb,
lib/saml/basic_provider.rb,
lib/saml/logout_request.rb,
lib/saml/elements/status.rb,
lib/saml/logout_response.rb,
lib/saml/artifact_resolve.rb,
lib/saml/elements/name_id.rb,
lib/saml/elements/subject.rb,
lib/saml/artifact_response.rb,
lib/saml/elements/key_info.rb,
lib/saml/bindings/http_post.rb,
lib/saml/elements/attribute.rb,
lib/saml/elements/signature.rb,
lib/saml/elements/conditions.rb,
lib/saml/provider_stores/url.rb,
lib/saml/elements/status_code.rb,
lib/saml/provider_stores/file.rb,
lib/saml/elements/organization.rb,
lib/saml/elements/service_name.rb,
lib/saml/bindings/http_artifact.rb,
lib/saml/bindings/http_redirect.rb,
lib/saml/elements/authn_context.rb,
lib/saml/elements/md_extensions.rb,
lib/saml/elements/contact_person.rb,
lib/saml/elements/key_descriptor.rb,
lib/saml/rails/controller_helper.rb,
lib/saml/elements/authn_statement.rb,
lib/saml/elements/sub_status_code.rb,
lib/saml/elements/organization_url.rb,
lib/saml/elements/samlp_extensions.rb,
lib/saml/elements/subject_locality.rb,
lib/saml/elements/entity_attributes.rb,
lib/saml/elements/entity_descriptor.rb,
lib/saml/elements/organization_name.rb,
lib/saml/elements/sp_sso_descriptor.rb,
lib/saml/complex_types/endpoint_type.rb,
lib/saml/elements/idp_sso_descriptor.rb,
lib/saml/elements/key_info/x509_data.rb,
lib/saml/complex_types/attribute_type.rb,
lib/saml/elements/attribute_statement.rb,
lib/saml/elements/encrypted_assertion.rb,
lib/saml/elements/encrypted_attribute.rb,
lib/saml/elements/entities_descriptor.rb,
lib/saml/elements/requested_attribute.rb,
lib/saml/elements/service_description.rb,
lib/saml/elements/signature/reference.rb,
lib/saml/elements/signature/transform.rb,
lib/saml/elements/audience_restriction.rb,
lib/saml/elements/signature/transforms.rb,
lib/saml/elements/subject_confirmation.rb,
lib/saml/elements/signature/signed_info.rb,
lib/saml/elements/requested_authn_context.rb,
lib/saml/elements/signature/digest_method.rb,
lib/saml/complex_types/localized_name_type.rb,
lib/saml/complex_types/sso_descriptor_type.rb,
lib/saml/elements/authenticating_authority.rb,
lib/saml/complex_types/status_response_type.rb,
lib/saml/elements/organization_display_name.rb,
lib/saml/elements/subject_confirmation_data.rb,
lib/saml/complex_types/indexed_endpoint_type.rb,
lib/saml/complex_types/request_abstract_type.rb,
lib/saml/elements/signature/signature_method.rb,
lib/saml/elements/attribute_consuming_service.rb,
lib/saml/complex_types/statement_abstract_type.rb,
lib/saml/elements/signature/inclusive_namespaces.rb,
lib/saml/elements/signature/canonicalization_method.rb

Defined Under Namespace

Modules: Base, Bindings, ClassRefs, ComplexTypes, Config, Elements, Errors, Notification, ProtocolBinding, Provider, ProviderStores, Rails, SubStatusCodes, TopLevelCodes, XMLHelpers Classes: Artifact, ArtifactResolve, ArtifactResponse, Assertion, AuthnRequest, BasicProvider, Encoding, LogoutRequest, LogoutResponse, NullProvider, Response, Util

Constant Summary collapse

MD_NAMESPACE =
'urn:oasis:names:tc:SAML:2.0:metadata'
MD_ATTR_NAMESPACE =
'urn:oasis:names:tc:SAML:metadata:attribute'
SAML_NAMESPACE =
'urn:oasis:names:tc:SAML:2.0:assertion'
SAMLP_NAMESPACE =
'urn:oasis:names:tc:SAML:2.0:protocol'
XML_DSIG_NAMESPACE =
'http://www.w3.org/2000/09/xmldsig#'
SAML_VERSION =
'2.0'
VERSION =
"2.5.2"

Class Method Summary collapse

Class Method Details

.current_providerObject



165
166
167
# File 'lib/saml.rb', line 165

def self.current_provider
  Thread.current['saml_current_provider'] || NullProvider.new
end

.current_provider=(provider) ⇒ Object



169
170
171
# File 'lib/saml.rb', line 169

def self.current_provider=(provider)
  Thread.current['saml_current_provider'] = provider
end

.current_storeObject



173
174
175
176
177
178
# File 'lib/saml.rb', line 173

def self.current_store
  store_name = Thread.current['saml_current_store']
  Saml::Config.registered_stores[store_name] ||
      Saml::Config.registered_stores[Saml::Config.default_store] ||
      raise(Errors::InvalidStore.new(store_name))
end

.current_store=(store_name) ⇒ Object



180
181
182
# File 'lib/saml.rb', line 180

def self.current_store=(store_name)
  Thread.current['saml_current_store'] = store_name
end

.generate_idObject



188
189
190
# File 'lib/saml.rb', line 188

def self.generate_id
  "_#{::SecureRandom.hex(20)}"
end

.parse_message(message, type) ⇒ Object



200
201
202
203
204
205
206
207
208
209
# File 'lib/saml.rb', line 200

def self.parse_message(message, type)
  if %w(authn_request response logout_request logout_response artifact_resolve artifact_response).include?(type.to_s)
    klass = "Saml::#{type.to_s.camelize}".constantize
    klass.parse(message, single: true)
  elsif klass = type.to_s.camelize.safe_constantize
    klass.parse(message, single: true)
  else
    nil
  end
end

.provider(entity_id) ⇒ Object



192
193
194
195
196
197
198
# File 'lib/saml.rb', line 192

def self.provider(entity_id)
  if current_provider.entity_id == entity_id
    current_provider
  else
    current_store.find_by_entity_id(entity_id) || raise(Saml::Errors::InvalidProvider.new("Cannot find provider with entity_id: #{entity_id}"))
  end
end

.setup {|Saml::Config| ... } ⇒ Object

Yields:



184
185
186
# File 'lib/saml.rb', line 184

def self.setup
  yield Saml::Config
end