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
GitLab 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
3c5c3b60
Commit
3c5c3b60
authored
Jun 24, 2022
by
Thijs Kinkhorst
Browse files
Options
Downloads
Patches
Plain Diff
Move NameId generation to separate method for understandability
No functional changes
parent
e11c0eaf
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/saml/src/IdP/SAML2.php
+26
-15
26 additions, 15 deletions
modules/saml/src/IdP/SAML2.php
with
26 additions
and
15 deletions
modules/saml/src/IdP/SAML2.php
+
26
−
15
View file @
3c5c3b60
...
@@ -1214,9 +1214,32 @@ class SAML2
...
@@ -1214,9 +1214,32 @@ class SAML2
$a
->
setAttributes
(
$attributes
);
$a
->
setAttributes
(
$attributes
);
}
}
$nameId
=
self
::
generateNameId
(
$idpMetadata
,
$spMetadata
,
$state
);
$state
[
'saml:idp:NameID'
]
=
$nameId
;
$a
->
setNameId
(
$nameId
);
$encryptNameId
=
$spMetadata
->
getOptionalBoolean
(
'nameid.encryption'
,
null
);
if
(
$encryptNameId
===
null
)
{
$encryptNameId
=
$idpMetadata
->
getOptionalBoolean
(
'nameid.encryption'
,
false
);
}
if
(
$encryptNameId
)
{
$a
->
encryptNameId
(
\SimpleSAML\Module\saml\Message
::
getEncryptionKey
(
$spMetadata
));
}
return
$a
;
}
/**
* Helper for buildAssertion to decide on an NameID to set
*/
private
static
function
generateNameId
(
Configuration
$idpMetadata
,
Configuration
$spMetadata
,
array
$state
):
NameID
{
$nameIdFormat
=
null
;
$nameIdFormat
=
null
;
// generate the NameID for the assertion
if
(
isset
(
$state
[
'saml:NameIDFormat'
]))
{
if
(
isset
(
$state
[
'saml:NameIDFormat'
]))
{
$nameIdFormat
=
$state
[
'saml:NameIDFormat'
];
$nameIdFormat
=
$state
[
'saml:NameIDFormat'
];
}
}
...
@@ -1236,6 +1259,7 @@ class SAML2
...
@@ -1236,6 +1259,7 @@ class SAML2
}
else
{
}
else
{
if
(
$nameIdFormat
===
Constants
::
NAMEID_TRANSIENT
)
{
if
(
$nameIdFormat
===
Constants
::
NAMEID_TRANSIENT
)
{
// generate a random id
// generate a random id
$randomUtils
=
new
Utils\Random
();
$nameIdValue
=
$randomUtils
->
generateID
();
$nameIdValue
=
$randomUtils
->
generateID
();
}
}
...
@@ -1250,22 +1274,9 @@ class SAML2
...
@@ -1250,22 +1274,9 @@ class SAML2
$nameId
->
setSPNameQualifier
(
$spNameQualifier
);
$nameId
->
setSPNameQualifier
(
$spNameQualifier
);
}
}
$state
[
'saml:idp:NameID'
]
=
$nameId
;
return
$nameId
;
$a
->
setNameId
(
$nameId
);
$encryptNameId
=
$spMetadata
->
getOptionalBoolean
(
'nameid.encryption'
,
null
);
if
(
$encryptNameId
===
null
)
{
$encryptNameId
=
$idpMetadata
->
getOptionalBoolean
(
'nameid.encryption'
,
false
);
}
if
(
$encryptNameId
)
{
$a
->
encryptNameId
(
\SimpleSAML\Module\saml\Message
::
getEncryptionKey
(
$spMetadata
));
}
}
return
$a
;
}
/**
/**
* Encrypt an assertion.
* Encrypt an assertion.
*
*
...
...
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