File tree Expand file tree Collapse file tree 3 files changed +16
-16
lines changed
Expand file tree Collapse file tree 3 files changed +16
-16
lines changed Original file line number Diff line number Diff line change @@ -1790,21 +1790,18 @@ types:
17901790 const response = await authorizerClient . DecisionTree ( {
17911791 identityContext : await AnonymousIdentityMapper ( ) ,
17921792 policyInstance : policyInstance ( "todo" , "todo" ) ,
1793- policyContext : policyContext ( ) ,
1793+ policyContext : policyContext ( "todoApp" ) ,
17941794 } ) ;
17951795
17961796 const expectedResult = {
17971797 path : {
1798- "rebac.check" : {
1799- allowed : false ,
1800- } ,
18011798 "todoApp.DELETE.todos.__id" : { allowed : false } ,
18021799 "todoApp.GET.todos" : { allowed : true } ,
18031800 "todoApp.GET.users.__userID" : { allowed : true } ,
18041801 "todoApp.POST.todos" : { allowed : false } ,
18051802 "todoApp.PUT.todos.__id" : { allowed : false } ,
18061803 } ,
1807- pathRoot : "" ,
1804+ pathRoot : "todoApp " ,
18081805 } ;
18091806
18101807 expect ( response ) . toEqual ( expectedResult ) ;
@@ -1830,6 +1827,7 @@ types:
18301827 describe ( "Query" , ( ) => {
18311828 it ( "returns the correct data structure" , async ( ) => {
18321829 const response = await authorizerClient . Query ( {
1830+ identityContext : await AnonymousIdentityMapper ( ) ,
18331831 query : "x=data" ,
18341832 input : '{"foo": "bar"}' ,
18351833 } ) ;
Original file line number Diff line number Diff line change @@ -30,6 +30,8 @@ import {
3030 QueryRequest ,
3131} from "./types" ;
3232
33+ const ADDRESS_REGEX = / h t t p s ? : \/ \/ / ;
34+
3335type AuthorizerConfig = {
3436 authorizerServiceUrl ?: string ;
3537 tenantId ?: string ;
@@ -62,8 +64,15 @@ export class Authorizer {
6264 interceptors . push ( traceMessage ) ;
6365 }
6466
65- const baseServiceUrl =
66- config . authorizerServiceUrl || "authorizer.prod.aserto.com:8443" ;
67+ const getServiceUrl = ( ) => {
68+ const baseServiceUrl =
69+ config . authorizerServiceUrl || "authorizer.prod.aserto.com:8443" ;
70+ const scheme = "https://" ;
71+
72+ const serviceUrlMatch = baseServiceUrl ?. match ( ADDRESS_REGEX ) ;
73+ return serviceUrlMatch ? baseServiceUrl : `${ scheme } ${ baseServiceUrl } ` ;
74+ } ;
75+
6776 const caFilePath = config . authorizerCertFile || config . caFile ;
6877 const baseCaFile = ! ! caFilePath ? readFileSync ( caFilePath ) : undefined ;
6978
@@ -75,7 +84,7 @@ export class Authorizer {
7584 } ;
7685
7786 const baseGrpcTransport = createGrpcTransport ( {
78- baseUrl : `https:// ${ baseServiceUrl } ` ,
87+ baseUrl : getServiceUrl ( ) ,
7988 interceptors : interceptors ,
8089 nodeOptions : baseNodeOptions ,
8190 } ) ;
Original file line number Diff line number Diff line change @@ -34,14 +34,7 @@ export default (
3434 if ( ! authorizerServiceUrl && res ) {
3535 return error ( res , "must provide authorizerServiceUrl in option map" ) ;
3636 }
37- let authorizerUrl = `${ authorizerServiceUrl } ` ;
38- // strip any https:// or http:// prefix since this is a gRPC address
39- if ( authorizerUrl . startsWith ( "https://" ) ) {
40- authorizerUrl = authorizerUrl . split ( "https://" ) [ 1 ] ! ;
41- }
42- if ( authorizerUrl . startsWith ( "http://" ) ) {
43- authorizerUrl = authorizerUrl . split ( "http://" ) [ 1 ] ! ;
44- }
37+ const authorizerUrl = `${ authorizerServiceUrl } ` ;
4538
4639 // set the authorizer API key
4740 let authorizerApiKey = null ;
You can’t perform that action at this time.
0 commit comments