ankitpokhrel / ankitpokhrel/jira-cli

Basic auth on windows is broken when using Credential Manager

Offen
#789 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Go
Sterne
6k
Forks
413
Ø Merge
2 T. 3 Std.
Gemergte PRs (30 T.)
1

Beschreibung

**Describe the bug**
On Windows Platforms, when using Credential Manager to store the basic Auth user/pass, the base64 encoded string will be wrong, causing authentication to fail.

**Please provide following details**
1. JiraCLI Version: 1.5.2
2. Are you using Jira cloud or on-premise jira server? Local
3. What operating system are you using? Windows 10
4. What terminal are you using? Neovide nvim cmd.exe terminal

**To Reproduce**

* Set up jira-cli init using basic auth
* In Windows Credential Manager, create new generic key in the following format:
- Internet or Network address: jira-cli:[username]
- Username: [username]
- Password: [password]

**Expected behavior**

Authentication works with properly encoded base64

**Additional context**
What seems to be happening is that the keyring/credman go packages return stored secrets as utf16(?) encoded strings, containing \0 bytes after every character byte. This results in a base64 encoded string that is around double the size of the expected base64 string.
Using --debug will show the wrong base64 auth header being sent.

A hacky solution taken from [stackoverflow](https://stackoverflow.com/questions/51015400/go-package-wincred-adding-spaces-when-converting-password-from-byte-to-string) is to fix the apitoken where it is set in client.go:44

```
import {
...
++ "runtime"
...
}

...

func Client(config jira.Config) *jira.Client {
...
if config.APIToken == "" {
secret, _ := keyring.Get("jira-cli", config.Login)
++ if runtime.GOOS == "windows" {
++ secret = string(bytes.Replace([]byte(secret), []byte("\000"), nil, -1))
++ }
config.APIToken = secret
}

...
}
```

I'm not a go user and took a quick look at Go strings, but couldn't figure out the proper way to deal with this. Happy to create a pull request if you'd want to move forward with this solution.

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.