user authentication - retrieve information from SSOprovider
This commit is contained in:
parent
f1666311c8
commit
8049923711
@ -1,18 +1,35 @@
|
|||||||
var express = require('express');
|
var express = require('express');
|
||||||
var route = express.Router();
|
var route = express.Router();
|
||||||
|
|
||||||
|
const cfg = require(global['__dirname']+'/bin/config');
|
||||||
|
const sso = require(global['__dirname']+'/bin/sso/module');
|
||||||
|
|
||||||
route.get('/login', (req, res) => {
|
route.get('/login', (req, res) => {
|
||||||
// TODO: login
|
// TODO: login
|
||||||
let a = global['modules'].sso.createAuthentication({
|
let a = sso.createAuthentication({
|
||||||
url: global['gds'].cfg.sso.authenticator,
|
url: cfg.sso.authenticator,
|
||||||
appId: global['gds'].cfg.sso.appId
|
appId: cfg.sso.appId
|
||||||
});
|
});
|
||||||
res.redirect(a);
|
res.redirect(a);
|
||||||
});
|
});
|
||||||
|
|
||||||
route.get('/authenticate', (req, res) => {
|
route.get('/authenticate', async (req, res) => {
|
||||||
// TODO: authenticate
|
if(req.query && req.query.uid && req.query.token) {
|
||||||
res.end();
|
let auth = await sso.authenticateUser({
|
||||||
|
userId: req.query.uid,
|
||||||
|
token: req.query.token,
|
||||||
|
appId: cfg.sso.appId,
|
||||||
|
appSecret: cfg.sso.appSecret
|
||||||
|
});
|
||||||
|
if(auth) {
|
||||||
|
req.session.user = {
|
||||||
|
ssoId: req.query.uid,
|
||||||
|
initializeUser: true
|
||||||
|
};
|
||||||
|
return res.redirect(cfg.web.rootUrl);
|
||||||
|
}
|
||||||
|
else return res.redirect(cfg.web.rootUrl + 'auth/login');
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
route.get('/logout', (req, res) => {
|
route.get('/logout', (req, res) => {
|
||||||
@ -31,7 +48,7 @@ route.get('/logout', (req, res) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if(global['gds'].debug) {
|
if(global['debug']) {
|
||||||
// DEBUG info
|
// DEBUG info
|
||||||
route.get('/info', (req, res) => {
|
route.get('/info', (req, res) => {
|
||||||
let obj = {};
|
let obj = {};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user