Skip to content

Commit b422422

Browse files
feat: Respect API token for mtls auth (#783)
Signed-off-by: Lucas Zanella <lucas.zanella@mercedes-benz.com>
1 parent 4a25d73 commit b422422

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ default.
118118

119119
* If you want to use PAT, you need to set `JIRA_AUTH_TYPE` as `bearer`.
120120
* If you want to use `mtls` run `jira init`. Select installation type `Local`, and then select authentication type as `mtls`.
121+
* In case `JIRA_API_TOKEN` variable is set it will be used together with `mtls`.
121122

122123
#### Shell completion
123124
Check `jira completion --help` for more info on setting up a bash/zsh shell completion.

pkg/jira/client.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,10 @@ func (c *Client) request(ctx context.Context, method, endpoint string, body []by
275275
// When need to compare using `String()` here, it is used to handle cases where the
276276
// authentication type might be empty, ensuring it defaults to the appropriate value.
277277
switch c.authType.String() {
278+
case string(AuthTypeMTLS):
279+
if c.token != "" {
280+
req.Header.Add("Authorization", "Bearer "+c.token)
281+
}
278282
case string(AuthTypeBearer):
279283
req.Header.Add("Authorization", "Bearer "+c.token)
280284
case string(AuthTypeBasic):

0 commit comments

Comments
 (0)