Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
simplesamlphp
Manage
Activity
Members
Labels
Plan
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Perun
Perun ProxyIdP
v1
simplesamlphp
Commits
213b6fe1
Unverified
Commit
213b6fe1
authored
5 years ago
by
Thijs Kinkhorst
Committed by
GitHub
5 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #1337 from msalle/hidefromdiscoverybug
Check explicitly whether array element is defined
parents
3d0de8e2
afcb8c87
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/SimpleSAML/Utils/Config/Metadata.php
+4
-4
4 additions, 4 deletions
lib/SimpleSAML/Utils/Config/Metadata.php
tests/lib/SimpleSAML/Metadata/SAMLParserTest.php
+95
-0
95 additions, 0 deletions
tests/lib/SimpleSAML/Metadata/SAMLParserTest.php
with
99 additions
and
4 deletions
lib/SimpleSAML/Utils/Config/Metadata.php
+
4
−
4
View file @
213b6fe1
...
@@ -298,10 +298,10 @@ class Metadata
...
@@ -298,10 +298,10 @@ class Metadata
*/
*/
public
static
function
isHiddenFromDiscovery
(
array
$metadata
):
bool
public
static
function
isHiddenFromDiscovery
(
array
$metadata
):
bool
{
{
Logger
::
maskErrors
(
E_ALL
);
if
(
!
isset
(
$metadata
[
'EntityAttributes'
][
self
::
$ENTITY_CATEGORY
]))
{
$hidden
=
in_array
(
self
::
$HIDE_FROM_DISCOVERY
,
$metadata
[
'EntityAttributes'
][
self
::
$ENTITY_CATEGORY
],
true
)
;
return
false
;
Logger
::
popErrorMask
();
}
return
$hidden
===
true
;
return
in_array
(
self
::
$HIDE_FROM_DISCOVERY
,
$metadata
[
'EntityAttributes'
][
self
::
$ENTITY_CATEGORY
],
true
)
;
}
}
...
...
This diff is collapsed.
Click to expand it.
tests/lib/SimpleSAML/Metadata/SAMLParserTest.php
+
95
−
0
View file @
213b6fe1
...
@@ -271,4 +271,99 @@ XML
...
@@ -271,4 +271,99 @@ XML
);
);
$this
->
assertEquals
(
$expected
[
'name'
],
$metadata
[
'name'
]);
$this
->
assertEquals
(
$expected
[
'name'
],
$metadata
[
'name'
]);
}
}
/**
* Test entity category hidden from discovery is parsed
* @return void
*/
public
function
testHiddenFromDiscovery
():
void
{
$document
=
DOMDocumentFactory
::
fromString
(
<<<XML
<EntitiesDescriptor xmlns="urn:oasis:names:tc:SAML:2.0:metadata" xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" xmlns:mdattr="urn:oasis:names:tc:SAML:metadata:attribute">
<EntityDescriptor entityID="theEntityID">
<Extensions>
<mdattr:EntityAttributes>
<saml:Attribute Name="http://macedir.org/entity-category" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri">
<saml:AttributeValue>https://example.org/some-category</saml:AttributeValue>
</saml:Attribute>
<saml:Attribute Name="http://macedir.org/entity-category" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri">
<saml:AttributeValue>http://refeds.org/category/hide-from-discovery</saml:AttributeValue>
</saml:Attribute>
</mdattr:EntityAttributes>
</Extensions>
<IDPSSODescriptor protocolSupportEnumeration="urn:oasis:names:tc:SAML:2.0:protocol"/>
</EntityDescriptor>
</EntitiesDescriptor>
XML
);
$entities
=
SAMLParser
::
parseDescriptorsElement
(
$document
->
documentElement
);
$this
->
assertArrayHasKey
(
'theEntityID'
,
$entities
);
$metadata
=
$entities
[
'theEntityID'
]
->
getMetadata20IdP
();
$this
->
assertArrayHasKey
(
'hide.from.discovery'
,
$metadata
);
$this
->
assertTrue
(
$metadata
[
'hide.from.discovery'
]);
}
/**
* Test entity category hidden from discovery is not returned when not present
* @return void
*/
public
function
testHiddenFromDiscoveryNotHidden
():
void
{
$document
=
DOMDocumentFactory
::
fromString
(
<<<XML
<EntitiesDescriptor xmlns="urn:oasis:names:tc:SAML:2.0:metadata" xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" xmlns:mdattr="urn:oasis:names:tc:SAML:metadata:attribute" xmlns:mdrpi="urn:oasis:names:tc:SAML:metadata:rpi">
<EntityDescriptor entityID="theEntityID">
<Extensions>
<mdrpi:RegistrationInfo registrationAuthority="https://safire.ac.za">
<mdrpi:RegistrationPolicy xml:lang="en">https://safire.ac.za/safire/policy/mrps/v20190207.html</mdrpi:RegistrationPolicy>
</mdrpi:RegistrationInfo>
<mdattr:EntityAttributes>
<saml:Attribute Name="http://macedir.org/entity-category" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri">
<saml:AttributeValue>https://example.org/some-category</saml:AttributeValue>
</saml:Attribute>
</mdattr:EntityAttributes>
</Extensions>
<IDPSSODescriptor protocolSupportEnumeration="urn:oasis:names:tc:SAML:2.0:protocol"/>
</EntityDescriptor>
</EntitiesDescriptor>
XML
);
$entities
=
SAMLParser
::
parseDescriptorsElement
(
$document
->
documentElement
);
$this
->
assertArrayHasKey
(
'theEntityID'
,
$entities
);
$metadata
=
$entities
[
'theEntityID'
]
->
getMetadata20IdP
();
$this
->
assertArrayNotHasKey
(
'hide.from.discovery'
,
$metadata
);
}
/**
* Test entity category hidden from discovery is not returned when no mace dir entity categories present
* @return void
*/
public
function
testHiddenFromDiscoveryNotHiddenNoMaceDirEC
():
void
{
$document
=
DOMDocumentFactory
::
fromString
(
<<<XML
<EntitiesDescriptor xmlns="urn:oasis:names:tc:SAML:2.0:metadata" xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" xmlns:mdattr="urn:oasis:names:tc:SAML:metadata:attribute">
<EntityDescriptor entityID="theEntityID">
<Extensions>
<mdattr:EntityAttributes>
<saml:Attribute Name="http://macedir.org/entity-category-support" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri">
<saml:AttributeValue>https://example.org/some-supported-category</saml:AttributeValue>
</saml:Attribute>
</mdattr:EntityAttributes>
</Extensions>
<IDPSSODescriptor protocolSupportEnumeration="urn:oasis:names:tc:SAML:2.0:protocol"/>
</EntityDescriptor>
</EntitiesDescriptor>
XML
);
$entities
=
SAMLParser
::
parseDescriptorsElement
(
$document
->
documentElement
);
$this
->
assertArrayHasKey
(
'theEntityID'
,
$entities
);
$metadata
=
$entities
[
'theEntityID'
]
->
getMetadata20IdP
();
$this
->
assertArrayNotHasKey
(
'hide.from.discovery'
,
$metadata
);
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment