@nsshunt/stsconfig 1.17.2 → 1.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.env-default CHANGED
@@ -103,8 +103,18 @@ AS_ENDPOINT=http://localhost
103
103
  AS_HOST_PORT=3002
104
104
  # Auth Server port (client port to access the service)
105
105
  AS_PORT=3002
106
- # Auth Server endpoint
107
- AS_API_ROOT=/stsauth/v1
106
+ # Auth Server API root.
107
+ AS_API_ROOT=/stsauth/v1.0
108
+ # Auth Server OAuth2 API root.
109
+ AS_OAUTH_API_ROOT=/oauth2/v2.0
110
+ # Auth Server Admin API root.
111
+ AS_ADMIN_API_ROOT=/admin/v1.0
112
+ # Auth Server API Identifier.
113
+ AS_API_IDENTIFIER=https://stsmda.com.au/stsauthapi/v1.0/
114
+ # Auth Server OAuth API Identifier.
115
+ AS_OAUTH_API_IDENTIFIER=https://stsmda.com.au/stsauthoauthapi/v2.0/
116
+ # Auth Server Administration API Identifier.
117
+ AS_ADMIN_API_IDENTIFIER=https://stsmda.com.au/stsauthadminapi/v1.0/
108
118
  # Auth Server Prometheus metric support
109
119
  AS_PROM_SUPPORT=true
110
120
  # Auth Prometheus Cluster Server port (port used for cluster prometheus scrapes)
@@ -226,3 +236,32 @@ HTTPS_SERVER_KEY_PATH=/var/lib/sts/stsglobalresources/keys/server.key
226
236
 
227
237
  # HTTPS server cert path.
228
238
  HTTPS_SERVER_CERT_PATH=/var/lib/sts/stsglobalresources/keys/server.cert
239
+
240
+ # Maximum number of RSA keys in the JWKS store
241
+ TS_JWKS_KEYS=3
242
+
243
+ # File path for JWKS store data. This file will contain the public and private keys for the JWKS store.
244
+ TS_JWKS_STORE_PATH=/var/lib/sts/stsglobalresources/.stsauthprivate/jwks-private.json
245
+
246
+ # File path for JWKS public store data. This file will contain only the public signing keys for the JWKS store.
247
+ TS_JWKS_STORE_PUBLIC_PATH=/var/lib/sts/stsglobalresources/.well-known/jwks.json
248
+
249
+ # JWKS Authentication Configuration Settings
250
+ # Ref: https://github.com/auth0/node-jwks-rsa
251
+ # Enables a LRU cache. Ref: https://github.com/auth0/node-jwks-rsa#caching
252
+ JWKS_AUTH_CONFIG_CACHE=true
253
+
254
+ # Maximum number of LRU cache entries. Ref: https://github.com/auth0/node-jwks-rsa#caching
255
+ JWKS_AUTH_CONFIG_CACHE_MAX_ENTRIES=5
256
+
257
+ # Maximum age of LRU cache entries. Ref: https://github.com/auth0/node-jwks-rsa#caching
258
+ JWKS_AUTH_CONFIG_CACHE_MAX_AGE=600000
259
+
260
+ # Enforce rate limiting for jwks public endpoint query. Ref: https://github.com/auth0/node-jwks-rsa#rate-limiting
261
+ JWKS_AUTH_CONFIG_RATE_LIMIT=true
262
+
263
+ # Enforce rate limiting maximum number of requests per minute. Ref: https://github.com/auth0/node-jwks-rsa#rate-limiting
264
+ JWKS_AUTH_CONFIG_RATE_LIMIT_REQUESTS_PER_MINUTE=10
265
+
266
+ # Timeout for the public endpoint query. Note: This will be ignored if an http/https agent is specified.
267
+ JWKS_AUTH_CONFIG_TIMEOUT=30000
package/.env-test-file-2 CHANGED
@@ -70,9 +70,15 @@ TO_CLIENT_SECRET_FILE=testclientsecretfile
70
70
  AS_ENDPOINT=http://localhost-c
71
71
  AS_HOST_PORT=30020
72
72
  AS_PORT=30020
73
- AS_API_ROOT=/stsauth/v1-c
73
+ AS_API_ROOT=/stsauth/v1.0-c
74
+ AS_OAUTH_API_ROOT=/oauth2/v2.0-c
75
+ AS_ADMIN_API_ROOT=/admin/v1.0-c
74
76
  AS_API_IDENTIFIER=xyz
75
77
  AS_API_IDENTIFIER_FILE=testapiidentifierFile
78
+ AS_OAUTH_API_IDENTIFIER=xyz
79
+ AS_OAUTH_API_IDENTIFIER_FILE=testapiidentifierFile
80
+ AS_ADMIN_API_IDENTIFIER=xyz
81
+ AS_ADMIN_API_IDENTIFIER_FILE=testapiidentifierFile
76
82
  AS_PROM_SUPPORT=false
77
83
  AS_PROM_CLUSTER_PORT=30120
78
84
  AS_SERVICE_NAME=STSAuth-c
@@ -121,3 +127,14 @@ IGNORE_SOCKETIO=false
121
127
  MODEL_PURGE_UPDATE_TIMEOUT=50000
122
128
  HTTPS_SERVER_KEY_PATH=/var/lib/sts/stsglobalresources/keys/server.key-c
123
129
  HTTPS_SERVER_CERT_PATH=/var/lib/sts/stsglobalresources/keys/server.cert-c
130
+
131
+ TS_JWKS_KEYS=30
132
+ TS_JWKS_STORE_PATH=xyz
133
+ TS_JWKS_STORE_PATH_FILE=testclientsecretfile
134
+ TS_JWKS_STORE_PUBLIC_PATH=/var/lib/sts/stsglobalresources/.well-known/jwks.json-c
135
+ JWKS_AUTH_CONFIG_CACHE=false
136
+ JWKS_AUTH_CONFIG_CACHE_MAX_ENTRIES=50
137
+ JWKS_AUTH_CONFIG_CACHE_MAX_AGE=6000000
138
+ JWKS_AUTH_CONFIG_RATE_LIMIT=false
139
+ JWKS_AUTH_CONFIG_RATE_LIMIT_REQUESTS_PER_MINUTE=100
140
+ JWKS_AUTH_CONFIG_TIMEOUT=300000
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nsshunt/stsconfig",
3
- "version": "1.17.2",
3
+ "version": "1.18.0",
4
4
  "description": "",
5
5
  "main": "stsconfig.js",
