ankitpokhrel / ankitpokhrel/jira-cli
Basic auth on windows is broken when using Credential Manager
- 主要言語
- Go
- スター
- 6k
- フォーク
- 413
- 平均マージ
- 2日 3時間
- マージ済み PR(30日)
- 1
説明
**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.
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
評価
この issue はまだ評価されていません。