Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport 2.x] feat: http proxy support for oidc #2044

Merged
merged 1 commit into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"@hapi/cryptiles": "5.0.0",
"@hapi/wreck": "^17.1.0",
"html-entities": "1.3.1",
"proxy-agent": "^6.4.0",
"zxcvbn": "^4.4.2"
},
"resolutions": {
Expand Down
29 changes: 16 additions & 13 deletions server/auth/types/openid/openid_auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,9 @@ import {
IOpenSearchDashboardsResponse,
AuthResult,
} from 'opensearch-dashboards/server';
import HTTP from 'http';
import HTTPS from 'https';
import { PeerCertificate } from 'tls';
import { Server, ServerStateCookieOptions } from '@hapi/hapi';
import { ProxyAgent } from 'proxy-agent';
import { SecurityPluginConfigType } from '../../..';
import {
SecuritySessionCookie,
Expand Down Expand Up @@ -175,19 +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 HTTP.Agent(),
https: new HTTPS.Agent(this.wreckHttpsOption),
httpsAllowUnauthorized: new HTTPS.Agent({
rejectUnauthorized: false,
}),
},
});
} else {
return wreck;
httpsAgent = new ProxyAgent(this.wreckHttpsOption);
}
return wreck.defaults({
agents: {
http: httpAgent,
https: httpsAgent,
httpsAllowUnauthorized: httpsAllowUnauthorizedAgent,
},
});
}

getWreckHttpsOptions(): WreckHttpsOptions {
Expand Down
Loading
Loading