GUACAMOLE-956: Use "Guacamole-Token" header in favor of "token" query parameter when invoking REST API from client.

This commit is contained in:
Michael Jumper
2020-02-11 16:23:38 -08:00
parent 5fdfb56c8b
commit aacf63857c
14 changed files with 119 additions and 374 deletions

View File

@@ -409,5 +409,36 @@ angular.module('auth').factory('authenticationService', ['$injector',
}; };
/**
* Makes an HTTP request leveraging the requestService(), automatically
* including the user's authentication token using the "Guacamole-Token"
* header. If the user is not logged in, the "Guacamole-Token" header is
* simply omitted. The provided configuration object is not modified by
* this function.
*
* @param {Object} object
* A configuration object describing the HTTP request to be made by
* requestService(). As described by requestService(), this object must
* be a configuration object accepted by AngularJS' $http service.
*
* @returns {Promise.<Object>}
* A promise that will resolve with the data from the HTTP response for
* the underlying requestService() call if successful, or reject with
* an @link{Error} describing the failure.
*/
service.request = function request(object) {
// Add "Guacamole-Token" header if an authentication token is available
var token = service.getCurrentToken();
if (token) {
object = _.merge({
headers : { 'Guacamole-Token' : token }
}, object);
}
return requestService(object);
};
return service; return service;
}]); }]);

View File

