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
f3d42c47
Commit
f3d42c47
authored
4 years ago
by
Tim van Dijen
Browse files
Options
Downloads
Patches
Plain Diff
Fail nicely when unparsable xml is being passed (closes #1327)
parent
08ae7dfd
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
modules/admin/lib/Controller/Federation.php
+37
-26
37 additions, 26 deletions
modules/admin/lib/Controller/Federation.php
modules/admin/templates/metadata_converter.twig
+8
-0
8 additions, 0 deletions
modules/admin/templates/metadata_converter.twig
with
45 additions
and
26 deletions
modules/admin/lib/Controller/Federation.php
+
37
−
26
View file @
f3d42c47
...
@@ -4,6 +4,7 @@ declare(strict_types=1);
...
@@ -4,6 +4,7 @@ declare(strict_types=1);
namespace
SimpleSAML\Module\admin\Controller
;
namespace
SimpleSAML\Module\admin\Controller
;
use
Exception
;
use
SimpleSAML\Auth
;
use
SimpleSAML\Auth
;
use
SimpleSAML\Configuration
;
use
SimpleSAML\Configuration
;
use
SimpleSAML\HTTP\RunnableResponse
;
use
SimpleSAML\HTTP\RunnableResponse
;
...
@@ -354,39 +355,48 @@ class Federation
...
@@ -354,39 +355,48 @@ class Federation
$xmldata
=
trim
(
$xmldata
);
$xmldata
=
trim
(
$xmldata
);
}
}
$error
=
null
;
if
(
!
empty
(
$xmldata
))
{
if
(
!
empty
(
$xmldata
))
{
Utils\XML
::
checkSAMLMessage
(
$xmldata
,
'saml-meta'
);
Utils\XML
::
checkSAMLMessage
(
$xmldata
,
'saml-meta'
);
$entities
=
SAMLParser
::
parseDescriptorsString
(
$xmldata
);
$entities
=
null
;
// get all metadata for the entities
try
{
foreach
(
$entities
as
&
$entity
)
{
$entities
=
SAMLParser
::
parseDescriptorsString
(
$xmldata
);
$entity
=
[
}
catch
(
Exception
$e
)
{
'saml20-sp-remote'
=>
$entity
->
getMetadata20SP
(),
$error
=
$e
->
getMessage
();
'saml20-idp-remote'
=>
$entity
->
getMetadata20IdP
(),
];
}
}
// transpose from $entities[entityid][type] to $output[type][entityid]
if
(
$entities
!==
null
)
{
$output
=
Utils\Arrays
::
transpose
(
$entities
);
// get all metadata for the entities
foreach
(
$entities
as
&
$entity
)
{
$entity
=
[
'saml20-sp-remote'
=>
$entity
->
getMetadata20SP
(),
'saml20-idp-remote'
=>
$entity
->
getMetadata20IdP
(),
];
}
// merge all metadata of each type to a single string which should be added to the corresponding file
// transpose from $entities[entityid][type] to $output[type][entityid]
foreach
(
$output
as
$type
=>
&
$entities
)
{
$output
=
Utils\Arrays
::
transpose
(
$entities
);
$text
=
''
;
foreach
(
$entities
as
$entityId
=>
$entityMetadata
)
{
// merge all metadata of each type to a single string which should be added to the corresponding file
if
(
$entityMetadata
===
null
)
{
foreach
(
$output
as
$type
=>
&
$entities
)
{
continue
;
$text
=
''
;
foreach
(
$entities
as
$entityId
=>
$entityMetadata
)
{
if
(
$entityMetadata
===
null
)
{
continue
;
}
/**
* remove the entityDescriptor element because it is unused,
* and only makes the output harder to read
*/
unset
(
$entityMetadata
[
'entityDescriptor'
]);
$text
.
=
'$metadata['
.
var_export
(
$entityId
,
true
)
.
'] = '
.
VarExporter
::
export
(
$entityMetadata
)
.
";
\n
"
;
}
}
$entities
=
$text
;
/**
* remove the entityDescriptor element because it is unused,
* and only makes the output harder to read
*/
unset
(
$entityMetadata
[
'entityDescriptor'
]);
$text
.
=
'$metadata['
.
var_export
(
$entityId
,
true
)
.
'] = '
.
VarExporter
::
export
(
$entityMetadata
)
.
";
\n
"
;
}
}
$entities
=
$text
;
}
}
}
else
{
}
else
{
$xmldata
=
''
;
$xmldata
=
''
;
...
@@ -398,6 +408,7 @@ class Federation
...
@@ -398,6 +408,7 @@ class Federation
'logouturl'
=>
Utils\Auth
::
getAdminLogoutURL
(),
'logouturl'
=>
Utils\Auth
::
getAdminLogoutURL
(),
'xmldata'
=>
$xmldata
,
'xmldata'
=>
$xmldata
,
'output'
=>
$output
,
'output'
=>
$output
,
'error'
=>
$error
,
];
];
$this
->
menu
->
addOption
(
'logout'
,
$t
->
data
[
'logouturl'
],
Translate
::
noop
(
'Log out'
));
$this
->
menu
->
addOption
(
'logout'
,
$t
->
data
[
'logouturl'
],
Translate
::
noop
(
'Log out'
));
...
...
This diff is collapsed.
Click to expand it.
modules/admin/templates/metadata_converter.twig
+
8
−
0
View file @
f3d42c47
...
@@ -47,6 +47,14 @@
...
@@ -47,6 +47,14 @@
<br><br>
<br><br>
{%
-
set
i
=
i
+
1
%}
{%
-
set
i
=
i
+
1
%}
{%
-
endfor
-
%}
{%
-
endfor
-
%}
{%
elseif
error
is
not
null
%}
<br>
<h2
id=
"error"
>
{{
'An error occured'
|
trans
}}
</h2>
<div
class=
"code-box"
>
<div
class=
"code-box-content"
>
<pre
id=
"error"
class=
"fa-warning"
>
{{
error
}}
</pre>
</div>
</div>
{%
endif
-
%}
{%
endif
-
%}
{%
endblock
content
-
%}
{%
endblock
content
-
%}
{%
block
postload
%}
{%
block
postload
%}
...
...
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