mirror of
https://github.com/Threnklyn/jira.git
synced 2026-05-18 20:23:28 +02:00
use password-source-path to allow overriding binary and/or path to binary
This commit is contained in:
@@ -375,18 +375,18 @@ When `password-source` is set to `stdin`, the `jira login` command will read fro
|
||||
$ ./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.
|
||||
#### Switch path used for password source
|
||||
For `gopass` and `pass` it is possible to specify the full path for the `password-source` tool used for retrieval of the password. This can be accomplised
|
||||
by setting the `password-source-path` option in the configuration file.
|
||||
|
||||
E.g.
|
||||
```yaml
|
||||
password-source: gopass
|
||||
password-name: jira.example.com/myuser
|
||||
password-source-binary: my-special-gopass
|
||||
password-source-path: /path/to/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`)
|
||||
If you ommit the `password-source-path` option, either `gopass` (for `gopass`) or `pass` (for `pass`)
|
||||
will be used.
|
||||
|
||||
+2
-1
@@ -72,7 +72,8 @@ type GlobalOptions struct {
|
||||
// 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"`
|
||||
|
||||
PasswordSourceBinary figtree.StringOption `yaml:"password-source-binary,omitempty" json:"password-source-binary,omitempty"`
|
||||
// PasswordSourcePath can be used to specify the path to the PasswordSource binary to use.
|
||||
PasswordSourcePath figtree.StringOption `yaml:"password-source-path,omitempty" json:"password-source-path,omitempty"`
|
||||
|
||||
// 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
|
||||
|
||||
+10
-16
@@ -41,18 +41,13 @@ func (o *GlobalOptions) keyName() string {
|
||||
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"
|
||||
func (o *GlobalOptions) GetPasswordPath() string {
|
||||
// if no password source path then just default
|
||||
// to the password source name
|
||||
if o.PasswordSourcePath.Value == "" {
|
||||
return o.PasswordSource.Value
|
||||
}
|
||||
}
|
||||
|
||||
return binary
|
||||
return o.PasswordSourcePath.Value
|
||||
}
|
||||
|
||||
func (o *GlobalOptions) GetPass() string {
|
||||
@@ -66,9 +61,8 @@ func (o *GlobalOptions) GetPass() string {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
} else if o.PasswordSource.Value == "gopass" && o.GetPasswordBinary() != "" {
|
||||
binary := o.GetPasswordBinary()
|
||||
|
||||
} else if o.PasswordSource.Value == "gopass" {
|
||||
binary := o.GetPasswordPath()
|
||||
if o.PasswordDirectory.Value != "" {
|
||||
orig := os.Getenv("PASSWORD_STORE_DIR")
|
||||
log.Debugf("using password-directory: %s", o.PasswordDirectory)
|
||||
@@ -92,8 +86,8 @@ func (o *GlobalOptions) GetPass() string {
|
||||
} else {
|
||||
log.Warning("Gopass binary was not found! Fallback to default password behaviour!")
|
||||
}
|
||||
} else if o.PasswordSource.Value == "pass" && o.GetPasswordBinary() != "" {
|
||||
binary := o.GetPasswordBinary()
|
||||
} else if o.PasswordSource.Value == "pass" {
|
||||
binary := o.GetPasswordPath()
|
||||
if o.PasswordDirectory.Value != "" {
|
||||
orig := os.Getenv("PASSWORD_STORE_DIR")
|
||||
log.Debugf("using password-directory: %s", o.PasswordDirectory)
|
||||
|
||||
Reference in New Issue
Block a user