Skip to content

Commit 3637e69

Browse files
authored
Zowe Suite v2.18.1
2 parents 5ef0a63 + 8e9c236 commit 3637e69

File tree

8 files changed

+182
-118
lines changed

8 files changed

+182
-118
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
All notable changes to the Zlux Server Framework package will be documented in this file..
44
This repo is part of the app-server Zowe Component, and the change logs here may appear on Zowe.org in that section.
55

6+
## 2.18.1
7+
- Bugfix: App-server could not register with discovery server when AT-TLS was enabled for app-server. (#581)
8+
- Bugfix: App-server /server/environment endpoint was missing the "agent" object, causing the Desktop to choose an indirect route to accessing ZSS. This fix improves latency and high availability behavior of ZSS APIs in the Desktop. (#589)
9+
- Bugfix: When eureka registration experienced a network failure, troubleshooting information was not available. The property `components.app-server.node.mediationLayer.traceTls` now exists for troubleshooting TLS issues. (#591)
10+
611
## 2.17.0
712
- Enhancement: Added function `isClientAttls(zoweConfig)` within `libs/util.js`. Whenever a plugin makes a network request, it should always use this to determine if a normally HTTPS request should instead be made as HTTP due to AT-TLS handling the TLS when enabled. (#544)
813
- Bugfix: Fixed function `isServerAttls(zoweConfig)` within `libs/util.js`, which was preventing using AT-TLS with app-server. (#544)

lib/apiml.js

Lines changed: 41 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,22 @@ const MEDIATION_LAYER_INSTANCE_DEFAULTS = (zluxProto, zluxHostname, zluxPort) =>
7979
}};
8080

8181
function ApimlConnector({ hostName, port, discoveryUrls,
82-
discoveryPort, tlsOptions, eurekaOverrides, isClientAttls }) {
82+
discoveryPort, tlsOptions, eurekaOverrides, isClientAttls, traceTls }) {
8383
Object.assign(this, { hostName, port, discoveryUrls,
84-
discoveryPort, tlsOptions, eurekaOverrides, isClientAttls });
84+
discoveryPort, tlsOptions, eurekaOverrides, isClientAttls, traceTls });
85+
//TODO config should never be checked through env var, but is temporarily needed to temporarily read gateway's ATTLS state to provide it with Eureka info it can work with.
86+
const clientGlobalAttls = process.env['ZWE_zowe_network_client_tls_attls'];
87+
const clientGatewayAttls = process.env['ZWE_components_gateway_zowe_network_client_tls_attls'];
88+
const clientAttls = (clientGlobalAttls == 'true') || (clientGatewayAttls == 'true');
89+
this.isGatewayClientAttls = false;
90+
if ((clientGlobalAttls === undefined) && (clientGatewayAttls === undefined)) {
91+
// If client attls env vars are not set, have client follow server attls variable. it simplifies common case in which users want both.
92+
const serverGlobalAttls = process.env['ZWE_zowe_network_server_tls_attls'] == 'true';
93+
const serverGatewayAttls = process.env['ZWE_components_gateway_zowe_network_server_tls_attls'] == 'true';
94+
this.isGatewayClientAttls = serverGlobalAttls || serverGatewayAttls;
95+
} else {
96+
this.isGatewayClientAttls = clientAttls;
97+
}
8598
this.vipAddress = hostName;
8699
}
87100

@@ -168,24 +181,29 @@ ApimlConnector.prototype = {
168181
// If the HTTP port is set to 0 then the API ML doesn't load zlux
169182
httpPort: Number(this.port),
170183
httpsPort: Number(this.port),
171-
httpEnabled: false,
172-
httpsEnabled: true
184+
// TODO while the server should always be HTTPS for security,
185+
// When AT-TLS is used, programs need to know when AT-TLS will add TLS to their traffic
186+
// To align with the correct amount of TLS (Avoid no TLS and double TLS)
187+
// It seems the gateway wants to be told app-server is 'http' when client TLS is set on it
188+
// So this eureka object will be based upon that setting.
189+
// This may change in the future, revisit.
190+
httpEnabled: this.isGatewayClientAttls,
191+
httpsEnabled: !this.isGatewayClientAttls
173192
};
174-
const proto = 'https';
175193

176-
log.debug("ZWED0141I", proto, this.port); //"Protocol:", proto, "Port", port);
194+
log.debug("ZWED0141I", 'https', this.port); //"Protocol:", proto, "Port", port);
177195
log.debug("ZWED0142I", JSON.stringify(protocolObject)); //"Protocol Object:", JSON.stringify(protocolObject));
178196

179-
const instance = Object.assign({}, MEDIATION_LAYER_INSTANCE_DEFAULTS(proto, this.hostName, this.port));
197+
const instance = Object.assign({}, MEDIATION_LAYER_INSTANCE_DEFAULTS('https', this.hostName, this.port));
180198
Object.assign(instance, overrides);
181199
Object.assign(instance, {
182200
instanceId: `${this.hostName}:zlux:${this.port}`,
183201
hostName: this.hostName,
184202
ipAddr: this.ipAddr,
185203
vipAddress: "zlux",//this.vipAddress,
186-
statusPageUrl: `${proto}://${this.hostName}:${this.port}/server/eureka/info`,
187-
healthCheckUrl: `${proto}://${this.hostName}:${this.port}/server/eureka/health`,
188-
homePageUrl: `${proto}://${this.hostName}:${this.port}/`,
204+
statusPageUrl: `https://${this.hostName}:${this.port}/server/eureka/info`,
205+
healthCheckUrl: `https://${this.hostName}:${this.port}/server/eureka/health`,
206+
homePageUrl: `https://${this.hostName}:${this.port}/`,
189207
port: {
190208
"$": protocolObject.httpPort, // This is a workaround for the mediation layer
191209
"@enabled": ''+protocolObject.httpEnabled
@@ -228,7 +246,11 @@ ApimlConnector.prototype = {
228246
},*/
229247

230248
registerMainServerInstance() {
231-
const overrideOptions = Object.assign({},this.tlsOptions);
249+
const overrideOptions = this.isClientAttls
250+
? {}
251+
//Use server's own TLS options except for TLS tracing.
252+
: Object.assign(Object.assign({},this.tlsOptions), {enableTrace: this.traceTls ? true : false});
253+
232254
if (!this.tlsOptions.rejectUnauthorized) {
233255
//Keeping these certs causes an openssl error 46, unknown cert error in a dev environment
234256
delete overrideOptions.cert;
@@ -240,7 +262,8 @@ ApimlConnector.prototype = {
240262
eureka: Object.assign({}, MEDIATION_LAYER_EUREKA_DEFAULTS, this.eurekaOverrides),
241263
requestMiddleware: function (requestOpts, done) {
242264
done(Object.assign(requestOpts, overrideOptions));
243-
}
265+
},
266+
ssl: !this.isClientAttls
244267
}
245268
log.debug("ZWED0144I", JSON.stringify(zluxProxyServerInstanceConfig, null, 2)); //log.debug("zluxProxyServerInstanceConfig: "
246269
//+ JSON.stringify(zluxProxyServerInstanceConfig, null, 2))
@@ -280,7 +303,12 @@ ApimlConnector.prototype = {
280303
},
281304

282305
getServiceUrls() {
283-
return this.discoveryUrls.map(url => url + (url.endsWith('/') ? '' : '/') + 'apps');
306+
let urls = this.discoveryUrls.map(url => url + (url.endsWith('/') ? '' : '/') + 'apps');
307+
if (this.isClientAttls) {
308+
return urls.map(url => url.replaceAll('https', 'http'));
309+
} else {
310+
return urls;
311+
}
284312
},
285313

286314
getRequestOptionsArray(method, path) {

lib/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ Server.prototype = {
220220
port: this.port,
221221
discoveryUrls: apimlConfig.server.discoveryUrls || [`https://${apimlConfig.server.hostname}:${apimlConfig.server.port}/eureka/`],
222222
tlsOptions: this.tlsOptions,
223+
traceTls: apimlConfig.traceTls,
223224
eurekaOverrides: apimlConfig.eureka,
224225
isClientAttls: util.isClientAttls(this.zoweConfig)
225226
});

lib/webapp.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,8 @@ const hostname = os.hostname();
234234
function getUserEnv(rbac, zoweConfig){
235235
var date = new Date();
236236
return new Promise(function(resolve, reject){
237-
const nodeConfig = zoweConfig.components['app-server'].node;
237+
const serverConfig = zoweConfig.components['app-server'];
238+
const nodeConfig = serverConfig.node;
238239
if (rbac) {
239240
resolve({
240241
"timestamp": date.toUTCString(),
@@ -248,7 +249,7 @@ function getUserEnv(rbac, zoweConfig){
248249
"hostname": hostname,
249250
"userEnvironment": process.env,
250251
"agent": {
251-
"mediationLayer": nodeConfig.agent?.mediationLayer
252+
"mediationLayer": serverConfig.agent?.mediationLayer
252253
},
253254
"PID": process.pid,
254255
"PPID": process.ppid,
@@ -279,7 +280,7 @@ function getUserEnv(rbac, zoweConfig){
279280
"GATEWAY_PORT": nodeConfig.mediationLayer.server.gatewayPort,
280281
},
281282
"agent": {
282-
"mediationLayer": nodeConfig.agent?.mediationLayer
283+
"mediationLayer": serverConfig.agent?.mediationLayer
283284
}
284285
})
285286
}

0 commit comments

Comments
 (0)