Fixed issue: /api/admin/plugins/sso-saml Not Found
https://github.com/GeographicaGS/nodebb-plugin-sso-saml/issues/2
This commit is contained in:
parent
f48592e2fd
commit
3317bc7d89
1 changed files with 15 additions and 14 deletions
29
library.js
29
library.js
|
|
@ -65,30 +65,31 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SAML.init = function(app, middleware, controllers, callback) {
|
SAML.init = function(params, callback) {
|
||||||
|
|
||||||
function render(req, res, next) {
|
function render(req, res, next) {
|
||||||
res.render('admin/plugins/sso-saml', {});
|
res.render('admin/plugins/sso-saml', {});
|
||||||
}
|
}
|
||||||
|
|
||||||
app.get('/admin/plugins/sso-saml', middleware.admin.buildHeader, render);
|
params.router.get('/admin/plugins/sso-saml', params.middleware.admin.buildHeader, render);
|
||||||
app.get('/api/admin/plugins/sso-saml', render);
|
params.router.get('/api/admin/plugins/sso-saml', render);
|
||||||
|
|
||||||
if (samlObj){
|
if (samlObj){
|
||||||
|
|
||||||
if (meta.config["sso:saml:metadata"]) {
|
if (meta.config["sso:saml:metadata"]) {
|
||||||
app.get(meta.config["sso:saml:metadata"], function(req, res) {
|
params.router.get(meta.config["sso:saml:metadata"], function(req, res) {
|
||||||
if (meta.config["sso:saml:servercrt"]){
|
if (meta.config["sso:saml:servercrt"]){
|
||||||
var cert = fs.readFileSync(meta.config["sso:saml:servercrt"], 'utf-8');
|
var cert = fs.readFileSync(meta.config["sso:saml:servercrt"], 'utf-8');
|
||||||
res.header("Content-Type", "application/xml");
|
res.header("Content-Type", "application/xml");
|
||||||
res.send(samlObj.generateServiceProviderMetadata(cert))
|
res.send(samlObj.generateServiceProviderMetadata(cert))
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
res.send("No servercrt specified. Please enter it at nodebb admin panel.");
|
res.send("No servercrt specified. Please enter it at nodebb admin panel.");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
app.post(meta.config['sso:saml:callbackpath'],
|
params.router.post(meta.config['sso:saml:callbackpath'],
|
||||||
passport.authenticate('saml'),
|
passport.authenticate('saml'),
|
||||||
function(req, res, next){
|
function(req, res, next){
|
||||||
if (meta.config['sso:saml:loginsuccessredirecturl']){
|
if (meta.config['sso:saml:loginsuccessredirecturl']){
|
||||||
|
|
@ -97,14 +98,14 @@
|
||||||
else{
|
else{
|
||||||
res.redirect("/");
|
res.redirect("/");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
if (meta.config['sso:saml:logouturl']) {
|
if (meta.config['sso:saml:logouturl']) {
|
||||||
|
|
||||||
app.get(meta.config['sso:saml:logouturl'],function(req,res){
|
params.router.get(meta.config['sso:saml:logouturl'],function(req,res){
|
||||||
if (req.user && parseInt(req.user.uid, 10) > 0) {
|
if (req.user && parseInt(req.user.uid, 10) > 0) {
|
||||||
winston.info('[Auth] Session ' + req.sessionID + ' logout (uid: ' + req.user.uid + ')');
|
winston.info('[Auth] Session ' + req.sessionID + ' logout (uid: ' + req.user.uid + ')');
|
||||||
|
|
||||||
|
|
@ -120,13 +121,13 @@
|
||||||
res.redirect("/");
|
res.redirect("/");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
callback();
|
callback();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue