From b9d4a419d8049f995771a7990e07f827084c6981 Mon Sep 17 00:00:00 2001 From: Olav Morken <olav.morken@uninett.no> Date: Fri, 18 Oct 2013 10:35:43 +0000 Subject: [PATCH] Add support for exporting shibmd:Scope metadata with regular expressions. Thanks to Brook Schofield for implementing this! git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@3281 44740490-163a-0410-bde0-09ae8108e29a --- docs/simplesamlphp-reference-idp-hosted.txt | 2 ++ lib/SimpleSAML/Metadata/SAMLBuilder.php | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/docs/simplesamlphp-reference-idp-hosted.txt b/docs/simplesamlphp-reference-idp-hosted.txt index 6ee064059..3fa8b5f40 100644 --- a/docs/simplesamlphp-reference-idp-hosted.txt +++ b/docs/simplesamlphp-reference-idp-hosted.txt @@ -108,6 +108,8 @@ Common options `scope` : An array with scopes for this IdP. The scopes will be added to the generated XML metadata. + A scope can either be a domain name or a regular expression + matching a number of domains. `userid.attribute` : The attribute name of an attribute which uniquely identifies diff --git a/lib/SimpleSAML/Metadata/SAMLBuilder.php b/lib/SimpleSAML/Metadata/SAMLBuilder.php index 923864807..da63e8991 100644 --- a/lib/SimpleSAML/Metadata/SAMLBuilder.php +++ b/lib/SimpleSAML/Metadata/SAMLBuilder.php @@ -114,7 +114,12 @@ class SimpleSAML_Metadata_SAMLBuilder { foreach ($metadata->getArray('scope') as $scopetext) { $s = new SAML2_XML_shibmd_Scope(); $s->scope = $scopetext; - $s->regexp = FALSE; + // Check whether $ ^ ( ) * | \ are in a scope -> assume regex. + if (1 === preg_match('/[\$\^\)\(\*\|\\\\]/', $scopetext)) { + $s->regexp = TRUE; + } else { + $s->regexp = FALSE; + } $e->Extensions[] = $s; } } -- GitLab