|
|
@ -364,10 +364,10 @@ var module = {};
|
|
|
|
* samlToken: string}>} SSO sessions
|
|
|
|
* samlToken: string}>} SSO sessions
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
function getSsoSessions() {
|
|
|
|
function getSsoSessions() {
|
|
|
|
var ssoSessions = session.get(constants.CACHE_KEY_SSO_SESSIONS);
|
|
|
|
var ssoSessions = application.get(constants.CACHE_KEY_SSO_SESSIONS);
|
|
|
|
if (!ssoSessions) {
|
|
|
|
if (!ssoSessions) {
|
|
|
|
ssoSessions = {};
|
|
|
|
ssoSessions = {};
|
|
|
|
session.put(constants.CACHE_KEY_SSO_SESSIONS, ssoSessions);
|
|
|
|
application.put(constants.CACHE_KEY_SSO_SESSIONS, ssoSessions);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ssoSessions;
|
|
|
|
return ssoSessions;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -486,14 +486,11 @@ var module = {};
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
module.ssoAcs = function (request, response) {
|
|
|
|
module.ssoAcs = function (request, response) {
|
|
|
|
var samlResponse = request.getParameter("SAMLResponse");
|
|
|
|
var samlResponse = request.getParameter("SAMLResponse");
|
|
|
|
if (!samlResponse) {
|
|
|
|
var samlRequest = request.getParameter('SAMLRequest');
|
|
|
|
var msg = "SAML response is not found in request parameters.";
|
|
|
|
|
|
|
|
log.error(msg);
|
|
|
|
|
|
|
|
response.sendError(400, msg);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
var ssoClient = require("sso").client;
|
|
|
|
var ssoClient = require("sso").client;
|
|
|
|
var samlResponseObj;
|
|
|
|
var samlResponseObj;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (samlResponse) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
samlResponseObj = ssoClient.getSamlObject(samlResponse);
|
|
|
|
samlResponseObj = ssoClient.getSamlObject(samlResponse);
|
|
|
|
} catch (e) {
|
|
|
|
} catch (e) {
|
|
|
@ -535,8 +532,8 @@ var module = {};
|
|
|
|
if (ssoSession.sessionId) {
|
|
|
|
if (ssoSession.sessionId) {
|
|
|
|
var ssoSessions = getSsoSessions();
|
|
|
|
var ssoSessions = getSsoSessions();
|
|
|
|
ssoSessions[ssoSession.sessionId] = ssoSession;
|
|
|
|
ssoSessions[ssoSession.sessionId] = ssoSession;
|
|
|
|
if (ssoSessions.sessionIndex != null || ssoSessions.sessionIndex != 'undefined') {
|
|
|
|
if (ssoSession.sessionIndex != null || ssoSession.sessionIndex != 'undefined') {
|
|
|
|
module.loadTenant(ssoSessions.loggedInUser);
|
|
|
|
module.loadTenant(ssoSession.loggedInUser);
|
|
|
|
var carbonUser = (require("carbon")).server.tenantUser(ssoSession.loggedInUser);
|
|
|
|
var carbonUser = (require("carbon")).server.tenantUser(ssoSession.loggedInUser);
|
|
|
|
utils.setCurrentUser(carbonUser.username, carbonUser.domain, carbonUser.tenantId);
|
|
|
|
utils.setCurrentUser(carbonUser.username, carbonUser.domain, carbonUser.tenantId);
|
|
|
|
var scriptArgument = {input: {samlToken: ssoSession.samlToken}, user: module.getCurrentUser()};
|
|
|
|
var scriptArgument = {input: {samlToken: ssoSession.samlToken}, user: module.getCurrentUser()};
|
|
|
@ -548,6 +545,17 @@ var module = {};
|
|
|
|
response.sendError(500, msg);
|
|
|
|
response.sendError(500, msg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// If it is a logout request
|
|
|
|
|
|
|
|
if (samlRequest) {
|
|
|
|
|
|
|
|
var index = ssoClient.decodeSAMLLogoutRequest(ssoClient.getSamlObject(samlRequest));
|
|
|
|
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
|
|
|
|
log.debug("Back end log out request received for the session Id : " + index);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
var jSessionId = getSsoSessions()[index];
|
|
|
|
|
|
|
|
delete getSsoSessions()[index];
|
|
|
|
|
|
|
|
session.invalidate();
|
|
|
|
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|