Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
simplesamlphp-module-authswitcher
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
Show more breadcrumbs
Perun
Perun ProxyIdP
v1
simplesamlphp-module-authswitcher
Commits
c1b50daa
Verified
Commit
c1b50daa
authored
2 years ago
by
Pavel Břoušek
Committed by
Pavel Břoušek
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
fix: do not prefer MFA at upstream when not preferred at SP
parent
c757817f
No related branches found
No related tags found
1 merge request
!49
fix: do not prefer MFA at upstream when not preferred at SP
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/DiscoUtils.php
+22
-3
22 additions, 3 deletions
lib/DiscoUtils.php
with
22 additions
and
3 deletions
lib/DiscoUtils.php
+
22
−
3
View file @
c1b50daa
...
@@ -46,13 +46,24 @@ class DiscoUtils
...
@@ -46,13 +46,24 @@ class DiscoUtils
$upstreamRequestedContexts
=
[];
$upstreamRequestedContexts
=
[];
if
(
empty
(
$spRequestedContexts
))
{
if
(
empty
(
$spRequestedContexts
))
{
Logger
::
debug
(
self
::
DEBUG_PREFIX
.
'No AuthnContextClassRef requested, not sending any to upstream IdP.'
);
Logger
::
debug
(
self
::
DEBUG_PREFIX
.
'No AuthnContextClassRef requested, not sending any to upstream IdP.'
);
}
elseif
(
$authnContextHelper
->
MFAin
(
$spRequestedContexts
))
{
}
elseif
(
$authnContextHelper
->
MFAin
(
$spRequestedContexts
)
&&
!
$authnContextHelper
->
SFAin
(
$spRequestedContexts
))
{
Logger
::
debug
(
self
::
DEBUG_PREFIX
.
'SP requested MFA, will prefer MFA at upstream IdP.'
);
Logger
::
debug
(
self
::
DEBUG_PREFIX
.
'SP requires MFA, will prefer MFA at upstream IdP.'
);
$upstreamRequestedContexts
=
array_values
(
array_unique
(
array_merge
(
$mfa_contexts
,
$spRequestedContexts
,
$password_contexts
))
);
}
elseif
(
$authnContextHelper
->
MFAin
(
$spRequestedContexts
)
&&
self
::
getMinIndex
(
$spRequestedContexts
,
$mfa_contexts
)
<
self
::
getMinIndex
(
$spRequestedContexts
,
$password_contexts
)
)
{
Logger
::
debug
(
self
::
DEBUG_PREFIX
.
'SP prefers MFA, will prefer MFA at upstream IdP.'
);
$upstreamRequestedContexts
=
array_values
(
$upstreamRequestedContexts
=
array_values
(
array_unique
(
array_merge
(
$mfa_contexts
,
$spRequestedContexts
,
$password_contexts
))
array_unique
(
array_merge
(
$mfa_contexts
,
$spRequestedContexts
,
$password_contexts
))
);
);
}
else
{
}
else
{
Logger
::
debug
(
self
::
DEBUG_PREFIX
.
'SP d
id
not re
quest
MFA, will prefer SFA at upstream IdP.'
);
Logger
::
debug
(
self
::
DEBUG_PREFIX
.
'SP d
oes
not
p
re
fer
MFA, will prefer SFA at upstream IdP.'
);
$upstreamRequestedContexts
=
array_values
(
$upstreamRequestedContexts
=
array_values
(
array_unique
(
array_merge
(
$spRequestedContexts
,
$password_contexts
,
$mfa_contexts
))
array_unique
(
array_merge
(
$spRequestedContexts
,
$password_contexts
,
$mfa_contexts
))
);
);
...
@@ -67,4 +78,12 @@ class DiscoUtils
...
@@ -67,4 +78,12 @@ class DiscoUtils
$state
[
'saml:RequestedAuthnContext'
][
'AuthnContextClassRef'
]
=
$upstreamRequestedContexts
;
$state
[
'saml:RequestedAuthnContext'
][
'AuthnContextClassRef'
]
=
$upstreamRequestedContexts
;
}
}
}
}
/**
* Returns first index in arr1 of any element from arr2
*/
private
static
function
getMinIndex
(
$arr1
,
$arr2
)
{
return
min
(
array_keys
(
array_intersect
(
$arr1
,
$arr2
)));
}
}
}
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