-
Notifications
You must be signed in to change notification settings - Fork 12.1k
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
Datasource: Fix allowed cookies to be forwarded as header to backend datasources #49541
Conversation
Drone build failed: https://drone.grafana.net/grafana/grafana-enterprise/19624 |
@@ -149,6 +151,19 @@ func (s *Service) handleQueryData(ctx context.Context, user *models.SignedInUser | |||
req.Headers[k] = v | |||
} | |||
|
|||
if parsedReq.httpRequest != nil && parsedReq.httpRequest.Header.Get("Cookie") != "" && ds.JsonData != nil { |
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 wonder is now a good opportunity to refactor so that resource, query and proxy calls both use the same code?
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.
Good question. They are different though, not sure how easy that would be. Do you have an idea?
if parsedReq.httpRequest != nil && parsedReq.httpRequest.Header.Get("Cookie") != "" && ds.JsonData != nil { | ||
keepCookieNames := []string{} | ||
|
||
if keepCookies := ds.JsonData.Get("keepCookies"); keepCookies != nil { |
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.
This seems like a kinda big feature to stick on the untyped jsonData
Where is this used? Is it something that is really set explicitly from the UI? It seems more like a setting attached to the whole plugin than something that would selectively apply to some instances
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.
It's an oldie part of the datasource HTTP settings for years:
grafana/packages/grafana-ui/src/components/DataSourceSettings/DataSourceHttpSettings.tsx
Lines 172 to 186 in 8fa8c9d
<div className="gf-form"> | |
<InlineFormLabel | |
width={13} | |
tooltip="Grafana proxy deletes forwarded cookies by default. Specify cookies by name that should be forwarded to the data source." | |
> | |
Allowed cookies | |
</InlineFormLabel> | |
<TagsInput | |
tags={dataSourceConfig.jsonData.keepCookies} | |
width={40} | |
onChange={(cookies) => | |
onSettingsChange({ jsonData: { ...dataSourceConfig.jsonData, keepCookies: cookies } }) | |
} | |
/> | |
</div> |
This pull request was removed from the 9.0.0-beta2 milestone because 9.0.0-beta2 is currently being released. |
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
Co-authored-by: Will Browne <wbrowne@users.noreply.github.com>
Drone build failed: https://drone.grafana.net/grafana/grafana-enterprise/20416 |
Verified it works out of the box with Prometheus so going to merge this. Ping @gabor |
What this PR does / why we need it:
Populates
Cookie
header inQueryDataRequest.Headers
given Allowed cookies (jsonData.keepCookies
) is configured for a datasource.Which issue(s) this PR fixes:
Fixes #44250
Special notes for your reviewer: