Skip to content
This repository was archived by the owner on Dec 14, 2022. It is now read-only.

Commit 9b2541c

Browse files
author
Chris Wiechmann
committed
Solved some other issues that may lead to race conditions
#75
1 parent 183cc64 commit 9b2541c

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/)
55
and this project adheres to [Semantic Versioning](http://semver.org/).
66

7+
## Unreleased
8+
### Fixed
9+
- Wrong organization assigned to API under heavy load [#75](https://github.com/Axway-API-Management-Plus/apigateway-openlogging-elk/issues/75)
10+
711
## [2.1.0] 2021-02-04
812
### Added
913
- Now the Application-Id shown in Traffic-Monitor column: Subject resolves to the Application-Name [#69](https://github.com/Axway-API-Management-Plus/apigateway-openlogging-elk/issues/69)

UPDATE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ On the other hand, the API builder Docker image, as a central component of the s
4141
| 2.0.1 | [X](#api-builderlogstashmemcached) | - | - | - | - | - | - | - | 7.10.0 | |
4242
| 2.0.2 | [X](#api-builderlogstashmemcached) | - | - | - | - | - | - | - | 7.10.0 | |
4343
| 2.1.0 | [X](#api-builderlogstashmemcached) | [X](#api-builderlogstashmemcached) | - | - | - | - | [X](#parameters)|[X](#elastic-config)| 7.10.0 | |
44+
| 2.1.1 | [X](#api-builderlogstashmemcached) | - | - | - | - | - | - |- | 7.10.0 | Unreleased |
4445

4546
### Update from Version 1.0.0
4647

apibuilder4elastic/custom_flow_nodes/api-builder-plugin-axway-api-management/src/actions.js

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ async function lookupCurrentUser(params, options) {
5858
logger.debug(`Trying to authorize user based on Authorization header.`);
5959
user.loginName = await _getCurrentGWUser(headers = {'Authorization': `${requestHeaders.authorization}`});
6060
logger.debug(`Authorized user is: ${user.loginName}`);
61-
permissions = await _getCurrentGWPermissions(headers = {'Authorization': `${requestHeaders.authorization}`}, loginName);
61+
permissions = await _getCurrentGWPermissions(headers = {'Authorization': `${requestHeaders.authorization}`}, user.loginName);
6262
} else {
6363
VIDUSR = _getCookie(requestHeaders.cookie, "VIDUSR");
6464
if(!VIDUSR) {
@@ -75,7 +75,7 @@ async function lookupCurrentUser(params, options) {
7575
logger.trace(`Trying to get current user based on VIDUSR cookie.`);
7676
user.loginName = await _getCurrentGWUser(headers = {'Cookie': `VIDUSR=${VIDUSR}`});
7777
logger.trace(`Current user is: ${user.loginName}`);
78-
permissions = await _getCurrentGWPermissions(headers = {'Cookie': `VIDUSR=${VIDUSR}`, 'csrf-token': requestHeaders['csrf-token']}, loginName);
78+
permissions = await _getCurrentGWPermissions(headers = {'Cookie': `VIDUSR=${VIDUSR}`, 'csrf-token': requestHeaders['csrf-token']}, user.loginName);
7979
}
8080
if(permissions.includes("adminusers_modify")) {
8181
user.gatewayManager.isAdmin = true;
@@ -363,12 +363,13 @@ async function _getGroupRegionFilename(basefilename, groupId, region) {
363363
}
364364

365365
async function _getCurrentGWUser(requestHeaders) {
366+
debugger;
366367
var options = {
367368
path: '/api/rbac/currentuser',
368369
headers: requestHeaders,
369370
agent: new https.Agent({ rejectUnauthorized: false })
370371
};
371-
const loginName = await sendRequest(pluginConfig.apigateway.url, options)
372+
var loginName = await sendRequest(pluginConfig.apigateway.url, options)
372373
.then(response => {
373374
return response.body.result;
374375
})
@@ -475,7 +476,7 @@ async function _getCurrentGWPermissions(requestHeaders, loginName) {
475476
headers: requestHeaders,
476477
agent: new https.Agent({ rejectUnauthorized: false })
477478
};
478-
const result = await sendRequest(pluginConfig.apigateway.url, options)
479+
var result = await sendRequest(pluginConfig.apigateway.url, options)
479480
.then(response => {
480481
return response.body.result;
481482
})
@@ -497,7 +498,7 @@ async function _getManagerUser(user, groupId) {
497498
},
498499
agent: new https.Agent({ rejectUnauthorized: false })
499500
};
500-
const managerUser = await sendRequest(apiManagerConfig.url, options)
501+
var managerUser = await sendRequest(apiManagerConfig.url, options)
501502
.then(response => {
502503
return response.body;
503504
})
@@ -552,11 +553,12 @@ async function _getOrganization(apiProxy, groupId, region, options) {
552553
if(apiProxy.organizationName == undefined) apiProxy.organizationName = "N/A";
553554
return apiProxy;
554555
}
556+
var org;
555557
const orgId = apiProxy.organizationId;
556558
const apiManagerConfig = getManagerConfig(pluginConfig.apimanager, groupId, region);
557559
const orgCacheKey = `ORG-${orgId}###${groupId}###${region}`
558560
if(cache.has(orgCacheKey)) {
559-
var org = cache.get(orgCacheKey);
561+
org = cache.get(orgCacheKey);
560562
logger.debug(`Organization: '${org.name}' (ID: ${orgId}) found in cache for groupId: ${groupId} in region: ${region}.`);
561563
return org;
562564
}
@@ -567,7 +569,7 @@ async function _getOrganization(apiProxy, groupId, region, options) {
567569
},
568570
agent: new https.Agent({ rejectUnauthorized: false })
569571
};
570-
const org = await sendRequest(apiManagerConfig.url, options)
572+
org = await sendRequest(apiManagerConfig.url, options)
571573
.then(response => {
572574
if(!response.body) {
573575
throw new Error(`Organization with : '${orgId}' not found in API-Manager.`);
@@ -591,8 +593,9 @@ async function _getConfiguredCustomProperties(groupId, region, options) {
591593
const { logger } = options;
592594
const apiManagerConfig = getManagerConfig(pluginConfig.apimanager, groupId, region);
593595
const customPropCacheKey = `CUSTOM_PROPERTIES###${groupId}###${region}`
596+
var propertiesConfig;
594597
if(cache.has(customPropCacheKey)) {
595-
var propertiesConfig = cache.get(customPropCacheKey);
598+
propertiesConfig = cache.get(customPropCacheKey);
596599
logger.debug(`Custom properties found in cache with groupId: ${groupId} and region ${region}.`);
597600
return propertiesConfig;
598601
}
@@ -604,7 +607,7 @@ async function _getConfiguredCustomProperties(groupId, region, options) {
604607
},
605608
agent: new https.Agent({ rejectUnauthorized: false })
606609
};
607-
const propertiesConfig = await sendRequest(apiManagerConfig.url, options)
610+
propertiesConfig = await sendRequest(apiManagerConfig.url, options)
608611
.then(response => {
609612
if(!response.body) {
610613
throw new Error(`Error getting custom properties from API-Manager: ${apiManagerConfig.ur}`);

0 commit comments

Comments
 (0)