Skip to content

Commit

Permalink
Split the SSO/SOAP virtual host test out from check_imported into che…
Browse files Browse the repository at this point in the history
…ck_vhosts, and use just that in the check.ports target.

Neither check_imported (which now just observes a requirement for UK federation IdPs to have scopes) nor the new check_vhosts are suitable for checking metadata imported from other partners; they are both UK conventions only.
  • Loading branch information
iay committed Apr 18, 2011
1 parent e96be8d commit b68d985
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 34 deletions.
11 changes: 5 additions & 6 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,10 @@
<arg value="${build.dir}/import.xsl"/>
</java>
<echo>Imported metadata to ${entities.dir}/imported.xml</echo>
<CHECK i="${entities.dir}/imported.xml" s="check_imported.xsl"/>
<CHECK.std i="${entities.dir}/imported.xml">
<arg value="${build.dir}/check_imported.xsl"/>
<arg value="${build.dir}/check_vhosts.xsl"/>
</CHECK.std>
<echo>Checked.</echo>
</target>

Expand Down Expand Up @@ -967,7 +970,6 @@
<attribute name="i"/>
<sequential>
<CHECK.std i="@{i}">
<arg value="${build.dir}/check_imported.xsl"/>
<arg value="${build.dir}/check_future.xsl"/>
<arg value="${build.dir}/check_saml2int.xsl"/>
</CHECK.std>
Expand Down Expand Up @@ -1223,13 +1225,10 @@

<!--
Check for IdPs using the single-port configuration.
It just so happens that the check_imported ruleset is exactly what we want
right now.
-->
<target name="check.ports" depends="gen.uk.master">
<echo>Checking vhost use</echo>
<CHECK i="${xml.dir}/${uk.master.file}" s="check_imported.xsl"/>
<CHECK.one i="${xml.dir}/${uk.master.file}" s="check_vhosts.xsl"/>
<echo>Checked.</echo>
</target>

Expand Down
28 changes: 0 additions & 28 deletions build/check_imported.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -29,34 +29,6 @@
Checks for IdPs.
-->
<xsl:template match="md:EntityDescriptor[md:IDPSSODescriptor]">
<!--
Look for IdPs which have either attribute authority or artifact resolution locations
on the same host:port combination as any of the SSO locations.
-->

<!-- XPath expression to evaluate to extract host:port strings from locations -->
<xsl:variable name="extract">substring-before(substring-after(concat(., '/'), 'https://'), '/')</xsl:variable>

<!-- Collect all of the SSO locations -->
<xsl:variable name="ssoLocations" select="descendant::md:SingleSignOnService/@Location"/>
<!-- convert to set of unique host:port strings -->
<xsl:variable name="ssoHosts" select="set:distinct(dyn:map($ssoLocations, $extract))"/>

<!-- Collect all of the attribute authority and artifact resolution locations -->
<xsl:variable name="soapLocations"
select="descendant::md:AttributeService/@Location |
descendant::md:ArtifactResolutionService/@Location"/>
<!-- convert to set of unique host:port strings -->
<xsl:variable name="soapHosts" select="set:distinct(dyn:map($soapLocations, $extract))"/>

<!-- we expect these two sets to be disjoint -->
<xsl:variable name="bothHosts" select="set:distinct($ssoHosts | $soapHosts)"/>
<xsl:if test="count($bothHosts) != count($ssoHosts) + count($soapHosts)">
<xsl:call-template name="fatal">
<xsl:with-param name="m">at least one SOAP location on same vhost as an SSO location</xsl:with-param>
</xsl:call-template>
</xsl:if>

<!--
IdPs registered with the UK federation are expected to have at least one scope.
-->
Expand Down
58 changes: 58 additions & 0 deletions build/check_vhosts.xsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
check_vhosts.xsl
Checking ruleset that makes sure that an IdP's SSO endpoints and SOAP
endpoints are on distinct virtual host.
Author: Ian A. Young <ian@iay.org.uk>
-->
<xsl:stylesheet version="1.0"
xmlns:dyn="http://exslt.org/dynamic"
xmlns:md="urn:oasis:names:tc:SAML:2.0:metadata"
xmlns:set="http://exslt.org/sets"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="urn:oasis:names:tc:SAML:2.0:metadata">

<!--
Common support functions.
-->
<xsl:import href="check_framework.xsl"/>

<!--
Check IdPs only.
-->
<xsl:template match="md:EntityDescriptor[md:IDPSSODescriptor]">
<!--
Look for IdPs which have either attribute authority or artifact resolution locations
on the same host:port combination as any of the SSO locations.
-->

<!-- XPath expression to evaluate to extract host:port strings from locations -->
<xsl:variable name="extract">substring-before(substring-after(concat(., '/'), 'https://'), '/')</xsl:variable>

<!-- Collect all of the SSO locations -->
<xsl:variable name="ssoLocations" select="descendant::md:SingleSignOnService/@Location"/>
<!-- convert to set of unique host:port strings -->
<xsl:variable name="ssoHosts" select="set:distinct(dyn:map($ssoLocations, $extract))"/>

<!-- Collect all of the attribute authority and artifact resolution locations -->
<xsl:variable name="soapLocations"
select="descendant::md:AttributeService/@Location |
descendant::md:ArtifactResolutionService/@Location"/>
<!-- convert to set of unique host:port strings -->
<xsl:variable name="soapHosts" select="set:distinct(dyn:map($soapLocations, $extract))"/>

<!-- we expect these two sets to be disjoint -->
<xsl:variable name="bothHosts" select="set:distinct($ssoHosts | $soapHosts)"/>
<xsl:if test="count($bothHosts) != count($ssoHosts) + count($soapHosts)">
<xsl:call-template name="fatal">
<xsl:with-param name="m">at least one SOAP location on same vhost as an SSO location</xsl:with-param>
</xsl:call-template>
</xsl:if>
</xsl:template>

</xsl:stylesheet>

0 comments on commit b68d985

Please sign in to comment.