-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
logcli: add support for basic token authentication #2889
Conversation
@grafana/docs-squad, looking at this. |
Codecov Report
@@ Coverage Diff @@
## master #2889 +/- ##
==========================================
- Coverage 61.23% 61.20% -0.04%
==========================================
Files 181 181
Lines 14574 14579 +5
==========================================
- Hits 8925 8923 -2
- Misses 4829 4836 +7
Partials 820 820
|
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.
Added some copy-edits.
Co-authored-by: achatterjee-grafana <[email protected]>
Co-authored-by: achatterjee-grafana <[email protected]>
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 for your contribution.
The world of tokens is huge :-). I think the command line flag's name should use the word "bearer" to narrow down the scope a little, semantically.
I think this sentence can could still be polished, right? :-). Maybe the most important feedback: personally, I do like the semantics and documentation of From the Prometheus docs:
Related: #2739 What do you think about adding a |
@@ -195,6 +197,8 @@ Flags: | |||
--key="" Path to the client certificate key. Can also be set using LOKI_CLIENT_KEY_PATH env var. | |||
--org-id="" adds X-Scope-OrgID to API requests for representing tenant ID. Useful for requesting tenant data when | |||
bypassing an auth gateway. | |||
--token="" Adds Authorization header bearer to API requests for authentication purposes. It can also be set |
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.
whitespace is off here
//The token presence overrides basic-auth authentication | ||
if c.Token != "" { | ||
req.Header.Set("Authorization", "Bearer "+c.Token) | ||
req.Header.Add("Accept", "application/json") |
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 does the Accept
header get set here?
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.
logcli does not set this header elsewhere. By setting it here, we'd expect a 406 error if the response is not adequate (! application/json"
).
IMHO it should be set for all request but this PR's scope is to add support for bearer tokens.
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.
Then leave it out of this PR entirely?
@jgehrcke fair point. Prometheus actually supports both |
This issue has been automatically marked as stale because it has not had any activity in the past 30 days. It will be closed in 7 days if no further activity occurs. Thank you for your contributions. |
@gcotone We would need that too, do you still plan to work on it? |
@dbluxo not in the next month or so. |
What this PR does / why we need it:
Add support for basic token authentication in cases where the loki-queriers/frontends are exposed through a reverse proxy doing token/bearer authentication.
Which issue(s) this PR fixes:
Fixes #395 (Partially - it does not implement oauth2)
Special notes for your reviewer:
Checklist