mirror of
https://github.com/Threnklyn/jira.git
synced 2026-05-18 20:23:28 +02:00
Add authentication-method: bearer-token
This commit is contained in:
+5
-1
@@ -173,7 +173,11 @@ func register(app *kingpin.Application, o *oreo.Client, fig *figtree.FigTree) {
|
|||||||
token := globals.GetPass()
|
token := globals.GetPass()
|
||||||
authHeader := fmt.Sprintf("Basic %s", base64.StdEncoding.EncodeToString([]byte(fmt.Sprintf("%s:%s", globals.Login.Value, token))))
|
authHeader := fmt.Sprintf("Basic %s", base64.StdEncoding.EncodeToString([]byte(fmt.Sprintf("%s:%s", globals.Login.Value, token))))
|
||||||
req.Header.Add("Authorization", authHeader)
|
req.Header.Add("Authorization", authHeader)
|
||||||
}
|
} else if globals.AuthMethod() == "bearer-token" {
|
||||||
|
token := globals.GetPass()
|
||||||
|
authHeader := fmt.Sprintf("Bearer %s", token)
|
||||||
|
req.Header.Add("Authorization", authHeader)
|
||||||
|
}
|
||||||
return req, nil
|
return req, nil
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -50,6 +50,10 @@ func CmdLogin(o *oreo.Client, globals *jiracli.GlobalOptions, opts *jiracli.Comm
|
|||||||
log.Noticef("No need to login when using api-token authentication method")
|
log.Noticef("No need to login when using api-token authentication method")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
if globals.AuthMethod() == "bearer-token" {
|
||||||
|
log.Noticef("No need to login when using bearer-token authentication method")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
ua := o.WithoutRedirect().WithRetries(0).WithoutCallbacks().WithPostCallback(authCallback)
|
ua := o.WithoutRedirect().WithRetries(0).WithoutCallbacks().WithPostCallback(authCallback)
|
||||||
for {
|
for {
|
||||||
|
|||||||
+3
-3
@@ -30,13 +30,13 @@ func CmdLogoutRegistry() *jiracli.CommandRegistryEntry {
|
|||||||
|
|
||||||
// CmdLogout will attempt to terminate an active Jira session
|
// CmdLogout will attempt to terminate an active Jira session
|
||||||
func CmdLogout(o *oreo.Client, globals *jiracli.GlobalOptions, opts *jiracli.CommonOptions) error {
|
func CmdLogout(o *oreo.Client, globals *jiracli.GlobalOptions, opts *jiracli.CommonOptions) error {
|
||||||
if globals.AuthMethod() == "api-token" {
|
if (globals.AuthMethod() == "api-token" || globals.AuthMethod() == "bearer-token") {
|
||||||
log.Noticef("No need to logout when using api-token authentication method")
|
log.Noticef("No need to logout when using api-token or bearer-token authentication method")
|
||||||
if globals.GetPass() != "" && terminal.IsTerminal(int(os.Stdin.Fd())) && terminal.IsTerminal(int(os.Stdout.Fd())) {
|
if globals.GetPass() != "" && terminal.IsTerminal(int(os.Stdin.Fd())) && terminal.IsTerminal(int(os.Stdout.Fd())) {
|
||||||
delete := false
|
delete := false
|
||||||
err := survey.AskOne(
|
err := survey.AskOne(
|
||||||
&survey.Confirm{
|
&survey.Confirm{
|
||||||
Message: fmt.Sprintf("Delete api-token from password provider [%s]: ", globals.PasswordSource),
|
Message: fmt.Sprintf("Delete token from password provider [%s]: ", globals.PasswordSource),
|
||||||
Default: false,
|
Default: false,
|
||||||
},
|
},
|
||||||
&delete,
|
&delete,
|
||||||
|
|||||||
Reference in New Issue
Block a user