File tree Expand file tree Collapse file tree 2 files changed +33
-0
lines changed
Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -198,6 +198,27 @@ def session_expires_at
198198 end
199199 end
200200
201+ # Gets the AuthnInstant from the AuthnStatement.
202+ # Could be used to require re-authentication if a long time has passed
203+ # since the last user authentication.
204+ # @return [String] AuthnInstant value
205+ #
206+ def authn_instant
207+ @authn_instant ||= begin
208+ node = xpath_first_from_signed_assertion ( '/a:AuthnStatement' )
209+ node . nil? ? nil : node . attributes [ 'AuthnInstant' ]
210+ end
211+ end
212+
213+ # Gets the AuthnContextClassRef from the AuthnStatement
214+ # Could be used to require re-authentication if the assertion
215+ # did not met the requested authentication context class.
216+ # @return [String] AuthnContextClassRef value
217+ #
218+ def authn_context_class_ref
219+ @authn_context_class_ref ||= Utils . element_text ( xpath_first_from_signed_assertion ( '/a:AuthnStatement/a:AuthnContext/a:AuthnContextClassRef' ) )
220+ end
221+
201222 # Checks if the Status has the "Success" code
202223 # @return [Boolean] True if the StatusCode is Sucess
203224 #
Original file line number Diff line number Diff line change @@ -1357,6 +1357,18 @@ def generate_audience_error(expected, actual)
13571357 end
13581358 end
13591359
1360+ describe "#authn_instant" do
1361+ it "extract the value of the AuthnInstant attribute" do
1362+ assert_equal "2010-11-18T21:57:37Z" , response . authn_instant
1363+ end
1364+ end
1365+
1366+ describe "#authn_context_class_ref" do
1367+ it "extract the value of the AuthnContextClassRef attribute" do
1368+ assert_equal "urn:oasis:names:tc:SAML:2.0:ac:classes:Password" , response . authn_context_class_ref
1369+ end
1370+ end
1371+
13601372 describe "#success" do
13611373 it "find a status code that says success" do
13621374 response . success?
You can’t perform that action at this time.
0 commit comments