6
6
  "dependencies": {
@@ -114,7 +114,7 @@ describe("Test implicit config settings", () =>
114
114
 
115
115
  test('Checking default authentication service config', async () =>
116
116
  {
117
- expect.assertions(21);
117
+ expect.assertions(27);
118
118
 
119
119
  process.env.STSENVFILE = './.env-test-file-1'; // Empty environment file
120
120
  let goptions = require('./stsconfig.js').$options;
@@ -123,6 +123,8 @@ describe("Test implicit config settings", () =>
123
123
  expect(goptions.ashostport).toEqual('3002');
124
124
  expect(goptions.asport).toEqual('3002');
125
125
  expect(goptions.asapiroot).toEqual('/stsauth/v1.0');
126
+ expect(goptions.asoauthapiroot).toEqual('/oauth2/v2.0');
127
+ expect(goptions.asadminapiroot).toEqual('/admin/v1.0');
126
128
  expect(goptions.asprometheussupport).toEqual(true);
127
129
  expect(goptions.asprometheusclusterport).toEqual('3012');
128
130
  expect(goptions.asservicename).toEqual('STSAuth');
@@ -131,6 +133,10 @@ describe("Test implicit config settings", () =>
131
133
  expect(goptions.aspublickeypath).toEqual('/var/lib/sts/stsglobalresources/keys/public.key');
132
134
  expect(goptions.asapiidentifier).toEqual('https://stsmda.com.au/stsauthapi/v1.0/');
133
135
  expect(goptions.asapiidentifierfile).toEqual(undefined);
136
+ expect(goptions.asoauthapiidentifier).toEqual('https://stsmda.com.au/stsauthoauthapi/v2.0/');
137
+ expect(goptions.asoauthapiidentifierfile).toEqual(undefined);
138
+ expect(goptions.asadminapiidentifier).toEqual('https://stsmda.com.au/stsauthadminapi/v1.0/');
139
+ expect(goptions.asadminapiidentifierfile).toEqual(undefined);
134
140
  expect(goptions.asclientid).toEqual(undefined);
135
141
  expect(goptions.asclientidfile).toEqual(undefined);
136
142
  expect(goptions.asclientsecret).toEqual(undefined);
@@ -189,5 +195,24 @@ describe("Test implicit config settings", () =>
189
195
  expect(goptions.httpsserverkeypath).toEqual('/var/lib/sts/stsglobalresources/keys/server.key');
190
196
  expect(goptions.httpsservercertpath).toEqual('/var/lib/sts/stsglobalresources/keys/server.cert');
191
197
  });
198
+
199
+ test('Checking JWKS config items', async () =>
200
+ {
201
+ expect.assertions(10);
202
+
203
+ process.env.STSENVFILE = './.env-default'; // Empty environment file
204
+ let goptions = require('./stsconfig.js').$options;
205
+
206
+ expect(goptions.tsjwkskeys).toEqual(3);
207
+ expect(goptions.tsjwksstorepath).toEqual('/var/lib/sts/stsglobalresources/.stsauthprivate/jwks-private.json');
208
+ expect(goptions.tsjwksstorepathfile).toEqual(undefined);
209
+ expect(goptions.tsjwksstorepublicpath).toEqual('/var/lib/sts/stsglobalresources/.well-known/jwks.json');
210
+ expect(goptions.jwksAuthConfigCache).toEqual(true);
211
+ expect(goptions.jwksAuthConfigCacheMaxEntries).toEqual(5);
212
+ expect(goptions.jwksAuthConfigCacheMaxAge).toEqual(600000);
213
+ expect(goptions.jwksAuthConfigRateLimit).toEqual(true);
214
+ expect(goptions.jwksAuthConfigRateLimitRequestsPerMinute).toEqual(10);
215
+ expect(goptions.jwksAuthConfigTimeout).toEqual(30000);
216
+ });
192
217
  });
193
218
 
@@ -114,7 +114,7 @@ describe("Test configured settings", () =>
114
114
 
115
115
  test('Checking default authentication service config', async () =>
116
116
  {
117
- expect.assertions(21);
117
+ expect.assertions(27);
118
118
 
119
119
  process.env.STSENVFILE = './.env-test-file-2'; // Empty environment file
120
120
  let goptions = require('./stsconfig.js').$options;
@@ -122,7 +122,9 @@ describe("Test configured settings", () =>
122
122
  expect(goptions.asendpoint).toEqual('http://localhost-c');
123
123
  expect(goptions.ashostport).toEqual('30020');
124
124
  expect(goptions.asport).toEqual('30020');
125
- expect(goptions.asapiroot).toEqual('/stsauth/v1-c');
125
+ expect(goptions.asapiroot).toEqual('/stsauth/v1.0-c');
126
+ expect(goptions.asoauthapiroot).toEqual('/oauth2/v2.0-c');
127
+ expect(goptions.asadminapiroot).toEqual('/admin/v1.0-c');
126
128
  expect(goptions.asprometheussupport).toEqual(false);
127
129
  expect(goptions.asprometheusclusterport).toEqual('30120');
128
130
  expect(goptions.asservicename).toEqual('STSAuth-c');
@@ -131,6 +133,10 @@ describe("Test configured settings", () =>
131
133
  expect(goptions.aspublickeypath).toEqual('/var/lib/sts/stsglobalresources/keys/public.key-c');
132
134
  expect(goptions.asapiidentifier).toEqual('testapiidentifierfilecontents');
133
135
  expect(goptions.asapiidentifierfile).toEqual('testapiidentifierFile');
136
+ expect(goptions.asoauthapiidentifier).toEqual('testapiidentifierfilecontents');
137
+ expect(goptions.asoauthapiidentifierfile).toEqual('testapiidentifierFile');
138
+ expect(goptions.asadminapiidentifier).toEqual('testapiidentifierfilecontents');
139
+ expect(goptions.asadminapiidentifierfile).toEqual('testapiidentifierFile');
134
140
  expect(goptions.asclientid).toEqual('testclientidfilecontents');
135
141
  expect(goptions.asclientidfile).toEqual('testclientidfile'); // testclientidfile
136
142
  expect(goptions.asclientsecret).toEqual('testclientsecretfilecontents');
@@ -189,5 +195,24 @@ describe("Test configured settings", () =>
189
195
  expect(goptions.httpsserverkeypath).toEqual('/var/lib/sts/stsglobalresources/keys/server.key-c');
190
196
  expect(goptions.httpsservercertpath).toEqual('/var/lib/sts/stsglobalresources/keys/server.cert-c');
191
197
  });
198
+
199
+ test('Checking JWKS config items', async () =>
200
+ {
201
+ expect.assertions(10);
202
+
203
+ process.env.STSENVFILE = './.env-default'; // Empty environment file
204
+ let goptions = require('./stsconfig.js').$options;
205
+
206
+ expect(goptions.tsjwkskeys).toEqual(30);
207
+ expect(goptions.tsjwksstorepath).toEqual('testclientsecretfilecontents');
208
+ expect(goptions.tsjwksstorepathfile).toEqual('testclientsecretfile');
209
+ expect(goptions.tsjwksstorepublicpath).toEqual('/var/lib/sts/stsglobalresources/.well-known/jwks.json-c');
210
+ expect(goptions.jwksAuthConfigCache).toEqual(false);
211
+ expect(goptions.jwksAuthConfigCacheMaxEntries).toEqual(50);
212
+ expect(goptions.jwksAuthConfigCacheMaxAge).toEqual(6000000);
213
+ expect(goptions.jwksAuthConfigRateLimit).toEqual(false);
214
+ expect(goptions.jwksAuthConfigRateLimitRequestsPerMinute).toEqual(100);
215
+ expect(goptions.jwksAuthConfigTimeout).toEqual(300000);
216
+ });
192
217
  });
193
218
 
@@ -114,7 +114,7 @@ describe("Test explicit default config settings", () =>
114
114
 
115
115
  test('Checking default authentication service config', async () =>
116
116
  {
117
- expect.assertions(21);
117
+ expect.assertions(27);
118
118
 
119
119
  process.env.STSENVFILE = './.env-default'; // Empty environment file
120
120
  let goptions = require('./stsconfig.js').$options;
@@ -122,7 +122,9 @@ describe("Test explicit default config settings", () =>
122
122
  expect(goptions.asendpoint).toEqual('http://localhost');
123
123
  expect(goptions.ashostport).toEqual('3002');
124
124
  expect(goptions.asport).toEqual('3002');
125
- expect(goptions.asapiroot).toEqual('/stsauth/v1');
125
+ expect(goptions.asapiroot).toEqual('/stsauth/v1.0');
126
+ expect(goptions.asoauthapiroot).toEqual('/oauth2/v2.0');
127
+ expect(goptions.asadminapiroot).toEqual('/admin/v1.0');
126
128
  expect(goptions.asprometheussupport).toEqual(true);
127
129
  expect(goptions.asprometheusclusterport).toEqual('3012');
128
130
  expect(goptions.asservicename).toEqual('STSAuth');
@@ -131,6 +133,10 @@ describe("Test explicit default config settings", () =>
131
133
  expect(goptions.aspublickeypath).toEqual('/var/lib/sts/stsglobalresources/keys/public.key');
132
134
  expect(goptions.asapiidentifier).toEqual('https://stsmda.com.au/stsauthapi/v1.0/');
133
135
  expect(goptions.asapiidentifierfile).toEqual(undefined);
136
+ expect(goptions.asoauthapiidentifier).toEqual('https://stsmda.com.au/stsauthoauthapi/v2.0/');
137
+ expect(goptions.asoauthapiidentifierfile).toEqual(undefined);
138
+ expect(goptions.asadminapiidentifier).toEqual('https://stsmda.com.au/stsauthadminapi/v1.0/');
139
+ expect(goptions.asadminapiidentifierfile).toEqual(undefined);
134
140
  expect(goptions.asclientid).toEqual(undefined);
135
141
  expect(goptions.asclientidfile).toEqual(undefined);
136
142
  expect(goptions.asclientsecret).toEqual(undefined);
@@ -189,5 +195,24 @@ describe("Test explicit default config settings", () =>
189
195
  expect(goptions.httpsserverkeypath).toEqual('/var/lib/sts/stsglobalresources/keys/server.key');
190
196
  expect(goptions.httpsservercertpath).toEqual('/var/lib/sts/stsglobalresources/keys/server.cert');
191
197
  });
198
+
199
+ test('Checking JWKS config items', async () =>
200
+ {
201
+ expect.assertions(10);
202
+
203
+ process.env.STSENVFILE = './.env-default'; // Empty environment file
204
+ let goptions = require('./stsconfig.js').$options;
205
+
206
+ expect(goptions.tsjwkskeys).toEqual(3);
207
+ expect(goptions.tsjwksstorepath).toEqual('/var/lib/sts/stsglobalresources/.stsauthprivate/jwks-private.json');
208
+ expect(goptions.tsjwksstorepathfile).toEqual(undefined);
209
+ expect(goptions.tsjwksstorepublicpath).toEqual('/var/lib/sts/stsglobalresources/.well-known/jwks.json');
210
+ expect(goptions.jwksAuthConfigCache).toEqual(true);
211
+ expect(goptions.jwksAuthConfigCacheMaxEntries).toEqual(5);
212
+ expect(goptions.jwksAuthConfigCacheMaxAge).toEqual(600000);
213
+ expect(goptions.jwksAuthConfigRateLimit).toEqual(true);
214
+ expect(goptions.jwksAuthConfigRateLimitRequestsPerMinute).toEqual(10);
215
+ expect(goptions.jwksAuthConfigTimeout).toEqual(30000);
216
+ });
192
217
  });
193
218
 
package/stsconfig.js CHANGED
@@ -163,11 +163,11 @@ const defconfig =
163
163
  ,ashostport: (process.env.AS_HOST_PORT === undefined ? "3002" : process.env.AS_HOST_PORT)
164
164
  // Auth Server port (client port to access the service)
165
165
  ,asport: (process.env.AS_PORT === undefined ? "3002" : process.env.AS_PORT)
166
- // Auth Server endpoint
166
+ // Auth Server API root.
167
167
  ,asapiroot: (process.env.AS_API_ROOT === undefined ? "/stsauth/v1.0" : process.env.AS_API_ROOT)
168
- // Auth Server API Identifier.
168
+ // Auth Server OAuth2 API root.
169
169
  ,asoauthapiroot: (process.env.AS_OAUTH_API_ROOT === undefined ? "/oauth2/v2.0" : process.env.AS_OAUTH_API_ROOT)
170
- // Auth Server Admin API Identifier.
170
+ // Auth Server Admin API root.
171
171
  ,asadminapiroot: (process.env.AS_ADMIN_API_ROOT === undefined ? "/admin/v1.0" : process.env.AS_ADMIN_API_ROOT)
172
172
  // Auth Server API Identifier.
173
173
  ,asapiidentifier: (process.env.AS_API_IDENTIFIER === undefined ? 'https://stsmda.com.au/stsauthapi/v1.0/' : process.env.AS_API_IDENTIFIER)
@@ -355,6 +355,26 @@ const defconfig =
355
355
  ,tsjwksstorepathfile: process.env.TS_JWKS_STORE_PATH_FILE
356
356
  // File path for JWKS public store data. This file will contain only the public signing keys for the JWKS store.
357
357
  ,tsjwksstorepublicpath: (process.env.TS_JWKS_STORE_PUBLIC_PATH === undefined ? "/var/lib/sts/stsglobalresources/.well-known/jwks.json" : process.env.TS_JWKS_STORE_PUBLIC_PATH)
358
+
359
+ // JWKS Authentication Configuration Settings
360
+ // Ref: https://github.com/auth0/node-jwks-rsa
361
+ // Enables a LRU cache. Ref: https://github.com/auth0/node-jwks-rsa#caching
362
+ ,jwksAuthConfigCache: (process.env.JWKS_AUTH_CONFIG_CACHE === undefined ? true : (process.env.JWKS_AUTH_CONFIG_CACHE === "true" ? true : false ))
363
+
364
+ // Maximum number of LRU cache entries. Ref: https://github.com/auth0/node-jwks-rsa#caching
365
+ ,jwksAuthConfigCacheMaxEntries: (process.env.JWKS_AUTH_CONFIG_CACHE_MAX_ENTRIES === undefined ? 5 : parseInt(process.env.JWKS_AUTH_CONFIG_CACHE_MAX_ENTRIES))
366
+
367
+ // Maximum age of LRU cache entries. Ref: https://github.com/auth0/node-jwks-rsa#caching
368
+ ,jwksAuthConfigCacheMaxAge: (process.env.JWKS_AUTH_CONFIG_CACHE_MAX_AGE === undefined ? 600000 : parseInt(process.env.JWKS_AUTH_CONFIG_CACHE_MAX_AGE))
369
+
370
+ // Enforce rate limiting for jwks public endpoint query. Ref: https://github.com/auth0/node-jwks-rsa#rate-limiting
371
+ ,jwksAuthConfigRateLimit: (process.env.JWKS_AUTH_CONFIG_RATE_LIMIT === undefined ? true : (process.env.JWKS_AUTH_CONFIG_RATE_LIMIT === "true" ? true : false ))
372
+
373
+ // Enforce rate limiting maximum number of requests per minute. Ref: https://github.com/auth0/node-jwks-rsa#rate-limiting
374
+ ,jwksAuthConfigRateLimitRequestsPerMinute: (process.env.JWKS_AUTH_CONFIG_RATE_LIMIT_REQUESTS_PER_MINUTE === undefined ? 10 : parseInt(process.env.JWKS_AUTH_CONFIG_RATE_LIMIT_REQUESTS_PER_MINUTE))
375
+
376
+ // Timeout for the public endpoint query. Note: This will be ignored if an http/https agent is specified.
377
+ ,jwksAuthConfigTimeout: (process.env.JWKS_AUTH_CONFIG_TIMEOUT === undefined ? 30000 : parseInt(process.env.JWKS_AUTH_CONFIG_TIMEOUT))
358
378
  }
359
379
 
360
380
  const ReadFile = (passwordFile) => {
@@ -374,6 +394,8 @@ const fileconfig = [
374
394
  { fileprop: 'dbpasswordfile', prop: 'dbpassword' },
375
395
  // API identifier file processing
376
396
  { fileprop: 'asapiidentifierfile', prop: 'asapiidentifier' },
397
+ { fileprop: 'asoauthapiidentifierfile', prop: 'asoauthapiidentifier' },
398
+ { fileprop: 'asadminapiidentifierfile', prop: 'asadminapiidentifier' },
377
399
  { fileprop: 'rest01apiidentifierfile', prop: 'rest01apiidentifier' },
378
400
  { fileprop: 'toapiidentifierfile', prop: 'toapiidentifier' },
379
401
  { fileprop: 'imapiidentifierfile', prop: 'imapiidentifier' },