lib/saml/kit/builders/authentication_request.rb in saml-kit-0.2.2 vs lib/saml/kit/builders/authentication_request.rb in saml-kit-0.2.3
- old
+ new
@@ -1,31 +1,34 @@
module Saml
module Kit
module Builders
class AuthenticationRequest
+ include Saml::Kit::Templatable
attr_accessor :id, :now, :issuer, :assertion_consumer_service_url, :name_id_format, :sign, :destination
attr_accessor :version
+ attr_reader :configuration
def initialize(configuration: Saml::Kit.configuration, sign: true)
+ @configuration = configuration
@id = Id.generate
@issuer = configuration.issuer
@name_id_format = Namespaces::PERSISTENT
@now = Time.now.utc
- @version = "2.0"
@sign = sign
+ @version = "2.0"
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
+ def acs_url
+ Saml::Kit.deprecate("acs_url is deprecated. Use assertion_consumer_service_url instead")
+ self.assertion_consumer_service_url
end
+ def acs_url=(value)
+ Saml::Kit.deprecate("acs_url= is deprecated. Use assertion_consumer_service_url= instead")
+ self.assertion_consumer_service_url = value
+ end
+
def build
Saml::Kit::AuthenticationRequest.new(to_xml)
end
private
@@ -37,10 +40,12 @@
ID: id,
Version: version,
IssueInstant: now.utc.iso8601,
Destination: destination,
}
- options[:AssertionConsumerServiceURL] = assertion_consumer_service_url if assertion_consumer_service_url.present?
+ if assertion_consumer_service_url.present?
+ options[:AssertionConsumerServiceURL] = assertion_consumer_service_url
+ end
options
end
end
end
end