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
0
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
3a12e85d
Commit
3a12e85d
authored
9 years ago
by
Jaime Perez Crespo
Browse files
Options
Downloads
Patches
Plain Diff
Avoid code duplication when checking if an entity should be hidden from discovery service.
parent
b5757a05
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
lib/SimpleSAML/Metadata/SAMLParser.php
+2
-6
2 additions, 6 deletions
lib/SimpleSAML/Metadata/SAMLParser.php
lib/SimpleSAML/Utils/Config/Metadata.php
+42
-1
42 additions, 1 deletion
lib/SimpleSAML/Utils/Config/Metadata.php
www/saml2/idp/metadata.php
+2
-6
2 additions, 6 deletions
www/saml2/idp/metadata.php
with
46 additions
and
13 deletions
lib/SimpleSAML/Metadata/SAMLParser.php
+
2
−
6
View file @
3a12e85d
...
@@ -490,12 +490,8 @@ class SimpleSAML_Metadata_SAMLParser
...
@@ -490,12 +490,8 @@ class SimpleSAML_Metadata_SAMLParser
$metadata
[
'EntityAttributes'
]
=
$this
->
entityAttributes
;
$metadata
[
'EntityAttributes'
]
=
$this
->
entityAttributes
;
// check for entity categories
// check for entity categories
$entity_category
=
'http://macedir.org/entity-category'
;
if
(
SimpleSAML\Utils\Config\Metadata
::
isHiddenFromDiscovery
(
$metadata
))
{
$hide_from_discovery
=
'http://refeds.org/category/hide-from-discovery'
;
$metadata
[
'hide.from.discovery'
]
=
true
;
if
(
array_key_exists
(
$entity_category
,
$metadata
[
'EntityAttributes'
]))
{
if
(
in_array
(
$hide_from_discovery
,
$metadata
[
'EntityAttributes'
][
$entity_category
]))
{
$metadata
[
'hide.from.discovery'
]
=
true
;
}
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
lib/SimpleSAML/Utils/Config/Metadata.php
+
42
−
1
View file @
3a12e85d
...
@@ -10,6 +10,22 @@ namespace SimpleSAML\Utils\Config;
...
@@ -10,6 +10,22 @@ namespace SimpleSAML\Utils\Config;
class
Metadata
class
Metadata
{
{
/**
* The string that identities Entity Categories.
*
* @var string
*/
public
static
$ENTITY_CATEGORY
=
'http://macedir.org/entity-category'
;
/**
* The string the identifies the REFEDS "Hide From Discovery" Entity Category.
*
* @var string
*/
public
static
$HIDE_FROM_DISCOVERY
=
'http://refeds.org/category/hide-from-discovery'
;
/**
/**
* @var array The valid configuration options for a contact configuration array.
* @var array The valid configuration options for a contact configuration array.
* @see "Metadata for the OASIS Security Assertion Markup Language (SAML) V2.0", section 2.3.2.2.
* @see "Metadata for the OASIS Security Assertion Markup Language (SAML) V2.0", section 2.3.2.2.
...
@@ -157,7 +173,9 @@ class Metadata
...
@@ -157,7 +173,9 @@ class Metadata
if
(
empty
(
$contact
[
'telephoneNumber'
])
||
if
(
empty
(
$contact
[
'telephoneNumber'
])
||
!
(
is_string
(
$contact
[
'telephoneNumber'
])
||
is_array
(
$contact
[
'telephoneNumber'
]))
!
(
is_string
(
$contact
[
'telephoneNumber'
])
||
is_array
(
$contact
[
'telephoneNumber'
]))
)
{
)
{
throw
new
\InvalidArgumentException
(
'"telephoneNumber" must be a string or an array and cannot be empty.'
);
throw
new
\InvalidArgumentException
(
'"telephoneNumber" must be a string or an array and cannot be empty.'
);
}
}
if
(
is_array
(
$contact
[
'telephoneNumber'
]))
{
if
(
is_array
(
$contact
[
'telephoneNumber'
]))
{
foreach
(
$contact
[
'telephoneNumber'
]
as
$address
)
{
foreach
(
$contact
[
'telephoneNumber'
]
as
$address
)
{
...
@@ -223,4 +241,27 @@ class Metadata
...
@@ -223,4 +241,27 @@ class Metadata
*/
*/
return
$firstAllowed
;
return
$firstAllowed
;
}
}
/**
* Determine if an entity should be hidden in the discovery service.
*
* This method searches for the "Hide From Discovery" REFEDS Entity Category, and tells if the entity should be
* hidden or not depending on it.
*
* @see https://refeds.org/category/hide-from-discovery
*
* @param array $metadata An associative array with the metadata representing an entity.
*
* @return boolean True if the entity should be hidden, false otherwise.
*/
public
static
function
isHiddenFromDiscovery
(
$metadata
)
{
if
(
array_key_exists
(
self
::
$ENTITY_CATEGORY
,
$metadata
[
'EntityAttributes'
]))
{
if
(
in_array
(
self
::
$HIDE_FROM_DISCOVERY
,
$metadata
[
'EntityAttributes'
][
self
::
$ENTITY_CATEGORY
]))
{
return
true
;
}
}
return
false
;
}
}
}
This diff is collapsed.
Click to expand it.
www/saml2/idp/metadata.php
+
2
−
6
View file @
3a12e85d
...
@@ -147,12 +147,8 @@ try {
...
@@ -147,12 +147,8 @@ try {
$metaArray
[
'EntityAttributes'
]
=
$idpmeta
->
getArray
(
'EntityAttributes'
);
$metaArray
[
'EntityAttributes'
]
=
$idpmeta
->
getArray
(
'EntityAttributes'
);
// check for entity categories
// check for entity categories
$entity_category
=
'http://macedir.org/entity-category'
;
if
(
SimpleSAML\Utils\Config\Metadata
::
isHiddenFromDiscovery
(
$metaArray
))
{
$hide_from_discovery
=
'http://refeds.org/category/hide-from-discovery'
;
$metaArray
[
'hide.from.discovery'
]
=
true
;
if
(
array_key_exists
(
$entity_category
,
$metaArray
[
'EntityAttributes'
]))
{
if
(
in_array
(
$hide_from_discovery
,
$metaArray
[
'EntityAttributes'
][
$entity_category
]))
{
$metaArray
[
'hide.from.discovery'
]
=
true
;
}
}
}
}
}
...
...
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