Sha256: 8d82159342e9becb0330c13e7816653983f566b5b6424c1590b6525f7cf83a46

Contents?: true

Size: 1.49 KB

Versions: 5

Compression:

Stored size: 1.49 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)
        builder = Saml::Kit::AuthenticationRequest.builder do |x|
          x.sign = 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

5 entries across 5 versions & 1 rubygems

Version Path
saml-kit-0.2.6 lib/saml/kit/identity_provider_metadata.rb
saml-kit-0.2.5 lib/saml/kit/identity_provider_metadata.rb
saml-kit-0.2.4 lib/saml/kit/identity_provider_metadata.rb
saml-kit-0.2.3 lib/saml/kit/identity_provider_metadata.rb
saml-kit-0.2.2 lib/saml/kit/identity_provider_metadata.rb