Skip to content

Commit

Permalink
feat: Respect API token for mtls auth
Browse files Browse the repository at this point in the history
Signed-off-by: Lucas Zanella <[email protected]>
  • Loading branch information
LucasZanellaMBTI committed Sep 30, 2024
1 parent 3422178 commit c0d5b62
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ default.

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

#### Shell completion
Check `jira completion --help` for more info on setting up a bash/zsh shell completion.
Expand Down
4 changes: 4 additions & 0 deletions pkg/jira/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,10 @@ func (c *Client) request(ctx context.Context, method, endpoint string, body []by
// When need to compare using `String()` here, it is used to handle cases where the
// authentication type might be empty, ensuring it defaults to the appropriate value.
switch c.authType.String() {
case string(AuthTypeMTLS):
if c.token != "" {
req.Header.Add("Authorization", "Bearer "+c.token)
}
case string(AuthTypeBearer):
req.Header.Add("Authorization", "Bearer "+c.token)
case string(AuthTypeBasic):
Expand Down

0 comments on commit c0d5b62

Please sign in to comment.