Skip to content

Commit

Permalink
Support custom headers to JIRA to bypass 2 factor auth
Browse files Browse the repository at this point in the history
  • Loading branch information
drhip committed Nov 7, 2020
1 parent 052d0e4 commit 2792a50
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/main/java/se/bjurr/gitchangelog/main/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public class Main {
public static final String PARAM_GITHUBAPI = "-gapi";
public static final String PARAM_GITHUBTOKEN = "-gtok";
public static final String PARAM_EXTENDED_VARIABLES = "-ex";
public static final String PARAM_EXTENDED_HEADERS = "-eh";
public static final String PARAM_TEMPLATE_CONTENT = "-tec";
public static final String PARAM_GITLABTOKEN = "-glt";
public static final String PARAM_GITLABSERVER = "-gls";
Expand Down Expand Up @@ -264,6 +265,15 @@ public static void main(String args[]) throws Exception {
.defaultValue("") //
.build();

Argument<String> extendedHeadersArgument =
stringArgument(PARAM_EXTENDED_HEADERS, "--extended-headers") //
.description(
"Extended headers that will send when access JIRA. e.g. "
+ PARAM_EXTENDED_HEADERS
+ " \"{\\\"CF-Access-Client-ID\\\": \\\"abcde12345xyz.access\\\"}\"") //
.defaultValue("") //
.build();

Argument<String> templateContentArgument =
stringArgument(PARAM_TEMPLATE_CONTENT, "--template-content") //
.description("String to use as template.") //
Expand Down Expand Up @@ -322,6 +332,7 @@ public static void main(String args[]) throws Exception {
jiraPasswordPatternArgument,
jiraBasicAuthStringPatternArgument,
extendedVariablesArgument,
extendedHeadersArgument,
templateContentArgument,
gitHubTokenArgument,
ignoreCommitsWithoutIssueArgument,
Expand Down Expand Up @@ -353,6 +364,14 @@ public static void main(String args[]) throws Exception {
changelogApiBuilder.withExtendedVariables(extendedVariables);
}

if (arg.wasGiven(extendedHeadersArgument)) {
String jsonString = arg.get(extendedHeadersArgument);
Gson gson = new Gson();
Type type = new TypeToken<Map<String, String>>() {}.getType();
Map<String, String> jsonObject = gson.fromJson(jsonString, type);
changelogApiBuilder.withExtendedHeaders(jsonObject);
}

if (arg.wasGiven(templateContentArgument)) {
changelogApiBuilder.withTemplateContent(arg.get(templateContentArgument));
}
Expand Down

0 comments on commit 2792a50

Please sign in to comment.