@@ -47,16 +47,10 @@ angular.module('rest').factory('activeConnectionService', ['$injector',
*/ */
service.getActiveConnection = function getActiveConnection(dataSource, id) { service.getActiveConnection = function getActiveConnection(dataSource, id) {
// Build HTTP parameters set
var httpParameters = {
token : authenticationService.getCurrentToken()
};
// Retrieve active connection // Retrieve active connection
return requestService({ return authenticationService.request({
method : 'GET', method : 'GET',
url : 'api/session/data/' + encodeURIComponent(dataSource) + '/activeConnections/' + encodeURIComponent(id), url : 'api/session/data/' + encodeURIComponent(dataSource) + '/activeConnections/' + encodeURIComponent(id)
params : httpParameters
}); });
}; };
@@ -79,17 +73,13 @@ angular.module('rest').factory('activeConnectionService', ['$injector',
*/ */
service.getActiveConnections = function getActiveConnections(dataSource, permissionTypes) { service.getActiveConnections = function getActiveConnections(dataSource, permissionTypes) {
// Build HTTP parameters set
var httpParameters = {
token : authenticationService.getCurrentToken()
};
// Add permission filter if specified // Add permission filter if specified
var httpParameters = {};
if (permissionTypes) if (permissionTypes)
httpParameters.permission = permissionTypes; httpParameters.permission = permissionTypes;
// Retrieve tunnels // Retrieve tunnels
return requestService({ return authenticationService.request({
method : 'GET', method : 'GET',
url : 'api/session/data/' + encodeURIComponent(dataSource) + '/activeConnections', url : 'api/session/data/' + encodeURIComponent(dataSource) + '/activeConnections',
params : httpParameters params : httpParameters
@@ -111,11 +101,6 @@ angular.module('rest').factory('activeConnectionService', ['$injector',
*/ */
service.deleteActiveConnections = function deleteActiveConnections(dataSource, identifiers) { service.deleteActiveConnections = function deleteActiveConnections(dataSource, identifiers) {
// Build HTTP parameters set
var httpParameters = {
token : authenticationService.getCurrentToken()
};
// Convert provided array of identifiers to a patch // Convert provided array of identifiers to a patch
var activeConnectionPatch = []; var activeConnectionPatch = [];
identifiers.forEach(function addActiveConnectionPatch(identifier) { identifiers.forEach(function addActiveConnectionPatch(identifier) {
@@ -126,10 +111,9 @@ angular.module('rest').factory('activeConnectionService', ['$injector',
}); });
// Perform active connection deletion via PATCH // Perform active connection deletion via PATCH
return requestService({ return authenticationService.request({
method : 'PATCH', method : 'PATCH',
url : 'api/session/data/' + encodeURIComponent(dataSource) + '/activeConnections', url : 'api/session/data/' + encodeURIComponent(dataSource) + '/activeConnections',
params : httpParameters,
data : activeConnectionPatch data : activeConnectionPatch
}); });
@@ -154,18 +138,12 @@ angular.module('rest').factory('activeConnectionService', ['$injector',
*/ */
service.getSharingCredentials = function getSharingCredentials(dataSource, id, sharingProfile) { service.getSharingCredentials = function getSharingCredentials(dataSource, id, sharingProfile) {
// Build HTTP parameters set
var httpParameters = {
token : authenticationService.getCurrentToken()
};
// Generate sharing credentials // Generate sharing credentials
return requestService({ return authenticationService.request({
method : 'GET', method : 'GET',
url : 'api/session/data/' + encodeURIComponent(dataSource) url : 'api/session/data/' + encodeURIComponent(dataSource)
+ '/activeConnections/' + encodeURIComponent(id) + '/activeConnections/' + encodeURIComponent(id)
+ '/sharingCredentials/' + encodeURIComponent(sharingProfile), + '/sharingCredentials/' + encodeURIComponent(sharingProfile)
params : httpParameters
}); });
}; };

View File

@@ -59,17 +59,13 @@ angular.module('rest').factory('connectionGroupService', ['$injector',
// Use the root connection group ID if no ID is passed in // Use the root connection group ID if no ID is passed in
connectionGroupID = connectionGroupID || ConnectionGroup.ROOT_IDENTIFIER; connectionGroupID = connectionGroupID || ConnectionGroup.ROOT_IDENTIFIER;
// Build HTTP parameters set
var httpParameters = {
token : authenticationService.getCurrentToken()
};
// Add permission filter if specified // Add permission filter if specified
var httpParameters = {};
if (permissionTypes) if (permissionTypes)
httpParameters.permission = permissionTypes; httpParameters.permission = permissionTypes;
// Retrieve connection group // Retrieve connection group
return requestService({ return authenticationService.request({
cache : cacheService.connections, cache : cacheService.connections,
method : 'GET', method : 'GET',
url : 'api/session/data/' + encodeURIComponent(dataSource) + '/connectionGroups/' + encodeURIComponent(connectionGroupID) + '/tree', url : 'api/session/data/' + encodeURIComponent(dataSource) + '/connectionGroups/' + encodeURIComponent(connectionGroupID) + '/tree',
@@ -96,17 +92,11 @@ angular.module('rest').factory('connectionGroupService', ['$injector',
// Use the root connection group ID if no ID is passed in // Use the root connection group ID if no ID is passed in
connectionGroupID = connectionGroupID || ConnectionGroup.ROOT_IDENTIFIER; connectionGroupID = connectionGroupID || ConnectionGroup.ROOT_IDENTIFIER;
// Build HTTP parameters set
var httpParameters = {
token : authenticationService.getCurrentToken()
};
// Retrieve connection group // Retrieve connection group
return requestService({ return authenticationService.request({
cache : cacheService.connections, cache : cacheService.connections,
method : 'GET', method : 'GET',
url : 'api/session/data/' + encodeURIComponent(dataSource) + '/connectionGroups/' + encodeURIComponent(connectionGroupID), url : 'api/session/data/' + encodeURIComponent(dataSource) + '/connectionGroups/' + encodeURIComponent(connectionGroupID)
params : httpParameters
}); });
}; };
@@ -126,17 +116,11 @@ angular.module('rest').factory('connectionGroupService', ['$injector',
*/ */
service.saveConnectionGroup = function saveConnectionGroup(dataSource, connectionGroup) { service.saveConnectionGroup = function saveConnectionGroup(dataSource, connectionGroup) {
// Build HTTP parameters set
var httpParameters = {
token : authenticationService.getCurrentToken()
};
// If connection group is new, add it and set the identifier automatically // If connection group is new, add it and set the identifier automatically
if (!connectionGroup.identifier) { if (!connectionGroup.identifier) {
return requestService({ return authenticationService.request({
method : 'POST', method : 'POST',
url : 'api/session/data/' + encodeURIComponent(dataSource) + '/connectionGroups', url : 'api/session/data/' + encodeURIComponent(dataSource) + '/connectionGroups',
params : httpParameters,
data : connectionGroup data : connectionGroup
}) })
@@ -153,10 +137,9 @@ angular.module('rest').factory('connectionGroupService', ['$injector',
// Otherwise, update the existing connection group // Otherwise, update the existing connection group
else { else {
return requestService({ return authenticationService.request({
method : 'PUT', method : 'PUT',
url : 'api/session/data/' + encodeURIComponent(dataSource) + '/connectionGroups/' + encodeURIComponent(connectionGroup.identifier), url : 'api/session/data/' + encodeURIComponent(dataSource) + '/connectionGroups/' + encodeURIComponent(connectionGroup.identifier),
params : httpParameters,
data : connectionGroup data : connectionGroup
}) })
@@ -184,16 +167,10 @@ angular.module('rest').factory('connectionGroupService', ['$injector',
*/ */
service.deleteConnectionGroup = function deleteConnectionGroup(dataSource, connectionGroup) { service.deleteConnectionGroup = function deleteConnectionGroup(dataSource, connectionGroup) {
// Build HTTP parameters set
var httpParameters = {
token : authenticationService.getCurrentToken()
};
// Delete connection group // Delete connection group
return requestService({ return authenticationService.request({
method : 'DELETE', method : 'DELETE',
url : 'api/session/data/' + encodeURIComponent(dataSource) + '/connectionGroups/' + encodeURIComponent(connectionGroup.identifier), url : 'api/session/data/' + encodeURIComponent(dataSource) + '/connectionGroups/' + encodeURIComponent(connectionGroup.identifier)
params : httpParameters
}) })
// Clear the cache // Clear the cache

View File

@@ -47,17 +47,11 @@ angular.module('rest').factory('connectionService', ['$injector',
*/ */
service.getConnection = function getConnection(dataSource, id) { service.getConnection = function getConnection(dataSource, id) {
// Build HTTP parameters set
var httpParameters = {
token : authenticationService.getCurrentToken()
};
// Retrieve connection // Retrieve connection
return requestService({ return authenticationService.request({
cache : cacheService.connections, cache : cacheService.connections,
method : 'GET', method : 'GET',
url : 'api/session/data/' + encodeURIComponent(dataSource) + '/connections/' + encodeURIComponent(id), url : 'api/session/data/' + encodeURIComponent(dataSource) + '/connections/' + encodeURIComponent(id)
params : httpParameters
}); });
}; };
@@ -76,16 +70,10 @@ angular.module('rest').factory('connectionService', ['$injector',
*/ */
service.getConnectionHistory = function getConnectionHistory(dataSource, id) { service.getConnectionHistory = function getConnectionHistory(dataSource, id) {
// Build HTTP parameters set
var httpParameters = {
token : authenticationService.getCurrentToken()
};
// Retrieve connection history // Retrieve connection history
return requestService({ return authenticationService.request({
method : 'GET', method : 'GET',
url : 'api/session/data/' + encodeURIComponent(dataSource) + '/connections/' + encodeURIComponent(id) + '/history', url : 'api/session/data/' + encodeURIComponent(dataSource) + '/connections/' + encodeURIComponent(id) + '/history'
params : httpParameters
}); });
}; };
@@ -104,17 +92,11 @@ angular.module('rest').factory('connectionService', ['$injector',
*/ */
service.getConnectionParameters = function getConnectionParameters(dataSource, id) { service.getConnectionParameters = function getConnectionParameters(dataSource, id) {
// Build HTTP parameters set
var httpParameters = {
token : authenticationService.getCurrentToken()
};
// Retrieve connection parameters // Retrieve connection parameters
return requestService({ return authenticationService.request({
cache : cacheService.connections, cache : cacheService.connections,
method : 'GET', method : 'GET',
url : 'api/session/data/' + encodeURIComponent(dataSource) + '/connections/' + encodeURIComponent(id) + '/parameters', url : 'api/session/data/' + encodeURIComponent(dataSource) + '/connections/' + encodeURIComponent(id) + '/parameters'
params : httpParameters
}); });
}; };
@@ -134,17 +116,11 @@ angular.module('rest').factory('connectionService', ['$injector',
*/ */
service.saveConnection = function saveConnection(dataSource, connection) { service.saveConnection = function saveConnection(dataSource, connection) {
// Build HTTP parameters set
var httpParameters = {
token : authenticationService.getCurrentToken()
};
// If connection is new, add it and set the identifier automatically // If connection is new, add it and set the identifier automatically
if (!connection.identifier) { if (!connection.identifier) {
return requestService({ return authenticationService.request({
method : 'POST', method : 'POST',
url : 'api/session/data/' + encodeURIComponent(dataSource) + '/connections', url : 'api/session/data/' + encodeURIComponent(dataSource) + '/connections',
params : httpParameters,
data : connection data : connection
}) })
@@ -161,10 +137,9 @@ angular.module('rest').factory('connectionService', ['$injector',
// Otherwise, update the existing connection // Otherwise, update the existing connection
else { else {
return requestService({ return authenticationService.request({
method : 'PUT', method : 'PUT',
url : 'api/session/data/' + encodeURIComponent(dataSource) + '/connections/' + encodeURIComponent(connection.identifier), url : 'api/session/data/' + encodeURIComponent(dataSource) + '/connections/' + encodeURIComponent(connection.identifier),
params : httpParameters,
data : connection data : connection
}) })
@@ -192,16 +167,10 @@ angular.module('rest').factory('connectionService', ['$injector',
*/ */
service.deleteConnection = function deleteConnection(dataSource, connection) { service.deleteConnection = function deleteConnection(dataSource, connection) {
// Build HTTP parameters set
var httpParameters = {
token : authenticationService.getCurrentToken()
};
// Delete connection // Delete connection
return requestService({ return authenticationService.request({
method : 'DELETE', method : 'DELETE',
url : 'api/session/data/' + encodeURIComponent(dataSource) + '/connections/' + encodeURIComponent(connection.identifier), url : 'api/session/data/' + encodeURIComponent(dataSource) + '/connections/' + encodeURIComponent(connection.identifier)
params : httpParameters
}) })
// Clear the cache // Clear the cache

View File

@@ -60,10 +60,7 @@ angular.module('rest').factory('historyService', ['$injector',
service.getConnectionHistory = function getConnectionHistory(dataSource, service.getConnectionHistory = function getConnectionHistory(dataSource,
requiredContents, sortPredicates) { requiredContents, sortPredicates) {
// Build HTTP parameters set var httpParameters = {};
var httpParameters = {
token : authenticationService.getCurrentToken()
};
// Filter according to contents if restrictions are specified // Filter according to contents if restrictions are specified
if (requiredContents) if (requiredContents)
@@ -74,7 +71,7 @@ angular.module('rest').factory('historyService', ['$injector',
httpParameters.order = sortPredicates; httpParameters.order = sortPredicates;
// Retrieve connection history // Retrieve connection history
return requestService({ return authenticationService.request({
method : 'GET', method : 'GET',
url : 'api/session/data/' + encodeURIComponent(dataSource) + '/history/connections', url : 'api/session/data/' + encodeURIComponent(dataSource) + '/history/connections',
params : httpParameters params : httpParameters

View File

@@ -41,17 +41,11 @@ angular.module('rest').factory('languageService', ['$injector',
*/ */
service.getLanguages = function getLanguages() { service.getLanguages = function getLanguages() {
// Build HTTP parameters set
var httpParameters = {
token : authenticationService.getCurrentToken()
};
// Retrieve available languages // Retrieve available languages
return requestService({ return authenticationService.request({
cache : cacheService.languages, cache : cacheService.languages,
method : 'GET', method : 'GET',
url : 'api/languages', url : 'api/languages'
params : httpParameters
}); });
}; };

View File

@@ -144,17 +144,11 @@ angular.module('rest').factory('membershipService', ['$injector',
*/ */
service.getUserGroups = function getUserGroups(dataSource, identifier, group) { service.getUserGroups = function getUserGroups(dataSource, identifier, group) {
// Build HTTP parameters set
var httpParameters = {
token : authenticationService.getCurrentToken()
};
// Retrieve parent groups // Retrieve parent groups
return requestService({ return authenticationService.request({
cache : cacheService.users, cache : cacheService.users,
method : 'GET', method : 'GET',
url : getUserGroupsResourceURL(dataSource, identifier, group), url : getUserGroupsResourceURL(dataSource, identifier, group)
params : httpParameters
}); });
}; };
@@ -193,16 +187,10 @@ angular.module('rest').factory('membershipService', ['$injector',
service.patchUserGroups = function patchUserGroups(dataSource, identifier, service.patchUserGroups = function patchUserGroups(dataSource, identifier,
addToUserGroups, removeFromUserGroups, group) { addToUserGroups, removeFromUserGroups, group) {
// Build HTTP parameters set
var httpParameters = {
token : authenticationService.getCurrentToken()
};
// Update parent user groups // Update parent user groups
return requestService({ return authenticationService.request({
method : 'PATCH', method : 'PATCH',
url : getUserGroupsResourceURL(dataSource, identifier, group), url : getUserGroupsResourceURL(dataSource, identifier, group),
params : httpParameters,
data : getRelatedObjectPatch(addToUserGroups, removeFromUserGroups) data : getRelatedObjectPatch(addToUserGroups, removeFromUserGroups)
}) })
@@ -232,17 +220,11 @@ angular.module('rest').factory('membershipService', ['$injector',
*/ */
service.getMemberUsers = function getMemberUsers(dataSource, identifier) { service.getMemberUsers = function getMemberUsers(dataSource, identifier) {
// Build HTTP parameters set
var httpParameters = {
token : authenticationService.getCurrentToken()
};
// Retrieve member users // Retrieve member users
return requestService({ return authenticationService.request({
cache : cacheService.users, cache : cacheService.users,
method : 'GET', method : 'GET',
url : 'api/session/data/' + encodeURIComponent(dataSource) + '/userGroups/' + encodeURIComponent(identifier) + '/memberUsers', url : 'api/session/data/' + encodeURIComponent(dataSource) + '/userGroups/' + encodeURIComponent(identifier) + '/memberUsers'
params : httpParameters
}); });
}; };
@@ -275,16 +257,10 @@ angular.module('rest').factory('membershipService', ['$injector',
service.patchMemberUsers = function patchMemberUsers(dataSource, identifier, service.patchMemberUsers = function patchMemberUsers(dataSource, identifier,
usersToAdd, usersToRemove) { usersToAdd, usersToRemove) {
// Build HTTP parameters set
var httpParameters = {
token : authenticationService.getCurrentToken()
};
// Update member users // Update member users
return requestService({ return authenticationService.request({
method : 'PATCH', method : 'PATCH',
url : 'api/session/data/' + encodeURIComponent(dataSource) + '/userGroups/' + encodeURIComponent(identifier) + '/memberUsers', url : 'api/session/data/' + encodeURIComponent(dataSource) + '/userGroups/' + encodeURIComponent(identifier) + '/memberUsers',
params : httpParameters,
data : getRelatedObjectPatch(usersToAdd, usersToRemove) data : getRelatedObjectPatch(usersToAdd, usersToRemove)
}) })
@@ -316,17 +292,11 @@ angular.module('rest').factory('membershipService', ['$injector',
*/ */
service.getMemberUserGroups = function getMemberUserGroups(dataSource, identifier) { service.getMemberUserGroups = function getMemberUserGroups(dataSource, identifier) {
// Build HTTP parameters set
var httpParameters = {
token : authenticationService.getCurrentToken()
};
// Retrieve member user groups // Retrieve member user groups
return requestService({ return authenticationService.request({
cache : cacheService.users, cache : cacheService.users,
method : 'GET', method : 'GET',
url : 'api/session/data/' + encodeURIComponent(dataSource) + '/userGroups/' + encodeURIComponent(identifier) + '/memberUserGroups', url : 'api/session/data/' + encodeURIComponent(dataSource) + '/userGroups/' + encodeURIComponent(identifier) + '/memberUserGroups'
params : httpParameters
}); });
}; };
@@ -360,16 +330,10 @@ angular.module('rest').factory('membershipService', ['$injector',
service.patchMemberUserGroups = function patchMemberUserGroups(dataSource, service.patchMemberUserGroups = function patchMemberUserGroups(dataSource,
identifier, userGroupsToAdd, userGroupsToRemove) { identifier, userGroupsToAdd, userGroupsToRemove) {
// Build HTTP parameters set
var httpParameters = {
token : authenticationService.getCurrentToken()
};
// Update member user groups // Update member user groups
return requestService({ return authenticationService.request({
method : 'PATCH', method : 'PATCH',
url : 'api/session/data/' + encodeURIComponent(dataSource) + '/userGroups/' + encodeURIComponent(identifier) + '/memberUserGroups', url : 'api/session/data/' + encodeURIComponent(dataSource) + '/userGroups/' + encodeURIComponent(identifier) + '/memberUserGroups',
params : httpParameters,
data : getRelatedObjectPatch(userGroupsToAdd, userGroupsToRemove) data : getRelatedObjectPatch(userGroupsToAdd, userGroupsToRemove)
}) })

View File

@@ -42,17 +42,11 @@ angular.module('rest').factory('patchService', ['$injector',
*/ */
service.getPatches = function getPatches() { service.getPatches = function getPatches() {
// Build HTTP parameters set
var httpParameters = {
token : authenticationService.getCurrentToken()
};
// Retrieve all applicable HTML patches // Retrieve all applicable HTML patches
return requestService({ return authenticationService.request({
cache : cacheService.patches, cache : cacheService.patches,
method : 'GET', method : 'GET',
url : 'api/patches', url : 'api/patches'
params : httpParameters
}); });
}; };

View File

@@ -105,17 +105,11 @@ angular.module('rest').factory('permissionService', ['$injector',
*/ */
service.getEffectivePermissions = function getEffectivePermissions(dataSource, userID) { service.getEffectivePermissions = function getEffectivePermissions(dataSource, userID) {
// Build HTTP parameters set
var httpParameters = {
token : authenticationService.getCurrentToken()
};
// Retrieve user permissions // Retrieve user permissions
return requestService({ return authenticationService.request({
cache : cacheService.users, cache : cacheService.users,
method : 'GET', method : 'GET',
url : getEffectivePermissionsResourceURL(dataSource, userID), url : getEffectivePermissionsResourceURL(dataSource, userID)
params : httpParameters
}); });
}; };
@@ -198,17 +192,11 @@ angular.module('rest').factory('permissionService', ['$injector',
*/ */
service.getPermissions = function getPermissions(dataSource, identifier, group) { service.getPermissions = function getPermissions(dataSource, identifier, group) {
// Build HTTP parameters set
var httpParameters = {
token : authenticationService.getCurrentToken()
};
// Retrieve user/group permissions // Retrieve user/group permissions
return requestService({ return authenticationService.request({
cache : cacheService.users, cache : cacheService.users,
method : 'GET', method : 'GET',
url : getPermissionsResourceURL(dataSource, identifier, group), url : getPermissionsResourceURL(dataSource, identifier, group)
params : httpParameters
}); });
}; };
@@ -333,11 +321,6 @@ angular.module('rest').factory('permissionService', ['$injector',
var permissionPatch = []; var permissionPatch = [];
// Build HTTP parameters set
var httpParameters = {
token : authenticationService.getCurrentToken()
};
// Add all the add operations to the patch // Add all the add operations to the patch
addPatchOperations(permissionPatch, PermissionPatch.Operation.ADD, permissionsToAdd); addPatchOperations(permissionPatch, PermissionPatch.Operation.ADD, permissionsToAdd);
@@ -345,10 +328,9 @@ angular.module('rest').factory('permissionService', ['$injector',
addPatchOperations(permissionPatch, PermissionPatch.Operation.REMOVE, permissionsToRemove); addPatchOperations(permissionPatch, PermissionPatch.Operation.REMOVE, permissionsToRemove);
// Patch user/group permissions // Patch user/group permissions
return requestService({ return authenticationService.request({
method : 'PATCH', method : 'PATCH',
url : getPermissionsResourceURL(dataSource, identifier, group), url : getPermissionsResourceURL(dataSource, identifier, group),
params : httpParameters,
data : permissionPatch data : permissionPatch
}) })

View File

@@ -49,17 +49,11 @@ angular.module('rest').factory('schemaService', ['$injector',
*/ */
service.getUserAttributes = function getUserAttributes(dataSource) { service.getUserAttributes = function getUserAttributes(dataSource) {
// Build HTTP parameters set
var httpParameters = {
token : authenticationService.getCurrentToken()
};
// Retrieve available user attributes // Retrieve available user attributes
return requestService({ return authenticationService.request({
cache : cacheService.schema, cache : cacheService.schema,
method : 'GET', method : 'GET',
url : 'api/session/data/' + encodeURIComponent(dataSource) + '/schema/userAttributes', url : 'api/session/data/' + encodeURIComponent(dataSource) + '/schema/userAttributes'
params : httpParameters
}); });
}; };
@@ -83,17 +77,11 @@ angular.module('rest').factory('schemaService', ['$injector',
*/ */
service.getUserGroupAttributes = function getUserGroupAttributes(dataSource) { service.getUserGroupAttributes = function getUserGroupAttributes(dataSource) {
// Build HTTP parameters set
var httpParameters = {
token : authenticationService.getCurrentToken()
};
// Retrieve available user group attributes // Retrieve available user group attributes
return requestService({ return authenticationService.request({
cache : cacheService.schema, cache : cacheService.schema,
method : 'GET', method : 'GET',
url : 'api/session/data/' + encodeURIComponent(dataSource) + '/schema/userGroupAttributes', url : 'api/session/data/' + encodeURIComponent(dataSource) + '/schema/userGroupAttributes'
params : httpParameters
}); });
}; };
@@ -117,17 +105,11 @@ angular.module('rest').factory('schemaService', ['$injector',
*/ */
service.getConnectionAttributes = function getConnectionAttributes(dataSource) { service.getConnectionAttributes = function getConnectionAttributes(dataSource) {
// Build HTTP parameters set
var httpParameters = {
token : authenticationService.getCurrentToken()
};
// Retrieve available connection attributes // Retrieve available connection attributes
return requestService({ return authenticationService.request({
cache : cacheService.schema, cache : cacheService.schema,
method : 'GET', method : 'GET',
url : 'api/session/data/' + encodeURIComponent(dataSource) + '/schema/connectionAttributes', url : 'api/session/data/' + encodeURIComponent(dataSource) + '/schema/connectionAttributes'
params : httpParameters
}); });
}; };
@@ -151,17 +133,11 @@ angular.module('rest').factory('schemaService', ['$injector',
*/ */
service.getSharingProfileAttributes = function getSharingProfileAttributes(dataSource) { service.getSharingProfileAttributes = function getSharingProfileAttributes(dataSource) {
// Build HTTP parameters set
var httpParameters = {
token : authenticationService.getCurrentToken()
};
// Retrieve available sharing profile attributes // Retrieve available sharing profile attributes
return requestService({ return authenticationService.request({
cache : cacheService.schema, cache : cacheService.schema,
method : 'GET', method : 'GET',
url : 'api/session/data/' + encodeURIComponent(dataSource) + '/schema/sharingProfileAttributes', url : 'api/session/data/' + encodeURIComponent(dataSource) + '/schema/sharingProfileAttributes'
params : httpParameters
}); });
}; };
@@ -185,17 +161,11 @@ angular.module('rest').factory('schemaService', ['$injector',
*/ */
service.getConnectionGroupAttributes = function getConnectionGroupAttributes(dataSource) { service.getConnectionGroupAttributes = function getConnectionGroupAttributes(dataSource) {
// Build HTTP parameters set
var httpParameters = {
token : authenticationService.getCurrentToken()
};
// Retrieve available connection group attributes // Retrieve available connection group attributes
return requestService({ return authenticationService.request({
cache : cacheService.schema, cache : cacheService.schema,
method : 'GET', method : 'GET',
url : 'api/session/data/' + encodeURIComponent(dataSource) + '/schema/connectionGroupAttributes', url : 'api/session/data/' + encodeURIComponent(dataSource) + '/schema/connectionGroupAttributes'
params : httpParameters
}); });
}; };
@@ -216,17 +186,11 @@ angular.module('rest').factory('schemaService', ['$injector',
*/ */
service.getProtocols = function getProtocols(dataSource) { service.getProtocols = function getProtocols(dataSource) {
// Build HTTP parameters set
var httpParameters = {
token : authenticationService.getCurrentToken()
};
// Retrieve available protocols // Retrieve available protocols
return requestService({ return authenticationService.request({
cache : cacheService.schema, cache : cacheService.schema,
method : 'GET', method : 'GET',
url : 'api/session/data/' + encodeURIComponent(dataSource) + '/schema/protocols', url : 'api/session/data/' + encodeURIComponent(dataSource) + '/schema/protocols'
params : httpParameters
}); });
}; };

View File

@@ -49,17 +49,11 @@ angular.module('rest').factory('sharingProfileService', ['$injector',
*/ */
service.getSharingProfile = function getSharingProfile(dataSource, id) { service.getSharingProfile = function getSharingProfile(dataSource, id) {
// Build HTTP parameters set
var httpParameters = {
token : authenticationService.getCurrentToken()
};
// Retrieve sharing profile // Retrieve sharing profile
return requestService({ return authenticationService.request({
cache : cacheService.connections, cache : cacheService.connections,
method : 'GET', method : 'GET',
url : 'api/session/data/' + encodeURIComponent(dataSource) + '/sharingProfiles/' + encodeURIComponent(id), url : 'api/session/data/' + encodeURIComponent(dataSource) + '/sharingProfiles/' + encodeURIComponent(id)
params : httpParameters
}); });
}; };
@@ -78,17 +72,11 @@ angular.module('rest').factory('sharingProfileService', ['$injector',
*/ */
service.getSharingProfileParameters = function getSharingProfileParameters(dataSource, id) { service.getSharingProfileParameters = function getSharingProfileParameters(dataSource, id) {
// Build HTTP parameters set
var httpParameters = {
token : authenticationService.getCurrentToken()
};
// Retrieve sharing profile parameters // Retrieve sharing profile parameters
return requestService({ return authenticationService.request({
cache : cacheService.connections, cache : cacheService.connections,
method : 'GET', method : 'GET',
url : 'api/session/data/' + encodeURIComponent(dataSource) + '/sharingProfiles/' + encodeURIComponent(id) + '/parameters', url : 'api/session/data/' + encodeURIComponent(dataSource) + '/sharingProfiles/' + encodeURIComponent(id) + '/parameters'
params : httpParameters
}); });
}; };
@@ -109,17 +97,11 @@ angular.module('rest').factory('sharingProfileService', ['$injector',
*/ */
service.saveSharingProfile = function saveSharingProfile(dataSource, sharingProfile) { service.saveSharingProfile = function saveSharingProfile(dataSource, sharingProfile) {
// Build HTTP parameters set
var httpParameters = {
token : authenticationService.getCurrentToken()
};
// If sharing profile is new, add it and set the identifier automatically // If sharing profile is new, add it and set the identifier automatically
if (!sharingProfile.identifier) { if (!sharingProfile.identifier) {
return requestService({ return authenticationService.request({
method : 'POST', method : 'POST',
url : 'api/session/data/' + encodeURIComponent(dataSource) + '/sharingProfiles', url : 'api/session/data/' + encodeURIComponent(dataSource) + '/sharingProfiles',
params : httpParameters,
data : sharingProfile data : sharingProfile
}) })
@@ -136,10 +118,9 @@ angular.module('rest').factory('sharingProfileService', ['$injector',
// Otherwise, update the existing sharing profile // Otherwise, update the existing sharing profile
else { else {
return requestService({ return authenticationService.request({
method : 'PUT', method : 'PUT',
url : 'api/session/data/' + encodeURIComponent(dataSource) + '/sharingProfiles/' + encodeURIComponent(sharingProfile.identifier), url : 'api/session/data/' + encodeURIComponent(dataSource) + '/sharingProfiles/' + encodeURIComponent(sharingProfile.identifier),
params : httpParameters,
data : sharingProfile data : sharingProfile
}) })
@@ -168,16 +149,10 @@ angular.module('rest').factory('sharingProfileService', ['$injector',
*/ */
service.deleteSharingProfile = function deleteSharingProfile(dataSource, sharingProfile) { service.deleteSharingProfile = function deleteSharingProfile(dataSource, sharingProfile) {
// Build HTTP parameters set
var httpParameters = {
token : authenticationService.getCurrentToken()
};
// Delete sharing profile // Delete sharing profile
return requestService({ return authenticationService.request({
method : 'DELETE', method : 'DELETE',
url : 'api/session/data/' + encodeURIComponent(dataSource) + '/sharingProfiles/' + encodeURIComponent(sharingProfile.identifier), url : 'api/session/data/' + encodeURIComponent(dataSource) + '/sharingProfiles/' + encodeURIComponent(sharingProfile.identifier)
params : httpParameters
}) })
// Clear the cache // Clear the cache

View File

@@ -65,16 +65,10 @@ angular.module('rest').factory('tunnelService', ['$injector',
*/ */
service.getTunnels = function getTunnels() { service.getTunnels = function getTunnels() {
// Build HTTP parameters set
var httpParameters = {
token : authenticationService.getCurrentToken()
};
// Retrieve tunnels // Retrieve tunnels
return requestService({ return authenticationService.request({
method : 'GET', method : 'GET',
url : 'api/session/tunnels', url : 'api/session/tunnels'
params : httpParameters
}); });
}; };
@@ -124,17 +118,11 @@ angular.module('rest').factory('tunnelService', ['$injector',
*/ */
service.getSharingProfiles = function getSharingProfiles(tunnel) { service.getSharingProfiles = function getSharingProfiles(tunnel) {
// Build HTTP parameters set
var httpParameters = {
token : authenticationService.getCurrentToken()
};
// Retrieve all associated sharing profiles // Retrieve all associated sharing profiles
return requestService({ return authenticationService.request({
method : 'GET', method : 'GET',
url : 'api/session/tunnels/' + encodeURIComponent(tunnel) url : 'api/session/tunnels/' + encodeURIComponent(tunnel)
+ '/activeConnection/connection/sharingProfiles', + '/activeConnection/connection/sharingProfiles'
params : httpParameters
}); });
}; };
@@ -160,18 +148,12 @@ angular.module('rest').factory('tunnelService', ['$injector',
*/ */
service.getSharingCredentials = function getSharingCredentials(tunnel, sharingProfile) { service.getSharingCredentials = function getSharingCredentials(tunnel, sharingProfile) {
// Build HTTP parameters set
var httpParameters = {
token : authenticationService.getCurrentToken()
};
// Generate sharing credentials // Generate sharing credentials
return requestService({ return authenticationService.request({
method : 'GET', method : 'GET',
url : 'api/session/tunnels/' + encodeURIComponent(tunnel) url : 'api/session/tunnels/' + encodeURIComponent(tunnel)
+ '/activeConnection/sharingCredentials/' + '/activeConnection/sharingCredentials/'
+ encodeURIComponent(sharingProfile), + encodeURIComponent(sharingProfile)
params : httpParameters
}); });
}; };

View File

@@ -52,17 +52,13 @@ angular.module('rest').factory('userGroupService', ['$injector',
*/ */
service.getUserGroups = function getUserGroups(dataSource, permissionTypes) { service.getUserGroups = function getUserGroups(dataSource, permissionTypes) {
// Build HTTP parameters set
var httpParameters = {
token : authenticationService.getCurrentToken()
};
// Add permission filter if specified // Add permission filter if specified
var httpParameters = {};
if (permissionTypes) if (permissionTypes)
httpParameters.permission = permissionTypes; httpParameters.permission = permissionTypes;
// Retrieve user groups // Retrieve user groups
return requestService({ return authenticationService.request({
cache : cacheService.users, cache : cacheService.users,
method : 'GET', method : 'GET',
url : 'api/session/data/' + encodeURIComponent(dataSource) + '/userGroups', url : 'api/session/data/' + encodeURIComponent(dataSource) + '/userGroups',
@@ -89,17 +85,11 @@ angular.module('rest').factory('userGroupService', ['$injector',
*/ */
service.getUserGroup = function getUserGroup(dataSource, identifier) { service.getUserGroup = function getUserGroup(dataSource, identifier) {
// Build HTTP parameters set
var httpParameters = {
token : authenticationService.getCurrentToken()
};
// Retrieve user group // Retrieve user group
return requestService({ return authenticationService.request({
cache : cacheService.users, cache : cacheService.users,
method : 'GET', method : 'GET',
url : 'api/session/data/' + encodeURIComponent(dataSource) + '/userGroups/' + encodeURIComponent(identifier), url : 'api/session/data/' + encodeURIComponent(dataSource) + '/userGroups/' + encodeURIComponent(identifier)
params : httpParameters
}); });
}; };
@@ -122,16 +112,10 @@ angular.module('rest').factory('userGroupService', ['$injector',
*/ */
service.deleteUserGroup = function deleteUserGroup(dataSource, userGroup) { service.deleteUserGroup = function deleteUserGroup(dataSource, userGroup) {
// Build HTTP parameters set
var httpParameters = {
token : authenticationService.getCurrentToken()
};
// Delete user group // Delete user group
return requestService({ return authenticationService.request({
method : 'DELETE', method : 'DELETE',
url : 'api/session/data/' + encodeURIComponent(dataSource) + '/userGroups/' + encodeURIComponent(userGroup.identifier), url : 'api/session/data/' + encodeURIComponent(dataSource) + '/userGroups/' + encodeURIComponent(userGroup.identifier)
params : httpParameters
}) })
// Clear the cache // Clear the cache
@@ -160,16 +144,10 @@ angular.module('rest').factory('userGroupService', ['$injector',
*/ */
service.createUserGroup = function createUserGroup(dataSource, userGroup) { service.createUserGroup = function createUserGroup(dataSource, userGroup) {
// Build HTTP parameters set
var httpParameters = {
token : authenticationService.getCurrentToken()
};
// Create user group // Create user group
return requestService({ return authenticationService.request({
method : 'POST', method : 'POST',
url : 'api/session/data/' + encodeURIComponent(dataSource) + '/userGroups', url : 'api/session/data/' + encodeURIComponent(dataSource) + '/userGroups',
params : httpParameters,
data : userGroup data : userGroup
}) })
@@ -198,16 +176,10 @@ angular.module('rest').factory('userGroupService', ['$injector',
*/ */
service.saveUserGroup = function saveUserGroup(dataSource, userGroup) { service.saveUserGroup = function saveUserGroup(dataSource, userGroup) {
// Build HTTP parameters set
var httpParameters = {
token : authenticationService.getCurrentToken()
};
// Update user group // Update user group
return requestService({ return authenticationService.request({
method : 'PUT', method : 'PUT',
url : 'api/session/data/' + encodeURIComponent(dataSource) + '/userGroups/' + encodeURIComponent(userGroup.identifier), url : 'api/session/data/' + encodeURIComponent(dataSource) + '/userGroups/' + encodeURIComponent(userGroup.identifier),
params : httpParameters,
data : userGroup data : userGroup
}) })

View File

@@ -56,17 +56,13 @@ angular.module('rest').factory('userService', ['$injector',
*/ */
service.getUsers = function getUsers(dataSource, permissionTypes) { service.getUsers = function getUsers(dataSource, permissionTypes) {
// Build HTTP parameters set
var httpParameters = {
token : authenticationService.getCurrentToken()
};
// Add permission filter if specified // Add permission filter if specified
var httpParameters = {};
if (permissionTypes) if (permissionTypes)
httpParameters.permission = permissionTypes; httpParameters.permission = permissionTypes;
// Retrieve users // Retrieve users
return requestService({ return authenticationService.request({
cache : cacheService.users, cache : cacheService.users,
method : 'GET', method : 'GET',
url : 'api/session/data/' + encodeURIComponent(dataSource) + '/users', url : 'api/session/data/' + encodeURIComponent(dataSource) + '/users',
@@ -93,17 +89,11 @@ angular.module('rest').factory('userService', ['$injector',
*/ */
service.getUser = function getUser(dataSource, username) { service.getUser = function getUser(dataSource, username) {
// Build HTTP parameters set
var httpParameters = {
token : authenticationService.getCurrentToken()
};
// Retrieve user // Retrieve user
return requestService({ return authenticationService.request({
cache : cacheService.users, cache : cacheService.users,
method : 'GET', method : 'GET',
url : 'api/session/data/' + encodeURIComponent(dataSource) + '/users/' + encodeURIComponent(username), url : 'api/session/data/' + encodeURIComponent(dataSource) + '/users/' + encodeURIComponent(username)
params : httpParameters
}); });
}; };
@@ -126,16 +116,10 @@ angular.module('rest').factory('userService', ['$injector',
*/ */
service.deleteUser = function deleteUser(dataSource, user) { service.deleteUser = function deleteUser(dataSource, user) {
// Build HTTP parameters set
var httpParameters = {
token : authenticationService.getCurrentToken()
};
// Delete user // Delete user
return requestService({ return authenticationService.request({
method : 'DELETE', method : 'DELETE',
url : 'api/session/data/' + encodeURIComponent(dataSource) + '/users/' + encodeURIComponent(user.username), url : 'api/session/data/' + encodeURIComponent(dataSource) + '/users/' + encodeURIComponent(user.username)
params : httpParameters
}) })
// Clear the cache // Clear the cache
@@ -164,16 +148,10 @@ angular.module('rest').factory('userService', ['$injector',
*/ */
service.createUser = function createUser(dataSource, user) { service.createUser = function createUser(dataSource, user) {
// Build HTTP parameters set
var httpParameters = {
token : authenticationService.getCurrentToken()
};
// Create user // Create user
return requestService({ return authenticationService.request({
method : 'POST', method : 'POST',
url : 'api/session/data/' + encodeURIComponent(dataSource) + '/users', url : 'api/session/data/' + encodeURIComponent(dataSource) + '/users',
params : httpParameters,
data : user data : user
}) })
@@ -202,16 +180,10 @@ angular.module('rest').factory('userService', ['$injector',
*/ */
service.saveUser = function saveUser(dataSource, user) { service.saveUser = function saveUser(dataSource, user) {
// Build HTTP parameters set
var httpParameters = {
token : authenticationService.getCurrentToken()
};
// Update user // Update user
return requestService({ return authenticationService.request({
method : 'PUT', method : 'PUT',
url : 'api/session/data/' + encodeURIComponent(dataSource) + '/users/' + encodeURIComponent(user.username), url : 'api/session/data/' + encodeURIComponent(dataSource) + '/users/' + encodeURIComponent(user.username),
params : httpParameters,
data : user data : user
}) })
@@ -247,16 +219,10 @@ angular.module('rest').factory('userService', ['$injector',
service.updateUserPassword = function updateUserPassword(dataSource, username, service.updateUserPassword = function updateUserPassword(dataSource, username,
oldPassword, newPassword) { oldPassword, newPassword) {
// Build HTTP parameters set
var httpParameters = {
token : authenticationService.getCurrentToken()
};
// Update user password // Update user password
return requestService({ return authenticationService.request({
method : 'PUT', method : 'PUT',
url : 'api/session/data/' + encodeURIComponent(dataSource) + '/users/' + encodeURIComponent(username) + '/password', url : 'api/session/data/' + encodeURIComponent(dataSource) + '/users/' + encodeURIComponent(username) + '/password',
params : httpParameters,
data : new UserPasswordUpdate({ data : new UserPasswordUpdate({
oldPassword : oldPassword, oldPassword : oldPassword,
newPassword : newPassword newPassword : newPassword