Skip to content

Commit e54e7b2

Browse files
author
Simon Coffey
committed
Support milliseconds in cacheDuration parsing
Since the introduction of cacheDuration parsing in 25cbddd we've been seeing parsing failures for one of our IdPs, whose cacheDuration value is set to cacheDuration="PT6H0M0.000S" This seems like a perfectly valid ISO8601 duration - the regexp being used for parsing doesn't provide for the possibility of milliseconds. This adds an optional non-captured group to the regexp to permit them. Since the captured string value is already being converted using .to_f, it appears this should work as-is. To achieve minimal test coverage I've added a seconds string to one of the existing metadata examples with a zero value; this reproduces the failure and confirms the fix without needing to add a specific test case.
1 parent bbb4fb6 commit e54e7b2

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

lib/onelogin/ruby-saml/utils.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class Utils
1515

1616
DSIG = "http://www.w3.org/2000/09/xmldsig#"
1717
XENC = "http://www.w3.org/2001/04/xmlenc#"
18-
DURATION_FORMAT = %r(^(-?)P(?:(?:(?:(\d+)Y)?(?:(\d+)M)?(?:(\d+)D)?(?:T(?:(\d+)H)?(?:(\d+)M)?(?:(\d+)S)?)?)|(?:(\d+)W))$)
18+
DURATION_FORMAT = %r(^(-?)P(?:(?:(?:(\d+)Y)?(?:(\d+)M)?(?:(\d+)D)?(?:T(?:(\d+)H)?(?:(\d+)M)?(?:(\d+(?:\.\d{3})?)S)?)?)|(?:(\d+)W))$)
1919

2020
# Checks if the x509 cert provided is expired
2121
#

test/metadata/idp_descriptor_6.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<md:EntityDescriptor entityID="https://hello.example.com/access/saml/idp.xml" validUntil="2020-01-04T18:02:33.910Z" cacheDuration="P2DT" xmlns:md="urn:oasis:names:tc:SAML:2.0:metadata">
2+
<md:EntityDescriptor entityID="https://hello.example.com/access/saml/idp.xml" validUntil="2020-01-04T18:02:33.910Z" cacheDuration="P2DT0.000S" xmlns:md="urn:oasis:names:tc:SAML:2.0:metadata">
33
<md:IDPSSODescriptor WantAuthnRequestsSigned="true" protocolSupportEnumeration="urn:oasis:names:tc:SAML:2.0:protocol">
44
<md:KeyDescriptor use="signing">
55
<ds:KeyInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig#">

0 commit comments

Comments
 (0)