lib/saml/kit/authentication_request.rb in saml-kit-0.2.1 vs lib/saml/kit/authentication_request.rb in saml-kit-0.2.2
- old
+ new
@@ -5,64 +5,26 @@
def initialize(xml)
super(xml, name: "AuthnRequest")
end
- def acs_url
+ def assertion_consumer_service_url
to_h[name]['AssertionConsumerServiceURL']
end
def name_id_format
to_h[name]['NameIDPolicy']['Format']
end
- def response_for(user)
- Response::Builder.new(user, self)
- end
-
- private
-
- class Builder
- attr_accessor :id, :now, :issuer, :acs_url, :name_id_format, :sign, :destination
- attr_accessor :version
-
- def initialize(configuration: Saml::Kit.configuration, sign: true)
- @id = SecureRandom.uuid
- @issuer = configuration.issuer
- @name_id_format = Namespaces::PERSISTENT
- @now = Time.now.utc
- @version = "2.0"
- @sign = sign
+ def response_for(user, binding:, relay_state: nil)
+ response_binding = provider.assertion_consumer_service_for(binding: binding)
+ builder = Saml::Kit::Response.builder(user, self) do |x|
+ x.sign = provider.want_assertions_signed
+ yield x if block_given?
end
-
- def to_xml
- Signature.sign(sign: sign) do |xml, signature|
- xml.tag!('samlp:AuthnRequest', request_options) do
- xml.tag!('saml:Issuer', issuer)
- signature.template(id)
- xml.tag!('samlp:NameIDPolicy', Format: name_id_format)
- end
- end
- end
-
- def build
- AuthenticationRequest.new(to_xml)
- end
-
- private
-
- def request_options
- options = {
- "xmlns:samlp" => Namespaces::PROTOCOL,
- "xmlns:saml" => Namespaces::ASSERTION,
- ID: "_#{id}",
- Version: version,
- IssueInstant: now.utc.iso8601,
- Destination: destination,
- }
- options[:AssertionConsumerServiceURL] = acs_url if acs_url.present?
- options
- end
+ response_binding.serialize(builder, relay_state: relay_state)
end
+
+ Builder = ActiveSupport::Deprecation::DeprecatedConstantProxy.new('Saml::Kit::AuthenticationRequest::Builder', 'Saml::Kit::Builders::AuthenticationRequest')
end
end
end