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
c4eae6ad
Unverified
Commit
c4eae6ad
authored
6 years ago
by
Jaime Pérez Crespo
Browse files
Options
Downloads
Patches
Plain Diff
bugfix: Encrypted attributes should also be automatically decrypted.
parent
00198aac
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/saml/lib/Message.php
+46
-0
46 additions, 0 deletions
modules/saml/lib/Message.php
with
46 additions
and
0 deletions
modules/saml/lib/Message.php
+
46
−
0
View file @
c4eae6ad
...
...
@@ -407,6 +407,51 @@ class sspmod_saml_Message
}
/**
* Decrypt any encrypted attributes in an assertion.
*
* @param SimpleSAML_Configuration $srcMetadata The metadata of the sender (IdP).
* @param SimpleSAML_Configuration $dstMetadata The metadata of the recipient (SP).
* @param \SAML2\Assertion|\SAML2\Assertion $assertion The assertion containing any possibly encrypted attributes.
*
* @return void
*
* @throws \SimpleSAML_Error_Exception if we cannot get the decryption keys or decryption fails.
*/
private
static
function
decryptAttributes
(
SimpleSAML_Configuration
$srcMetadata
,
SimpleSAML_Configuration
$dstMetadata
,
\SAML2\Assertion
&
$assertion
)
{
if
(
!
$assertion
->
hasEncryptedAttributes
())
{
return
;
}
try
{
$keys
=
self
::
getDecryptionKeys
(
$srcMetadata
,
$dstMetadata
);
}
catch
(
Exception
$e
)
{
throw
new
SimpleSAML_Error_Exception
(
'Error decrypting attributes: '
.
$e
->
getMessage
());
}
$blacklist
=
self
::
getBlacklistedAlgorithms
(
$srcMetadata
,
$dstMetadata
);
$error
=
true
;
foreach
(
$keys
as
$i
=>
$key
)
{
try
{
$assertion
->
decryptAttributes
(
$key
,
$blacklist
);
SimpleSAML\Logger
::
debug
(
'Attribute decryption with key #'
.
$i
.
' succeeded.'
);
$error
=
false
;
break
;
}
catch
(
Exception
$e
)
{
SimpleSAML\Logger
::
debug
(
'Attribute decryption failed with exception: '
.
$e
->
getMessage
());
}
}
if
(
$error
)
{
throw
new
SimpleSAML_Error_Exception
(
'Could not decrypt the attributes'
);
}
}
/**
* Retrieve the status code of a response as a sspmod_saml_Error.
*
...
...
@@ -609,6 +654,7 @@ class sspmod_saml_Message
assert
(
is_bool
(
$responseSigned
));
$assertion
=
self
::
decryptAssertion
(
$idpMetadata
,
$spMetadata
,
$assertion
);
self
::
decryptAttributes
(
$idpMetadata
,
$spMetadata
,
$assertion
);
if
(
!
self
::
checkSign
(
$idpMetadata
,
$assertion
))
{
if
(
!
$responseSigned
)
{
...
...
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