-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
fix(api-gateway): support proxy when fetching jwk for token validation #9013
base: master
Are you sure you want to change the base?
fix(api-gateway): support proxy when fetching jwk for token validation #9013
Conversation
When fetching the JWK data needed to validate the auth token, the environment proxy settings are not honored.
@johnsca Thanks for this contribution!
Just to double check, which proxy settings exactly are not honored? Also, which platform are we talking about here? |
No proxy settings were being honored when using JWT authentication (specifically, when retrieving the JWK keys to validate the token). This was encountered when deploying Cube in an environment with restricted outbound traffic which requires request to the public internet to go out via a proxy for security reasons. This PR uses |
Hi, @johnsca. Thanks for finding this issue and suggesting a fix. However, the right way to fix this, as you already mentioned, is to patch getProxySettings(), making it aware of common env vars like |
@@ -51,7 +52,7 @@ export type JWKsFetcherOptions = Pick<BackgroundMemoizeOptions<any, any>, 'onBac | |||
|
|||
export const createJWKsFetcher = (jwtOptions: JWTOptions, options: JWKsFetcherOptions) => { | |||
const fetchJwkUrl = asyncMemoizeBackground(async (url: string) => { | |||
const response = await asyncRetry(() => fetch(url), { | |||
const response = await asyncRetry(() => fetch(url, { agent: new ProxyAgent() }), { |
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.
We need to reuse getHttpAgentForProxySettings()
from backend-shared here instead.
@KSDaemon It doesn't seem like a good idea to reimplement what I don't see anywhere that |
Check List
Description of Changes Made (if issue reference is not provided)
When fetching the JWK data needed to validate the auth token, the environment proxy settings are not honored.