File tree Expand file tree Collapse file tree 3 files changed +20
-17
lines changed Expand file tree Collapse file tree 3 files changed +20
-17
lines changed Original file line number Diff line number Diff line change @@ -271,9 +271,10 @@ export class Client {
271
271
this . kasEndpoint = clientConfig . keyRewrapEndpoint . replace ( / \/ r e w r a p $ / , '' ) ;
272
272
}
273
273
274
+ const kasOrigin = new URL ( this . kasEndpoint ) . origin ;
274
275
if ( clientConfig . allowedKases ) {
275
- this . allowedKases = [ ... clientConfig . allowedKases ] ;
276
- if ( ! validateSecureUrl ( this . kasEndpoint ) && ! this . allowedKases . includes ( this . kasEndpoint ) ) {
276
+ this . allowedKases = clientConfig . allowedKases . map ( ( a ) => new URL ( a ) . origin ) ;
277
+ if ( ! validateSecureUrl ( this . kasEndpoint ) && ! this . allowedKases . includes ( kasOrigin ) ) {
277
278
throw new TdfError ( `Invalid KAS endpoint [${ this . kasEndpoint } ]` ) ;
278
279
}
279
280
this . allowedKases . forEach ( validateSecureUrl ) ;
@@ -283,7 +284,7 @@ export class Client {
283
284
`Invalid KAS endpoint [${ this . kasEndpoint } ]; to force, please list it among allowedKases`
284
285
) ;
285
286
}
286
- this . allowedKases = [ this . kasEndpoint ] ;
287
+ this . allowedKases = [ kasOrigin ] ;
287
288
}
288
289
289
290
this . authProvider = config . authProvider ;
Original file line number Diff line number Diff line change @@ -145,6 +145,7 @@ export type EncryptConfiguration = {
145
145
} ;
146
146
147
147
export type DecryptConfiguration = {
148
+ // Normalized KAS origins to connect to
148
149
allowedKases : string [ ] ;
149
150
authProvider : AuthProvider | AppIdAuthProvider ;
150
151
cryptoService : CryptoService ;
@@ -824,7 +825,8 @@ async function unwrapKey({
824
825
// Get key access information to know the KAS URLS
825
826
const rewrappedKeys = await Promise . all (
826
827
keyAccess . map ( async ( keySplitInfo ) => {
827
- if ( ! allowedKases . includes ( keySplitInfo . url ) ) {
828
+ const kaoOrigin = new URL ( keySplitInfo . url ) . origin ;
829
+ if ( ! allowedKases . includes ( kaoOrigin ) ) {
828
830
throw new UnsafeUrlError (
829
831
`cannot decrypt TDF: [${ keySplitInfo . url } ] not on allowlist ${ JSON . stringify (
830
832
allowedKases
You can’t perform that action at this time.
0 commit comments