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
f5e8e426
Commit
f5e8e426
authored
2 years ago
by
Tim van Dijen
Browse files
Options
Downloads
Patches
Plain Diff
Fix NameID generation
parent
db671f0a
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/src/IdP/SAML2.php
+5
-49
5 additions, 49 deletions
modules/saml/src/IdP/SAML2.php
with
5 additions
and
49 deletions
modules/saml/src/IdP/SAML2.php
+
5
−
49
View file @
f5e8e426
...
...
@@ -954,40 +954,6 @@ class SAML2
}
/**
* Calculate the NameID value that should be used.
*
* @param \SimpleSAML\Configuration $idpMetadata The metadata of the IdP.
* @param \SimpleSAML\Configuration $spMetadata The metadata of the SP.
* @param array &$state The authentication state of the user.
*
* @return string|null The NameID value.
*/
private
static
function
generateNameIdValue
(
Configuration
$idpMetadata
,
Configuration
$spMetadata
,
array
&
$state
):
?string
{
$attribute
=
$spMetadata
->
getOptionalString
(
'simplesaml.nameidattribute'
,
null
);
if
(
$attribute
===
null
)
{
$attribute
=
$idpMetadata
->
getOptionalString
(
'simplesaml.nameidattribute'
,
null
);
if
(
$attribute
===
null
)
{
Logger
::
error
(
'Unable to generate NameID. Check the simplesaml.nameidattribute option.'
);
return
null
;
}
}
$attributes
=
$state
[
'Attributes'
];
if
(
!
array_key_exists
(
$attribute
,
$attributes
))
{
Logger
::
error
(
'Unable to add NameID: Missing '
.
var_export
(
$attribute
,
true
)
.
' in the attributes of the user.'
);
return
null
;
}
return
$attributes
[
$attribute
][
0
];
}
/**
* Helper function for encoding attributes.
*
...
...
@@ -1267,25 +1233,15 @@ class SAML2
if
(
isset
(
$state
[
'saml:NameID'
][
$nameIdFormat
]))
{
$nameId
=
$state
[
'saml:NameID'
][
$nameIdFormat
];
$nameId
->
setFormat
(
$nameIdFormat
);
}
else
{
$spNameQualifier
=
$spMetadata
->
getOptionalString
(
'SPNameQualifier'
,
null
);
if
(
$spNameQualifier
===
null
)
{
$spNameQualifier
=
$spMetadata
->
getString
(
'entityid'
);
}
if
(
$nameIdFormat
===
Constants
::
NAMEID_TRANSIENT
)
{
// generate a random id
$nameIdValue
=
$randomUtils
->
generateID
();
}
else
{
/* this code will end up generating either a fixed assigned id (via nameid.attribute)
or random id if not assigned/configured */
$nameIdValue
=
self
::
generateNameIdValue
(
$idpMetadata
,
$spMetadata
,
$state
);
if
(
$nameIdValue
===
null
)
{
Logger
::
warning
(
'Falling back to transient NameID.'
);
$nameIdFormat
=
Constants
::
NAMEID_TRANSIENT
;
$nameIdValue
=
$randomUtils
->
generateID
();
}
}
$spNameQualifier
=
$spMetadata
->
getOptionalString
(
'SPNameQualifier'
,
null
);
if
(
$spNameQualifier
===
null
)
{
$spNameQualifier
=
$spMetadata
->
getString
(
'entityid'
);
}
$nameId
=
new
NameID
();
...
...
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