@@ -74,7 +74,7 @@ export default class AuthProvider {
7474 *
7575 * Until this is resolved, we use one client application per tenant.
7676 */
77- const client = this . _getClient ( tenantId ) ;
77+ const client = await this . _getClient ( tenantId ) ;
7878
7979 const authRequest = this . _authRequest ( resourceURI , tenantId ) ;
8080 try {
@@ -157,24 +157,39 @@ export default class AuthProvider {
157157 }
158158 }
159159
160- protected _getClient ( tenantId : string ) : PublicClientApplication {
160+ protected async _getClient ( tenantId : string ) :
161+ Promise < PublicClientApplication > {
161162 if ( tenantId in this . _clients ) {
162163 return this . _clients [ tenantId ] ;
163164 }
164- const client = this . _createClient ( tenantId ) ;
165+ const client = await this . _createClient ( tenantId ) ;
165166 if ( ! this . _primaryClient ) {
166167 this . _primaryClient = client ;
167168 }
168169 this . _clients [ tenantId ] = client ;
169170 return client ;
170171 }
171172
172- private _createClient ( tenantId : string ) : PublicClientApplication {
173- return new PublicClientApplication ( {
173+ private async _createClient ( tenantId : string ) :
174+ Promise < PublicClientApplication > {
175+ const proxySettings = await this . app . proxySettings . settings ;
176+ const proxyUrl = proxySettings ?. http . toString ( ) ;
177+ if ( proxyUrl ) {
178+ log . info ( `[${ tenantId } ] Proxying auth endpoints through ` +
179+ proxyUrl ) ;
180+ }
181+
182+ const authority =
183+ `${ this . app . properties . azureEnvironment . aadUrl } ${ tenantId } /` ;
184+
185+ return new PublicClientApplication ( {
186+ system : {
187+ proxyUrl
188+ } ,
174189 auth : {
175190 clientId : this . config . clientId ,
176- authority :
177- ` ${ this . app . properties . azureEnvironment . aadUrl } ${ tenantId } /`
191+ authority,
192+ knownAuthorities : [ authority ]
178193 } ,
179194 cache : {
180195 cachePlugin : this . _cachePlugin
0 commit comments