-
-
Notifications
You must be signed in to change notification settings - Fork 389
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
OIDC issuer behind a proxy cannot be accessed #1363
base: main
Are you sure you want to change the base?
OIDC issuer behind a proxy cannot be accessed #1363
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your patch @tristanrobert!
Some tests are failling. Some are just because of instabilities like Importer2
, we can ignore them.
But some of them are due to the enhancement you introduced (these tests). Are you comfortable with adapting them? Or do you want me to do that for you?
The tests to adapt are here:
https://github.com/gristlabs/grist-core/blob/main/test/server/lib/OIDCConfig.ts
To setup the environment and to run the tests: https://github.com/gristlabs/grist-core/blob/main/documentation/develop.md
I have fixed the tests @fflorent |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds almost good.
I left you some remarks. Also I need to setup an environment to test your work. I am doing that ASAP.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you @tristanrobert!
The code here looks fine for doing what it intends, but I am not sure we want
@paulfitz , what do you think? |
That's a good point @dsagal. There are two distinct usages here, and they could conflict. A proxy set up specifically for untrusted requests might not even be able to reach some internal OIDC-related server. Not sure I have a good idea how to deal with this. Perhaps the proxying of untrusted traffic should have distinct configuration? The standard environment variable for this in other tools is |
I think we should plan for a future where support for HTTP_PROXY/HTTPS_PROXY/NO_PROXY becomes more common in node apps through better native node support for it, following the trajectory of other languages. @dsagal what do you think of this proposal:
Suppose we rename the current function
I include The use of Hopefully in the future The name of |
Talked to @dsagal about #1363 (comment) offline and it seems acceptable. One modification: we'd make @tristanrobert let me know if you're up for making these changes, or want to hand them off. |
I'm trying to make you a proposition. |
1 similar comment
I'm trying to make you a proposition. |
I have commited what I have understood from #1363 (comment) and I have tested it in self hosted instance behind corporate proxy. |
app/server/lib/Requests.ts
Outdated
@@ -91,7 +91,7 @@ export class DocRequests { | |||
} | |||
const response = await fetch(urlObj.toString(), { | |||
headers: headers || {}, | |||
agent: proxyAgent(urlObj), | |||
agent: proxyAgentForTrustedRequests(urlObj), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be untrusted, as this module is used for the REQUEST()
function.
Quoting the README file:
GRIST_ENABLE_REQUEST_FUNCTION enables the REQUEST function. This function performs HTTP requests in a similar way to requests.request. This function presents a significant security risk, since it can let users call internal endpoints when Grist is available publicly. This function can also cause performance issues. Unset by default.
agent: proxyAgentForTrustedRequests(urlObj), | |
agent: proxyAgentForUntrustedRequests(urlObj), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am lost. 😞 OIDCCOnfig tests fail because it is contradictory. Indeed, if GRIST_HTTPS_PROXY enables proxyAgentForUntrustedRequests and HTTPS_PROXY enables proxyAgentForTrustedRequests as ProxyAgent.tx does, then if requests uses proxyAgentForUntrustedRequests we must enable GRIST_HTTPS_PROXY with the same corporate proxy value, but then why two env vars ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why two environment variables: as suggested by Paul above, it is useful to be able to distinguish requests that are made to URLs determined by an administrator, e.g. requests to an OIDC provider — we call those "trusted"; from requests made to URLs that are given by Grist end users (i.e. Webhooks and requests made through the REQUEST
function if you enable it), over which the administrator has no control — "untrusted" requests.
Having both HTTPS_PROXY
for trusted requests and HTTPS_PROXY_UNTRUSTED_URLS
(new name for GRIST_HTTPS_PROXY
suggested by Paul) for untrusted requests can let an administrator apply more stringent controls on untrusted requests.
For example, in your case you may want to use a lenient outgoing proxy for HTTPS_PROXY
, that allows any request to the internet (including those to your OIDC provider); and set up a stricter HTTP proxy pointed to by HTTPS_PROXY_UNTRUSTED_URLS
for untrusted requests, for example one that only allows requests to a limited list of domains, and/or limits request verbs, sizes, etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tristanrobert Will you still make the changes suggested above? I find myself in agreement that HTTPS_PROXY_UNTRUSTED_URLS
is a better name, as well as noting that REQUEST
should use the proxy for untrusted URLs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am working on it, and I agree too that this would be a better name!
Proxy Agent with corporate settings is needed too in Assistance.ts and Telemetry.ts that use node-fetch. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to see an implementation of the changes others have suggested. Changing the variable name, some tweaks to documentation, and ensuring that REQUEST
goes through the proxy for untrusted URLs are all reasonable fixes. @tristanrobert, are you still working on this?
README.md
Outdated
| GRIST_HTTPS_PROXY | if set with url, use this proxy for webhook payload delivery; if not set or set to direct it call `"direct"` webhook payload. | | ||
| HTTPS_PROXY or https_proxy | if set, use this reverse web proxy (corporate proxy) for fetching custom widgets repository from url or OIDC config from issuer url outside the grist stack. | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| GRIST_HTTPS_PROXY | if set with url, use this proxy for webhook payload delivery; if not set or set to direct it call `"direct"` webhook payload. | | |
| HTTPS_PROXY or https_proxy | if set, use this reverse web proxy (corporate proxy) for fetching custom widgets repository from url or OIDC config from issuer url outside the grist stack. | | |
| GRIST_HTTPS_PROXY | Full URL of proxy for delivering webhook payloads. Default value is `direct` for delivering payloads without proxying. | | |
| HTTPS_PROXY or https_proxy | Full URL of reverse web proxy (corporate proxy) for fetching the custom widgets repository or the OIDC config from the issuer. | |
app/server/lib/Requests.ts
Outdated
@@ -91,7 +91,7 @@ export class DocRequests { | |||
} | |||
const response = await fetch(urlObj.toString(), { | |||
headers: headers || {}, | |||
agent: proxyAgent(urlObj), | |||
agent: proxyAgentForTrustedRequests(urlObj), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tristanrobert Will you still make the changes suggested above? I find myself in agreement that HTTPS_PROXY_UNTRUSTED_URLS
is a better name, as well as noting that REQUEST
should use the proxy for untrusted URLs.
We are still working on it with @fflorent. |
Co-authored-by: Florent <[email protected]>
Co-authored-by: Florent <[email protected]>
Co-authored-by: Florent <[email protected]>
Co-authored-by: Florent <[email protected]>
Co-authored-by: Florent <[email protected]>
883369b
to
0fe0a12
Compare
Fixes #942
Context
Self hosted instance behind corporate proxy with OIDC issuer outside corporate LAN.
Proposed solution
Add ./ProxyAgent agent in openid-client custom http_options if issuer is on Internet
Related issues
Has this been tested?
Screenshots / Screencasts