From bd8289828a4515b71e33cd8504e10185db2d97c9 Mon Sep 17 00:00:00 2001 From: Alberto Asuero Date: Wed, 8 Oct 2014 13:31:33 +0200 Subject: [PATCH] Logout --- library.js | 34 ++++++++++++++++++++++------ package.json | 5 ++-- templates/admin/plugins/sso-saml.tpl | 6 +++++ 3 files changed, 36 insertions(+), 9 deletions(-) diff --git a/library.js b/library.js index abc31eb..d117f14 100644 --- a/library.js +++ b/library.js @@ -9,7 +9,8 @@ fs = module.parent.require('fs'), path = module.parent.require('path'), nconf = module.parent.require('nconf'), - async = module.parent.require('async'); + async = module.parent.require('async'), + winston = require('winston'); var constants = Object.freeze({ 'name': "SAML", @@ -94,6 +95,30 @@ } ); + + if (meta.config['sso:saml:logouturl']) { + + app.get(meta.config['sso:saml:logouturl'],function(req,res){ + if (req.user && parseInt(req.user.uid, 10) > 0) { + winston.info('[Auth] Session ' + req.sessionID + ' logout (uid: ' + req.user.uid + ')'); + + var ws = module.parent.require('./socket.io'); + ws.logoutUser(req.user.uid); + + req.logout(); + + if (meta.config['sso:saml:logoutredirecturl']){ + res.redirect(meta.config['sso:saml:logoutredirecturl']); + } + else{ + res.redirect("/"); + } + } + + + }); + } + } callback(); @@ -131,12 +156,7 @@ }); } else { - console.log({ - username: userdata.username, - email: userdata.email, - fullname : userdata.cn + " " + userdata.sn - - }); + // New User user.create({ username: userdata.username, diff --git a/package.json b/package.json index 6a2e8d5..f7c61f3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nodebb-plugin-sso-saml", - "version": "0.0.3", + "version": "0.0.4", "description": "NodeBB SAML SSO", "main": "library.js", "repository": { @@ -27,7 +27,8 @@ "readme": "# NodeBB SAML SSO\n\nNodeBB Plugin that allows users to login/register via a account.\n\n## Installation\n\n npm install nodebb-plugin-sso-saml\n", "readmeFilename": "README.md", "dependencies": { - "passport-saml": "~0.5.3" + "passport-saml": "~0.5.3", + "winston" : "0.8.1" }, "homepage": "https://github.com/GeographicaGS/nodebb-plugin-sso-saml.git", "_id": "nodebb-plugin-sso-saml@0.0.2" diff --git a/templates/admin/plugins/sso-saml.tpl b/templates/admin/plugins/sso-saml.tpl index 9f2e0fe..e43f981 100644 --- a/templates/admin/plugins/sso-saml.tpl +++ b/templates/admin/plugins/sso-saml.tpl @@ -17,6 +17,12 @@
+
+ + +
+ +