-
Notifications
You must be signed in to change notification settings - Fork 6
Feature/use api key #1
base: master
Are you sure you want to change the base?
Feature/use api key #1
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 contribution!
@josselinchevalay Please, add description of apiKey property to README.md |
/** | ||
* Grafana api key | ||
*/ | ||
String getApiKey() { return apiKey; } |
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.
@josselinchevalay Please, make each statement on a line by itself. Like other getters.
String getApiKey() {
return apiKey;
}
@@ -78,8 +78,12 @@ private static String getHttpResponseBodyAsString(HttpResponse response) throws | |||
} | |||
|
|||
private String getAuthHeader() { | |||
return "Basic " + Base64.getEncoder().encodeToString( | |||
(grafanaUploadSettings.getUser() + ':' + grafanaUploadSettings.getPassword()).getBytes(UTF_8)); | |||
if(grafanaUploadSettings.getApiKey().isEmpty()) { |
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.
@josselinchevalay i think it will be better to invert this if statement. And you should check that apiKey property is not null before. Smth like this:
if (grafanaUploadSettings.getApiKey() != null && !grafanaUploadSettings.getApiKey().isEmpty()) {
return "Basic " + grafanaUploadSettings.getApiKey();
}
// old way
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.
@komarovd95 i'm not sure if we no declare Api key we can use Basic auth else we use Bearer and api key
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.
Codecov Report
@@ Coverage Diff @@
## master #1 +/- ##
============================================
- Coverage 82.85% 80.82% -2.04%
- Complexity 33 34 +1
============================================
Files 8 8
Lines 140 146 +6
Branches 5 5
============================================
+ Hits 116 118 +2
- Misses 19 22 +3
- Partials 5 6 +1
Continue to review full report at Codecov.
|
Hello,
i think it can be intresting use api key looks like : http://docs.grafana.org/http_api/auth/#create-api-token instead of user credentials.
Regards