@@ -169,7 +169,7 @@ export const handleArgs = (args: string[]) => {
169
169
// AUTH OPTIONS
170
170
. option ( 'kasEndpoint' , {
171
171
demandOption : true ,
172
- group : 'KAS Endpoint: ' ,
172
+ group : 'KAS Configuration ' ,
173
173
type : 'string' ,
174
174
description : 'URL to non-default KAS instance (https://mykas.net)' ,
175
175
} )
@@ -179,6 +179,12 @@ export const handleArgs = (args: string[]) => {
179
179
type : 'string' ,
180
180
description : 'URL to non-default OIDC IdP (https://myidp.net)' ,
181
181
} )
182
+ . option ( 'allowList' , {
183
+ group : 'KAS Configuration' ,
184
+ desc : 'allowed KAS origins, comma separated; defaults to [kasEndpoint]' ,
185
+ type : 'string' ,
186
+ validate : ( attributes : string ) => attributes . split ( ',' ) ,
187
+ } )
182
188
. option ( 'auth' , {
183
189
group : 'Authentication:' ,
184
190
type : 'string' ,
@@ -286,13 +292,19 @@ export const handleArgs = (args: string[]) => {
286
292
} ,
287
293
async ( argv ) => {
288
294
log ( 'DEBUG' , 'Running decrypt command' ) ;
295
+ const allowedKases = argv . allowList ?. split ( ',' ) ;
289
296
const authProvider = await processAuth ( argv ) ;
290
297
log ( 'DEBUG' , `Initialized auth provider ${ JSON . stringify ( authProvider ) } ` ) ;
291
298
292
299
const kasEndpoint = argv . kasEndpoint ;
293
300
if ( argv . containerType === 'tdf3' ) {
294
301
log ( 'DEBUG' , `TDF3 Client` ) ;
295
- const client = new TDF3Client ( { authProvider, kasEndpoint, dpopEnabled : argv . dpop } ) ;
302
+ const client = new TDF3Client ( {
303
+ allowedKases,
304
+ authProvider,
305
+ kasEndpoint,
306
+ dpopEnabled : argv . dpop ,
307
+ } ) ;
296
308
log ( 'SILLY' , `Initialized client ${ JSON . stringify ( client ) } ` ) ;
297
309
log ( 'DEBUG' , `About to decrypt [${ argv . file } ]` ) ;
298
310
const ct = await client . decrypt ( await tdf3DecryptParamsFor ( argv ) ) ;
@@ -306,8 +318,13 @@ export const handleArgs = (args: string[]) => {
306
318
const dpopEnabled = ! ! argv . dpop ;
307
319
const client =
308
320
argv . containerType === 'nano'
309
- ? new NanoTDFClient ( { authProvider, kasEndpoint, dpopEnabled } )
310
- : new NanoTDFDatasetClient ( { authProvider, kasEndpoint, dpopEnabled } ) ;
321
+ ? new NanoTDFClient ( { allowedKases, authProvider, kasEndpoint, dpopEnabled } )
322
+ : new NanoTDFDatasetClient ( {
323
+ allowedKases,
324
+ authProvider,
325
+ kasEndpoint,
326
+ dpopEnabled,
327
+ } ) ;
311
328
const buffer = await processDataIn ( argv . file as string ) ;
312
329
313
330
log ( 'DEBUG' , 'Decrypt data.' ) ;
@@ -359,10 +376,16 @@ export const handleArgs = (args: string[]) => {
359
376
const authProvider = await processAuth ( argv ) ;
360
377
log ( 'DEBUG' , `Initialized auth provider ${ JSON . stringify ( authProvider ) } ` ) ;
361
378
const kasEndpoint = argv . kasEndpoint ;
379
+ const allowedKases = argv . allowList ?. split ( ',' ) ;
362
380
363
381
if ( 'tdf3' === argv . containerType ) {
364
382
log ( 'DEBUG' , `TDF3 Client` ) ;
365
- const client = new TDF3Client ( { authProvider, kasEndpoint, dpopEnabled : argv . dpop } ) ;
383
+ const client = new TDF3Client ( {
384
+ allowedKases,
385
+ authProvider,
386
+ kasEndpoint,
387
+ dpopEnabled : argv . dpop ,
388
+ } ) ;
366
389
log ( 'SILLY' , `Initialized client ${ JSON . stringify ( client ) } ` ) ;
367
390
const ct = await client . encrypt ( await tdf3EncryptParamsFor ( argv ) ) ;
368
391
if ( ! ct ) {
@@ -378,8 +401,13 @@ export const handleArgs = (args: string[]) => {
378
401
const dpopEnabled = ! ! argv . dpop ;
379
402
const client =
380
403
argv . containerType === 'nano'
381
- ? new NanoTDFClient ( { authProvider, dpopEnabled, kasEndpoint } )
382
- : new NanoTDFDatasetClient ( { authProvider, dpopEnabled, kasEndpoint } ) ;
404
+ ? new NanoTDFClient ( { allowedKases, authProvider, dpopEnabled, kasEndpoint } )
405
+ : new NanoTDFDatasetClient ( {
406
+ allowedKases,
407
+ authProvider,
408
+ dpopEnabled,
409
+ kasEndpoint,
410
+ } ) ;
383
411
log ( 'SILLY' , `Initialized client ${ JSON . stringify ( client ) } ` ) ;
384
412
385
413
addParams ( client , argv ) ;
0 commit comments