Skip to content
GitLab
Explore
Projects
Groups
Snippets
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Wolfgang Knopki
Spacedeck-open-SAML
Commits
ba02f861
Commit
ba02f861
authored
4 years ago
by
Wolfgang Knopki
Browse files
Options
Download
Email Patches
Plain Diff
[slo] added slo functionality to main logoutbutton
parent
9d956240
master
saml-integration
1 merge request
!3
Saml integration
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
config/default.json
+2
-1
config/default.json
routes/root.js
+50
-1
routes/root.js
with
52 additions
and
2 deletions
+52
-2
config/default.json
+
2
-
1
View file @
ba02f861
...
@@ -33,5 +33,6 @@
...
@@ -33,5 +33,6 @@
"path"
:
"http://localhost:9666/saml/SSO"
,
"path"
:
"http://localhost:9666/saml/SSO"
,
"entryPoint"
:
"https://m4lab.hft-stuttgart.de/idp/saml2/idp/SSOService.php"
,
"entryPoint"
:
"https://m4lab.hft-stuttgart.de/idp/saml2/idp/SSOService.php"
,
"issuer"
:
"spacedeck.m4lab.hft-stuttgart.de"
"issuer"
:
"spacedeck.m4lab.hft-stuttgart.de"
,
"logoutUrl"
:
"https://m4lab.hft-stuttgart.de/idp/saml2/idp/SingleLogoutService.php"
}
}
This diff is collapsed.
Click to expand it.
routes/root.js
+
50
-
1
View file @
ba02f861
...
@@ -32,6 +32,7 @@ const uuidv4 = require('uuid/v4');
...
@@ -32,6 +32,7 @@ const uuidv4 = require('uuid/v4');
var
samlStrategy
=
new
SamlStrategy
({
var
samlStrategy
=
new
SamlStrategy
({
// URL that goes from the Identity Provider -> Service Provider
// URL that goes from the Identity Provider -> Service Provider
callbackUrl
:
config
.
path
,
callbackUrl
:
config
.
path
,
logoutUrl
:
config
.
logoutUrl
,
entryPoint
:
config
.
entryPoint
,
entryPoint
:
config
.
entryPoint
,
issuer
:
config
.
issuer
,
issuer
:
config
.
issuer
,
...
@@ -245,10 +246,58 @@ router.get('/login', passport.authenticate('saml',
...
@@ -245,10 +246,58 @@ router.get('/login', passport.authenticate('saml',
// res.render('spacedeck', { config:config, user:req.user });
// res.render('spacedeck', { config:config, user:req.user });
//});
//});
function
samlLogout
(
req
,
res
){
console
.
log
(
"
enter samlLogout
"
)
try
{
samlStrategy
.
logout
(
req
,
function
(
err
,
uri
){
if
(
err
)
console
.
log
(
"
can't generate logout URL: ${err}
"
);
req
.
logout
();
var
token
=
req
.
cookies
[
'
sdsession
'
];
db
.
Session
.
findOne
({
where
:
{
token
:
token
}})
.
then
(
session
=>
{
session
.
destroy
();
});
var
domain
=
(
process
.
env
.
NODE_ENV
==
"
production
"
)
?
new
URL
(
config
.
get
(
'
endpoint
'
)).
hostname
:
req
.
headers
.
hostname
;
res
.
clearCookie
(
'
sdsession
'
,
{
domain
:
domain
});
console
.
log
(
"
clear Cookie
"
)
res
.
redirect
(
uri
);
});
}
catch
(
err
){
if
(
err
)
console
.
log
(
`Exception on URL:
${
err
}
`
);
req
.
logout
();
var
token
=
req
.
cookies
[
'
sdsession
'
];
db
.
Session
.
findOne
({
where
:
{
token
:
token
}})
.
then
(
session
=>
{
session
.
destroy
();
});
var
domain
=
(
process
.
env
.
NODE_ENV
==
"
production
"
)
?
new
URL
(
config
.
get
(
'
endpoint
'
)).
hostname
:
req
.
headers
.
hostname
;
res
.
clearCookie
(
'
sdsession
'
,
{
domain
:
domain
});
console
.
log
(
"
clear Cookie on error
"
)
res
.
redirect
(
"
/login
"
);
}
}
router
.
get
(
'
/logout
'
,
(
req
,
res
)
=>
{
router
.
get
(
'
/logout
'
,
(
req
,
res
)
=>
{
res
.
render
(
'
spacedeck
'
,
{
config
:
config
,
user
:
req
.
user
});
console
.
log
(
"
logout pressed
"
)
if
(
req
.
user
==
null
)
{
console
.
log
(
"
req.user == null
"
);
return
res
.
redirect
(
'
/
'
);
}
samlLogout
(
req
,
res
);
});
});
router
.
get
(
'
/saml/SLO
'
,
(
req
,
res
,
next
)
=>
{
console
.
log
(
"
received logout request
"
);
var
token
=
req
.
cookies
[
'
sdsession
'
];
if
(
token
)
{
return
next
();
}
else
{
return
res
.
redirect
(
'
/
'
);
//best be landing page of everything
}
},
samlLogout
);
router
.
get
(
'
/t/:id
'
,
(
req
,
res
)
=>
{
router
.
get
(
'
/t/:id
'
,
(
req
,
res
)
=>
{
res
.
cookie
(
'
spacedeck_locale
'
,
req
.
params
.
id
,
{
maxAge
:
900000
,
httpOnly
:
true
});
res
.
cookie
(
'
spacedeck_locale
'
,
req
.
params
.
id
,
{
maxAge
:
900000
,
httpOnly
:
true
});
var
path
=
"
/
"
;
var
path
=
"
/
"
;
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Snippets