File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -47,6 +47,7 @@ def create_authentication_xml_doc(settings)
4747 root . attributes [ 'IsPassive' ] = settings . passive unless settings . passive . nil?
4848 root . attributes [ 'ProtocolBinding' ] = settings . protocol_binding unless settings . protocol_binding . nil?
4949 root . attributes [ "AttributeConsumingServiceIndex" ] = settings . attributes_index unless settings . attributes_index . nil?
50+ root . attributes [ 'ForceAuthn' ] = settings . force_authn unless settings . force_authn . nil?
5051
5152 # Conditionally defined elements based on settings
5253 if settings . assertion_consumer_service_url != nil
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ def initialize(overrides = {})
2020 attr_accessor :passive
2121 attr_accessor :protocol_binding
2222 attr_accessor :attributes_index
23+ attr_accessor :force_authn
2324
2425 private
2526
Original file line number Diff line number Diff line change @@ -96,6 +96,22 @@ class RequestTest < Test::Unit::TestCase
9696 assert_match /<samlp:AuthnRequest[^<]* AttributeConsumingServiceIndex='30'/ , inflated
9797 end
9898
99+ should "create the SAMLRequest URL parameter with ForceAuthn" do
100+ settings = OneLogin ::RubySaml ::Settings . new
101+ settings . idp_sso_target_url = "http://example.com"
102+ settings . force_authn = true
103+ auth_url = OneLogin ::RubySaml ::Authrequest . new . create ( settings )
104+ assert auth_url =~ /^http:\/ \/ example\. com\? SAMLRequest=/
105+ payload = CGI . unescape ( auth_url . split ( "=" ) . last )
106+ decoded = Base64 . decode64 ( payload )
107+
108+ zstream = Zlib ::Inflate . new ( -Zlib ::MAX_WBITS )
109+ inflated = zstream . inflate ( decoded )
110+ zstream . finish
111+ zstream . close
112+ assert_match /<samlp:AuthnRequest[^<]* ForceAuthn='true'/ , inflated
113+ end
114+
99115 should "accept extra parameters" do
100116 settings = OneLogin ::RubySaml ::Settings . new
101117 settings . idp_sso_target_url = "http://example.com"
You can’t perform that action at this time.
0 commit comments