mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Merge pull request #216 from GPrathap/master
fixed some bugs which caused while enabling SSO in IoT Server
This commit is contained in:
commit
c6fbc8f1fe
@ -20,6 +20,7 @@ var apiWrapperUtil = function () {
|
|||||||
var module = {};
|
var module = {};
|
||||||
var tokenUtil = require("/app/modules/util.js").util;
|
var tokenUtil = require("/app/modules/util.js").util;
|
||||||
var constants = require("/app/modules/constants.js");
|
var constants = require("/app/modules/constants.js");
|
||||||
|
var constants = require("/app/modules/constants.js");
|
||||||
|
|
||||||
module.refreshToken = function () {
|
module.refreshToken = function () {
|
||||||
var tokenPair = session.get(constants.ACCESS_TOKEN_PAIR_IDENTIFIER);
|
var tokenPair = session.get(constants.ACCESS_TOKEN_PAIR_IDENTIFIER);
|
||||||
@ -32,10 +33,10 @@ var apiWrapperUtil = function () {
|
|||||||
var clientData = tokenUtil.getDyanmicCredentials(properties);
|
var clientData = tokenUtil.getDyanmicCredentials(properties);
|
||||||
var encodedClientKeys = tokenUtil.encode(clientData.clientId + ":" + clientData.clientSecret);
|
var encodedClientKeys = tokenUtil.encode(clientData.clientId + ":" + clientData.clientSecret);
|
||||||
session.put(constants.ENCODED_CLIENT_KEYS_IDENTIFIER, encodedClientKeys);
|
session.put(constants.ENCODED_CLIENT_KEYS_IDENTIFIER, encodedClientKeys);
|
||||||
if (type == "password") {
|
if (type == constants.GRANT_TYPE_PASSWORD) {
|
||||||
tokenPair =
|
tokenPair =
|
||||||
tokenUtil.getTokenWithPasswordGrantType(properties.username, encodeURIComponent(properties.password), encodedClientKeys);
|
tokenUtil.getTokenWithPasswordGrantType(properties.username, encodeURIComponent(properties.password), encodedClientKeys);
|
||||||
} else if (type == "saml") {
|
} else if (type == constants.GRANT_TYPE_SAML) {
|
||||||
tokenPair = tokenUtil.
|
tokenPair = tokenUtil.
|
||||||
getTokenWithSAMLGrantType(properties.samlToken, encodedClientKeys, "PRODUCTION");
|
getTokenWithSAMLGrantType(properties.samlToken, encodedClientKeys, "PRODUCTION");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -49,7 +49,7 @@ var LANGUAGE_US = "en_US";
|
|||||||
var VENDOR_APPLE = "Apple";
|
var VENDOR_APPLE = "Apple";
|
||||||
var ERRORS = {
|
var ERRORS = {
|
||||||
"USER_NOT_FOUND": "USER_NOT_FOUND"
|
"USER_NOT_FOUND": "USER_NOT_FOUND"
|
||||||
};
|
};
|
||||||
|
|
||||||
var USER_STORES_NOISY_CHAR = "\"";
|
var USER_STORES_NOISY_CHAR = "\"";
|
||||||
var USER_STORES_SPLITTING_CHAR = "\\n";
|
var USER_STORES_SPLITTING_CHAR = "\\n";
|
||||||
@ -70,6 +70,9 @@ var HTTP_POST = "POST";
|
|||||||
var HTTP_PUT = "PUT";
|
var HTTP_PUT = "PUT";
|
||||||
var HTTP_DELETE = "DELETE";
|
var HTTP_DELETE = "DELETE";
|
||||||
|
|
||||||
|
var GRANT_TYPE_PASSWORD = "password";
|
||||||
|
var GRANT_TYPE_SAML = "saml";
|
||||||
|
|
||||||
var MQTT_QUEUE_CONFIG_NAME = "MQTT";
|
var MQTT_QUEUE_CONFIG_NAME = "MQTT";
|
||||||
|
|
||||||
var HTTP_CONFLICT = 409;
|
var HTTP_CONFLICT = 409;
|
||||||
|
|||||||
@ -20,13 +20,19 @@ var onSuccess;
|
|||||||
var onFail;
|
var onFail;
|
||||||
|
|
||||||
(function () {
|
(function () {
|
||||||
var log = new Log("api/user-api.jag");
|
var log = new Log("/app/modules/login.js");
|
||||||
|
var constants = require("/app/modules/constants.js");
|
||||||
onSuccess = function (context) {
|
onSuccess = function (context) {
|
||||||
|
var properties;
|
||||||
var utility = require("/app/modules/utility.js").utility;
|
var utility = require("/app/modules/utility.js").utility;
|
||||||
var apiWrapperUtil = require("/app/modules/api-wrapper-util.js").apiWrapperUtil;
|
var apiWrapperUtil = require("/app/modules/api-wrapper-util.js").apiWrapperUtil;
|
||||||
var properties = {username: context.input.username, password: context.input.password};
|
if(context.input.samlToken){
|
||||||
apiWrapperUtil.setupAccessTokenPair("password", properties);
|
properties = {samlToken: context.input.samlToken};
|
||||||
|
apiWrapperUtil.setupAccessTokenPair(constants.GRANT_TYPE_SAML, properties);
|
||||||
|
}else{
|
||||||
|
properties = {username: context.input.username, password: context.input.password};
|
||||||
|
apiWrapperUtil.setupAccessTokenPair(constants.GRANT_TYPE_PASSWORD, properties);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
onFail = function (error) {
|
onFail = function (error) {
|
||||||
|
|||||||
@ -17,6 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
var util = function () {
|
var util = function () {
|
||||||
|
var log = new Log("/app/modules/util.js");
|
||||||
var module = {};
|
var module = {};
|
||||||
var Base64 = Packages.org.apache.commons.codec.binary.Base64;
|
var Base64 = Packages.org.apache.commons.codec.binary.Base64;
|
||||||
var String = Packages.java.lang.String;
|
var String = Packages.java.lang.String;
|
||||||
|
|||||||
@ -534,7 +534,7 @@ var module = {};
|
|||||||
ssoSessions[ssoSession.sessionId] = ssoSession;
|
ssoSessions[ssoSession.sessionId] = ssoSession;
|
||||||
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: {}, user: module.getCurrentUser()};
|
var scriptArgument = {input: {samlToken: ssoSession.samlToken}, user: module.getCurrentUser()};
|
||||||
handleEvent(OPERATION_LOGIN, EVENT_SUCCESS, scriptArgument);
|
handleEvent(OPERATION_LOGIN, EVENT_SUCCESS, scriptArgument);
|
||||||
} else {
|
} else {
|
||||||
var msg = "Cannot decode SAML login response.";
|
var msg = "Cannot decode SAML login response.";
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user