Sha256: b8d060a466ea7b31b61d8ed2b2b0f539097bc73f980bafbb397f3039657e2ae1

Contents?: true

Size: 1.57 KB

Versions: 4

Compression:

Stored size: 1.57 KB

Contents

module Saml
  module Kit
    class IdentityProviderMetadata < Metadata
      def initialize(xml)
        super("IDPSSODescriptor", xml)
      end

      def want_authn_requests_signed
        xpath = "/md:EntityDescriptor/md:#{name}"
        attribute = document.find_by(xpath).attribute("WantAuthnRequestsSigned")
        return true if attribute.nil?
        attribute.text.downcase == "true"
      end

      def single_sign_on_services
        services('SingleSignOnService')
      end

      def single_sign_on_service_for(binding:)
        service_for(binding: binding, type: 'SingleSignOnService')
      end

      def attributes
        document.find_all("/md:EntityDescriptor/md:#{name}/saml:Attribute").map do |item|
          {
            format: item.attribute("NameFormat").try(:value),
            name: item.attribute("Name").value,
          }
        end
      end

      def login_request_for(binding:, relay_state: nil, configuration: Saml::Kit.configuration)
        builder = Saml::Kit::AuthenticationRequest.builder(configuration: configuration) do |x|
          x.embed_signature = want_authn_requests_signed
          yield x if block_given?
        end
        request_binding = single_sign_on_service_for(binding: binding)
        request_binding.serialize(builder, relay_state: relay_state)
      end

      def self.builder_class
        Saml::Kit::Builders::IdentityProviderMetadata
      end

      Builder = ActiveSupport::Deprecation::DeprecatedConstantProxy.new('Saml::Kit::IdentityProviderMetadata::Builder', 'Saml::Kit::Builders::IdentityProviderMetadata')
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
saml-kit-0.2.11 lib/saml/kit/identity_provider_metadata.rb
saml-kit-0.2.10 lib/saml/kit/identity_provider_metadata.rb
saml-kit-0.2.9 lib/saml/kit/identity_provider_metadata.rb
saml-kit-0.2.8 lib/saml/kit/identity_provider_metadata.rb