mirror of
https://github.com/Threnklyn/jira.git
synced 2026-05-19 04:33:28 +02:00
Merge branch 'make-password-source-binary-exchangeable' of https://github.com/patrickpichler/jira into patrickpichler-make-password-source-binary-exchangeable
This commit is contained in:
@@ -374,3 +374,19 @@ When `password-source` is set to `stdin`, the `jira login` command will read fro
|
|||||||
```bash
|
```bash
|
||||||
$ ./password-generator | jira login --endpoint=https://my.jira.endpoint.com --user=USERNAME
|
$ ./password-generator | jira login --endpoint=https://my.jira.endpoint.com --user=USERNAME
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### Switch binary used for password source
|
||||||
|
For `gopass` and `pass` it is possible to switch the binary used for retrieval of the password. This can be accomplised
|
||||||
|
by setting the `password-source-binary` option in the configuration file.
|
||||||
|
|
||||||
|
E.g.
|
||||||
|
```yaml
|
||||||
|
password-source: gopass
|
||||||
|
password-name: jira.example.com/myuser
|
||||||
|
password-source-binary: my-special-gopass
|
||||||
|
```
|
||||||
|
|
||||||
|
This will cause go-jira to use the `gopass` style cli interaction with the `my-special-gopass` binary.
|
||||||
|
|
||||||
|
If you ommit the `password-source-binary` option, either `gopass` (for `gopass`) or `pass` (for `pass`)
|
||||||
|
will be used.
|
||||||
|
|||||||
@@ -72,6 +72,8 @@ type GlobalOptions struct {
|
|||||||
// location using the `pass` tool, if missing prompt the user and store in the PasswordDirectory
|
// location using the `pass` tool, if missing prompt the user and store in the PasswordDirectory
|
||||||
PasswordSource figtree.StringOption `yaml:"password-source,omitempty" json:"password-source,omitempty"`
|
PasswordSource figtree.StringOption `yaml:"password-source,omitempty" json:"password-source,omitempty"`
|
||||||
|
|
||||||
|
PasswordSourceBinary figtree.StringOption `yaml:"password-source-binary,omitempty" json:"password-source-binary,omitempty"`
|
||||||
|
|
||||||
// PasswordDirectory is only used for the "pass" PasswordSource. It is the location for the encrypted password
|
// PasswordDirectory is only used for the "pass" PasswordSource. It is the location for the encrypted password
|
||||||
// files used by `pass`. Effectively this overrides the "PASSWORD_STORE_DIR" environment variable
|
// files used by `pass`. Effectively this overrides the "PASSWORD_STORE_DIR" environment variable
|
||||||
PasswordDirectory figtree.StringOption `yaml:"password-directory,omitempty" json:"password-directory,omitempty"`
|
PasswordDirectory figtree.StringOption `yaml:"password-directory,omitempty" json:"password-directory,omitempty"`
|
||||||
|
|||||||
+21
-4
@@ -41,6 +41,20 @@ func (o *GlobalOptions) keyName() string {
|
|||||||
return user
|
return user
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (o *GlobalOptions) GetPasswordBinary() string {
|
||||||
|
binary := o.PasswordSourceBinary.Value
|
||||||
|
|
||||||
|
if binary == "" {
|
||||||
|
if o.PasswordSource.Value == "gopass" {
|
||||||
|
return "gopass"
|
||||||
|
} else if o.PasswordSource.Value == "pass" {
|
||||||
|
return "pass"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return binary
|
||||||
|
}
|
||||||
|
|
||||||
func (o *GlobalOptions) GetPass() string {
|
func (o *GlobalOptions) GetPass() string {
|
||||||
log.Debugf("Getting Password")
|
log.Debugf("Getting Password")
|
||||||
passwd := ""
|
passwd := ""
|
||||||
@@ -52,7 +66,9 @@ func (o *GlobalOptions) GetPass() string {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
} else if o.PasswordSource.Value == "gopass" {
|
} else if o.PasswordSource.Value == "gopass" && o.GetPasswordBinary() != "" {
|
||||||
|
binary := o.GetPasswordBinary()
|
||||||
|
|
||||||
if o.PasswordDirectory.Value != "" {
|
if o.PasswordDirectory.Value != "" {
|
||||||
orig := os.Getenv("PASSWORD_STORE_DIR")
|
orig := os.Getenv("PASSWORD_STORE_DIR")
|
||||||
log.Debugf("using password-directory: %s", o.PasswordDirectory)
|
log.Debugf("using password-directory: %s", o.PasswordDirectory)
|
||||||
@@ -62,7 +78,7 @@ func (o *GlobalOptions) GetPass() string {
|
|||||||
if passDir := os.Getenv("PASSWORD_STORE_DIR"); passDir != "" {
|
if passDir := os.Getenv("PASSWORD_STORE_DIR"); passDir != "" {
|
||||||
log.Debugf("using PASSWORD_STORE_DIR=%s", passDir)
|
log.Debugf("using PASSWORD_STORE_DIR=%s", passDir)
|
||||||
}
|
}
|
||||||
if bin, err := exec.LookPath("gopass"); err == nil {
|
if bin, err := exec.LookPath(binary); err == nil {
|
||||||
log.Debugf("found gopass at: %s", bin)
|
log.Debugf("found gopass at: %s", bin)
|
||||||
buf := bytes.NewBufferString("")
|
buf := bytes.NewBufferString("")
|
||||||
cmd := exec.Command(bin, "show", "-o", o.keyName())
|
cmd := exec.Command(bin, "show", "-o", o.keyName())
|
||||||
@@ -76,7 +92,8 @@ func (o *GlobalOptions) GetPass() string {
|
|||||||
} else {
|
} else {
|
||||||
log.Warning("Gopass binary was not found! Fallback to default password behaviour!")
|
log.Warning("Gopass binary was not found! Fallback to default password behaviour!")
|
||||||
}
|
}
|
||||||
} else if o.PasswordSource.Value == "pass" {
|
} else if o.PasswordSource.Value == "pass" && o.GetPasswordBinary() != "" {
|
||||||
|
binary := o.GetPasswordBinary()
|
||||||
if o.PasswordDirectory.Value != "" {
|
if o.PasswordDirectory.Value != "" {
|
||||||
orig := os.Getenv("PASSWORD_STORE_DIR")
|
orig := os.Getenv("PASSWORD_STORE_DIR")
|
||||||
log.Debugf("using password-directory: %s", o.PasswordDirectory)
|
log.Debugf("using password-directory: %s", o.PasswordDirectory)
|
||||||
@@ -86,7 +103,7 @@ func (o *GlobalOptions) GetPass() string {
|
|||||||
if passDir := os.Getenv("PASSWORD_STORE_DIR"); passDir != "" {
|
if passDir := os.Getenv("PASSWORD_STORE_DIR"); passDir != "" {
|
||||||
log.Debugf("using PASSWORD_STORE_DIR=%s", passDir)
|
log.Debugf("using PASSWORD_STORE_DIR=%s", passDir)
|
||||||
}
|
}
|
||||||
if bin, err := exec.LookPath("pass"); err == nil {
|
if bin, err := exec.LookPath(binary); err == nil {
|
||||||
log.Debugf("found pass at: %s", bin)
|
log.Debugf("found pass at: %s", bin)
|
||||||
buf := bytes.NewBufferString("")
|
buf := bytes.NewBufferString("")
|
||||||
cmd := exec.Command(bin, o.keyName())
|
cmd := exec.Command(bin, o.keyName())
|
||||||
|
|||||||
Reference in New Issue
Block a user