Skip to content
GitLab
Menu
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
f0b219f5
Commit
f0b219f5
authored
Sep 17, 2020
by
Wolfgang Knopki
Browse files
wip: await db connections, session creation
parent
afd3c92a
Pipeline
#974
failed with stages
in 6 minutes and 32 seconds
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
routes/root.js
View file @
f0b219f5
...
...
@@ -65,6 +65,11 @@ router.post('/saml/SSO', passport.authenticate('saml', { failureRedirect: '/logi
const
xmlResponse
=
req
.
body
.
SAMLResponse
;
const
parser
=
new
Saml2js
(
xmlResponse
);
const
userid
=
parser
.
get
(
'
email
'
);
//check, if user exists, if not create.
//else get userid and create session -> set cookie
crypto
.
randomBytes
(
48
,
function
(
ex
,
buf
)
{
var
token
=
buf
.
toString
(
'
hex
'
);
...
...
@@ -73,20 +78,20 @@ router.post('/saml/SSO', passport.authenticate('saml', { failureRedirect: '/logi
token
:
token
,
ip
:
req
.
ip
,
device
:
"
web
"
,
created_at
:
new
Date
()
created_at
:
new
Date
(),
url
:
"
/
"
};
db
.
Session
.
create
(
session
)
.
error
(
err
=>
{
console
.
error
(
"
Error creating Session:
"
,
err
);
res
.
sendStatus
(
500
);
res
.
redirect
(
500
,
"
/
"
);
})
.
then
(()
=>
{
var
domain
=
(
process
.
env
.
NODE_ENV
==
"
production
"
)
?
new
URL
(
config
.
get
(
'
endpoint
'
)).
hostname
:
req
.
headers
.
hostname
;
res
.
cookie
(
'
sdsession
'
,
token
,
{
domain
:
domain
,
httpOnly
:
true
});
res
.
status
(
201
).
json
(
session
);
res
.
redirect
(
302
,
"
/
"
)
});
res
.
redirect
(
"
/
"
);
});
});
...
...
Write
Preview
Markdown
is supported
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