diff --git a/lib/saml_idp/request.rb b/lib/saml_idp/request.rb
index 3f08648d..7c369090 100644
--- a/lib/saml_idp/request.rb
+++ b/lib/saml_idp/request.rb
@@ -67,6 +67,12 @@ def request
end
end
+ def force_authn?
+ return nil unless authn_request?
+
+ request["ForceAuthn"] == 'true'
+ end
+
def requested_authn_context
return authn_context_node.content if authn_request? && authn_context_node
end
diff --git a/lib/saml_idp/version.rb b/lib/saml_idp/version.rb
index 430d3ac1..6ac6705c 100644
--- a/lib/saml_idp/version.rb
+++ b/lib/saml_idp/version.rb
@@ -1,4 +1,4 @@
# encoding: utf-8
module SamlIdp
- VERSION = '0.14.3-18f'.freeze
+ VERSION = '0.15.0-18f'.freeze
end
diff --git a/spec/lib/saml_idp/request_spec.rb b/spec/lib/saml_idp/request_spec.rb
index 3be3a180..fc6f26b0 100644
--- a/spec/lib/saml_idp/request_spec.rb
+++ b/spec/lib/saml_idp/request_spec.rb
@@ -10,6 +10,10 @@ module SamlIdp
let(:raw_authn_unspecified_name_id_format) { "localhost:3000urn:oasis:names:tc:SAML:2.0:ac:classes:Password" }
+ let(:raw_authn_forceauthn_present) { "localhost:3000urn:oasis:names:tc:SAML:2.0:ac:classes:Password" }
+
+ let(:raw_authn_forceauthn_false) { "localhost:3000urn:oasis:names:tc:SAML:2.0:ac:classes:Password" }
+
describe "deflated request" do
let(:deflated_request) { Base64.encode64(Zlib::Deflate.deflate(raw_authn_request, 9)[2..-5]) }
@@ -83,6 +87,22 @@ module SamlIdp
expect(authn_request.issuer).to eq(nil)
expect(authn_request.valid?).to eq(false)
end
+
+ it 'defaults to force_authn = false' do
+ expect(subject.force_authn?).to be_falsey
+ end
+
+ it 'properly parses ForceAuthn="true" if passed' do
+ authn_request = described_class.new raw_authn_forceauthn_present
+
+ expect(authn_request.force_authn?).to be_truthy
+ end
+
+ it 'properly parses ForceAuthn="false" if passed' do
+ authn_request = described_class.new raw_authn_forceauthn_false
+
+ expect(authn_request.force_authn?).to be_falsey
+ end
end
describe "authn request with unspecified name id format" do