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
|
$ ./password-generator | jira login --endpoint=https://my.jira.endpoint.com --user=USERNAME
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Switch binary used for password source
|
#### Switch path 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
|
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-binary` option in the configuration file.
|
by setting the `password-source-path` option in the configuration file.
|
||||||
|
|
||||||
E.g.
|
E.g.
|
||||||
```yaml
|
```yaml
|
||||||
password-source: gopass
|
password-source: gopass
|
||||||
password-name: jira.example.com/myuser
|
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.
|
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.
|
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
|
// 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"`
|
// 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
|
// 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
|
||||||
|
|||||||
+11
-17
@@ -41,18 +41,13 @@ func (o *GlobalOptions) keyName() string {
|
|||||||
return user
|
return user
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *GlobalOptions) GetPasswordBinary() string {
|
func (o *GlobalOptions) GetPasswordPath() string {
|
||||||
binary := o.PasswordSourceBinary.Value
|
// if no password source path then just default
|
||||||
|
// to the password source name
|
||||||
if binary == "" {
|
if o.PasswordSourcePath.Value == "" {
|
||||||
if o.PasswordSource.Value == "gopass" {
|
return o.PasswordSource.Value
|
||||||
return "gopass"
|
}
|
||||||
} else if o.PasswordSource.Value == "pass" {
|
return o.PasswordSourcePath.Value
|
||||||
return "pass"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return binary
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *GlobalOptions) GetPass() string {
|
func (o *GlobalOptions) GetPass() string {
|
||||||
@@ -66,9 +61,8 @@ func (o *GlobalOptions) GetPass() string {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
} else if o.PasswordSource.Value == "gopass" && o.GetPasswordBinary() != "" {
|
} else if o.PasswordSource.Value == "gopass" {
|
||||||
binary := o.GetPasswordBinary()
|
binary := o.GetPasswordPath()
|
||||||
|
|
||||||
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)
|
||||||
@@ -92,8 +86,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" && o.GetPasswordBinary() != "" {
|
} else if o.PasswordSource.Value == "pass" {
|
||||||
binary := o.GetPasswordBinary()
|
binary := o.GetPasswordPath()
|
||||||
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)
|
||||||
|
|||||||
Reference in New Issue
Block a user