Name
global.ISCAuthUtil
Description
No description available
Script
var ISCAuthUtil = Class.create();
ISCAuthUtil.prototype = {
initialize: function() {},
/**
* This function will get all the rest api's from BR and compare it with configured rest api's in sys_api_access_policy table
* @param {dictionary} restAPIDict - list of all rest api's with version, path and sys_id details
*/
getAPIWithoutAccessPolicy: function(restAPIDict) {
var allRestAPI = [];
for (var svcName in restAPIDict) {
var opVal = svcName;
allRestAPI.push(opVal);
}
var configuredAPIList = [];
var api_access_policy = new GlideAggregate('api_access_policies_and_profiles');
api_access_policy.addQuery('saap_active', true);
api_access_policy.addNotNullQuery('sapm_inbound_auth_profile');
api_access_policy.groupBy('saap_api');
api_access_policy.query();
while (api_access_policy.next()) {
var apiList = api_access_policy.getValue('saap_api');
configuredAPIList.push(apiList);
}
//get difference of 2 arrays, all rest API's and configured rest api's
var arrayUtil = new global.ArrayUtil();
var apiWithoutAccessPolicy = arrayUtil.diff(allRestAPI, configuredAPIList);
if (apiWithoutAccessPolicy) {
//clear existing records
var api_clear = new GlideRecord('isc_api_without_access_policy');
api_clear.deleteMultiple();
//Insert non-configured API records to a new table
var api_without_policy = new GlideRecord('isc_api_without_access_policy');
api_without_policy.initialize();
for (var i = 0; i < apiWithoutAccessPolicy.length; i++) {
api_without_policy.api_name = apiWithoutAccessPolicy[i];
api_without_policy.api_path = this.getOpName(restAPIDict[apiWithoutAccessPolicy[i]]);
api_without_policy.insert();
}
}
},
/**
* This function will get api path for each rest api
* @param {dictionary} svcInfo - list of all rest api's with version, path and sys_id details
*/
getOpName: function(svcInfo) {
return svcInfo['route'];
},
type: 'ISCAuthUtil'
};
Sys ID
257464bf87f920104608083f37cb0b7c