Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
GIP RENATER
switch-wayf
Commits
940ca006
Commit
940ca006
authored
Jan 08, 2018
by
Lukas Haemmerle
Browse files
Ensure that IdP domain cookie array contains no more than 5 elements
parent
ba284bc1
Changes
1
Show whitespace changes
Inline
Side-by-side
js/embeddedWAYF.js
View file @
940ca006
...
...
@@ -220,20 +220,35 @@ function setDomainSAMLDomainCookie(entityID){
// Create and store SAML domain cookie on host where WAYF is embedded
var
currentDomainCookie
=
getCookie
(
'
_saml_idp
'
);
var
encodedEntityID
=
encodeBase64
(
entityID
);
if
(
currentDomainCookie
==
null
){
currentDomainCookie
=
''
;
}
var
oldIdPs
=
currentDomainCookie
.
split
(
'
'
);
var
newCookie
=
''
;
for
(
var
i
=
0
;
i
<
oldIdPs
.
length
;
i
++
)
{
if
(
oldIdPs
[
i
]
!=
encodedEntityID
&&
oldIdPs
[
i
]
!=
''
){
newCookie
+=
oldIdPs
[
i
]
+
'
'
;
// Ensure current IdP is not already in array
var
currentIdPs
=
currentDomainCookie
.
split
(
'
'
);
var
newIdPs
=
new
Array
();
for
(
var
i
=
0
;
i
<
currentIdPs
.
length
;
i
++
)
{
if
(
currentIdPs
[
i
]
!=
encodedEntityID
&&
currentIdPs
[
i
]
!=
''
){
newIdPs
.
push
(
currentIdPs
[
i
]);
}
}
// Add new IdP
newIdPs
.
push
(
encodedEntityID
);
// Ensure array is no longer than 5 IdPs
while
(
newIdPs
.
length
>
5
){
newIdPs
.
shift
();
}
newCookie
+=
encodedEntityID
;
setCookie
(
'
<?php echo $SAMLDomainCookieName ?>
'
,
newCookie
,
100
);
// Compose cookie value
var
newDomainCookie
=
''
;
for
(
var
i
=
0
;
i
<
newIdPs
.
length
;
i
++
)
{
newDomainCookie
+=
newIdPs
[
i
]
+
'
'
;
}
// Set cookie value
setCookie
(
'
<?php echo $SAMLDomainCookieName ?>
'
,
newDomainCookie
.
trim
()
,
100
);
}
function
setCookie
(
c_name
,
value
,
expiredays
){
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment