Skip to content

Commit

Permalink
chore: reduce code duplication for agent configuration
Browse files Browse the repository at this point in the history
Signed-off-by: Manuelraa <[email protected]>
  • Loading branch information
Manuelraa committed Jul 18, 2024
1 parent 8b6cb97 commit d72eb5f
Showing 1 changed file with 15 additions and 19 deletions.
34 changes: 15 additions & 19 deletions server/auth/types/openid/openid_auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,27 +174,23 @@ export class OpenIdAuthentication extends AuthenticationType {
};
}
this.logger.info(getObjectProperties(this.wreckHttpsOption, 'WreckHttpsOptions'));

// Use proxy agent to allow usage of e.g. http_proxy environment variable
const httpAgent = new ProxyAgent();
const httpsAllowUnauthorizedAgent = new ProxyAgent({
rejectUnauthorized: false,
});
let httpsAgent = new ProxyAgent();
if (Object.keys(this.wreckHttpsOption).length > 0) {
return wreck.defaults({
agents: {
http: new ProxyAgent(),
https: new ProxyAgent(this.wreckHttpsOption),
httpsAllowUnauthorized: new ProxyAgent({
rejectUnauthorized: false,
}),
},
});
} else {
return wreck.defaults({
agents: {
http: new ProxyAgent(),
https: new ProxyAgent(),
httpsAllowUnauthorized: new ProxyAgent({
rejectUnauthorized: false,
}),
},
});
httpsAgent = new ProxyAgent(this.wreckHttpsOption);
}
return wreck.defaults({
agents: {
http: httpAgent,
https: httpsAgent,
httpsAllowUnauthorized: httpsAllowUnauthorizedAgent,
},
});
}

getWreckHttpsOptions(): WreckHttpsOptions {
Expand Down

0 comments on commit d72eb5f

Please sign in to comment.